Home > matpower6.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 %   Copyright (c) 2004-2016, Power Systems Engineering Research Center (PSERC)
0017 %   by Ray Zimmerman, PSERC Cornell
0018 %
0019 %   This file is part of MATPOWER.
0020 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0021 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0022 
0023 if nargin < 2
0024     verbose = 0;
0025 end
0026 
0027 global t_num_of_tests;
0028 global t_counter;
0029 global t_ok_cnt;
0030 global t_not_ok_cnt;
0031 global t_skip_cnt;
0032 
0033 %% figure out padding for printing
0034 if ~verbose
0035     len = zeros(length(test_names), 1);
0036     for k = 1:length(test_names)
0037         len(k) = length(test_names{k});
0038     end
0039     maxlen = max(len);
0040 end
0041 
0042 %% initialize statistics
0043 num_of_tests = 0;
0044 counter = 0;
0045 ok_cnt = 0;
0046 not_ok_cnt = 0;
0047 skip_cnt = 0;
0048 
0049 t0 = clock;
0050 for k = 1:length(test_names)
0051     if verbose
0052         fprintf('\n----------  %s  ----------\n', test_names{k});
0053     else
0054         pad = maxlen + 4 - length(test_names{k});
0055         fprintf('%s', test_names{k});
0056         for m = 1:pad, fprintf('.'); end
0057     end
0058     feval( test_names{k}, ~verbose );
0059     
0060     num_of_tests    = num_of_tests  + t_num_of_tests;
0061     counter         = counter       + t_counter;
0062     ok_cnt          = ok_cnt        + t_ok_cnt;
0063     not_ok_cnt      = not_ok_cnt    + t_not_ok_cnt;
0064     skip_cnt        = skip_cnt      + t_skip_cnt;
0065 end
0066 
0067 if verbose
0068     fprintf('\n\n----------  Summary  ----------\n');
0069 end
0070 if counter == num_of_tests && counter == ok_cnt + skip_cnt && not_ok_cnt == 0
0071     if skip_cnt
0072         fprintf('All tests successful (%d passed, %d skipped of %d)', ...
0073             ok_cnt, skip_cnt, num_of_tests);
0074     else
0075         fprintf('All tests successful (%d of %d)', ok_cnt, num_of_tests);
0076     end
0077 else
0078     fprintf('Ran %d of %d tests: %d passed, %d failed', ...
0079         counter, num_of_tests, ok_cnt, not_ok_cnt);
0080     if skip_cnt
0081         fprintf(', %d skipped', skip_cnt);
0082     end
0083 end
0084 fprintf('\nElapsed time %.2f seconds.\n', etime(clock, t0));

Generated on Fri 16-Dec-2016 12:45:37 by m2html © 2005