0001 function t_run_tests(test_names, verbose)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
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
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
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));