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

Generated on Fri 20-Mar-2015 18:23:34 by m2html © 2005