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 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
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
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));