Home > matpower5.0 > t > t_run_tests.m

t_run_tests

PURPOSE ^

T_RUN_TESTS Run a series of tests.

SYNOPSIS ^

function t_run_tests(test_names, verbose)

DESCRIPTION ^

T_RUN_TESTS  Run a series of tests.
   T_RUN_TESTS(TEST_NAMES, VERBOSE) runs a set of tests whose names
   are given in the cell array TEST_NAMES. If the optional parameter
   VERBOSE is true, it prints the details of the individual tests.

   Example:
       tests{end+1} = 't_loadcase';
       tests{end+1} = 't_jacobian';
       tests{end+1} = 't_hessian';
       t_run_tests( tests, verbose );

   See also T_BEGIN, T_END.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function t_run_tests(test_names, verbose)
0002 %T_RUN_TESTS  Run a series of tests.
0003 %   T_RUN_TESTS(TEST_NAMES, VERBOSE) runs a set of tests whose names
0004 %   are given in the cell array TEST_NAMES. If the optional parameter
0005 %   VERBOSE is true, it prints the details of the individual tests.
0006 %
0007 %   Example:
0008 %       tests{end+1} = 't_loadcase';
0009 %       tests{end+1} = 't_jacobian';
0010 %       tests{end+1} = 't_hessian';
0011 %       t_run_tests( tests, verbose );
0012 %
0013 %   See also T_BEGIN, T_END.
0014 
0015 %   MATPOWER
0016 %   $Id: t_run_tests.m 1635 2010-04-26 19:45:26Z ray $
0017 %   by Ray Zimmerman, PSERC Cornell
0018 %   Copyright (c) 2004-2010 by Power System Engineering Research Center (PSERC)
0019 %
0020 %   This file is part of MATPOWER.
0021 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0022 %
0023 %   MATPOWER is free software: you can redistribute it and/or modify
0024 %   it under the terms of the GNU General Public License as published
0025 %   by the Free Software Foundation, either version 3 of the License,
0026 %   or (at your option) any later version.
0027 %
0028 %   MATPOWER is distributed in the hope that it will be useful,
0029 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
0030 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0031 %   GNU General Public License for more details.
0032 %
0033 %   You should have received a copy of the GNU General Public License
0034 %   along with MATPOWER. If not, see <http://www.gnu.org/licenses/>.
0035 %
0036 %   Additional permission under GNU GPL version 3 section 7
0037 %
0038 %   If you modify MATPOWER, or any covered work, to interface with
0039 %   other modules (such as MATLAB code and MEX-files) available in a
0040 %   MATLAB(R) or comparable environment containing parts covered
0041 %   under other licensing terms, the licensors of MATPOWER grant
0042 %   you additional permission to convey the resulting work.
0043 
0044 if nargin < 2
0045     verbose = 0;
0046 end
0047 
0048 global t_num_of_tests;
0049 global t_counter;
0050 global t_ok_cnt;
0051 global t_not_ok_cnt;
0052 global t_skip_cnt;
0053 
0054 %% figure out padding for printing
0055 if ~verbose
0056     len = zeros(length(test_names), 1);
0057     for k = 1:length(test_names)
0058         len(k) = length(test_names{k});
0059     end
0060     maxlen = max(len);
0061 end
0062 
0063 %% initialize statistics
0064 num_of_tests = 0;
0065 counter = 0;
0066 ok_cnt = 0;
0067 not_ok_cnt = 0;
0068 skip_cnt = 0;
0069 
0070 t0 = clock;
0071 for k = 1:length(test_names)
0072     if verbose
0073         fprintf('\n----------  %s  ----------\n', test_names{k});
0074     else
0075         pad = maxlen + 4 - length(test_names{k});
0076         fprintf('%s', test_names{k});
0077         for m = 1:pad, fprintf('.'); end
0078     end
0079     feval( test_names{k}, ~verbose );
0080     
0081     num_of_tests    = num_of_tests  + t_num_of_tests;
0082     counter         = counter       + t_counter;
0083     ok_cnt          = ok_cnt        + t_ok_cnt;
0084     not_ok_cnt      = not_ok_cnt    + t_not_ok_cnt;
0085     skip_cnt        = skip_cnt      + t_skip_cnt;
0086 end
0087 
0088 if verbose
0089     fprintf('\n\n----------  Summary  ----------\n');
0090 end
0091 if counter == num_of_tests && counter == ok_cnt + skip_cnt && not_ok_cnt == 0
0092     if skip_cnt
0093         fprintf('All tests successful (%d passed, %d skipped of %d)', ...
0094             ok_cnt, skip_cnt, num_of_tests);
0095     else
0096         fprintf('All tests successful (%d of %d)', ok_cnt, num_of_tests);
0097     end
0098 else
0099     fprintf('Ran %d of %d tests: %d passed, %d failed', ...
0100         counter, num_of_tests, ok_cnt, not_ok_cnt);
0101     if skip_cnt
0102         fprintf(', %d skipped', skip_cnt);
0103     end
0104 end
0105 fprintf('\nElapsed time %.2f seconds.\n', etime(clock, t0));

Generated on Mon 26-Jan-2015 15:21:31 by m2html © 2005