📄 t_run_tests.m
字号:
function t_run_tests(test_names, verbose)%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.% MATPOWER% $Id: t_run_tests.m,v 1.3 2004/08/25 15:09:46 ray Exp $% by Ray Zimmerman, PSERC Cornell% Copyright (c) 2004 by Power System Engineering Research Center (PSERC)% See http://www.pserc.cornell.edu/matpower/ for more info.if nargin < 2 verbose = 0;endglobal t_num_of_tests;global t_counter;global t_ok_cnt;global t_not_ok_cnt;global t_skip_cnt;%% figure out padding for printingif ~verbose maxlen = 0; len = zeros(length(test_names), 1); for k = 1:length(test_names) len(k) = length(test_names{k}); end maxlen = max(len);end%% initialize statisticsnum_of_tests = 0;counter = 0;ok_cnt = 0;not_ok_cnt = 0;skip_cnt = 0;t0 = clock;for k = 1:length(test_names) if verbose fprintf('\n---------- %s ----------\n', test_names{k}); else pad = maxlen + 4 - length(test_names{k}); fprintf('%s', test_names{k}); for m = 1:pad, fprintf('.'); end end feval( test_names{k}, ~verbose ); num_of_tests = num_of_tests + t_num_of_tests; counter = counter + t_counter; ok_cnt = ok_cnt + t_ok_cnt; not_ok_cnt = not_ok_cnt + t_not_ok_cnt; skip_cnt = skip_cnt + t_skip_cnt;endif verbose fprintf('\n\n---------- Summary ----------\n');endif counter == num_of_tests & counter == ok_cnt + skip_cnt & not_ok_cnt == 0 if skip_cnt fprintf('All tests successful (%d passed, %d skipped of %d)', ... ok_cnt, skip_cnt, num_of_tests); else fprintf('All tests successful (%d of %d)', ok_cnt, num_of_tests); endelse fprintf('Ran %d of %d tests: %d passed, %d failed', ... counter, num_of_tests, ok_cnt, not_ok_cnt); if skip_cnt fprintf(', %d skipped', skip_cnt); endendfprintf('\nElapsed time %.2f seconds.\n', etime(clock, t0));return;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -