0001 function all_ok_ = 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
0026 if nargin < 2
0027 verbose = 0;
0028 end
0029
0030 global t_num_of_tests;
0031 global t_counter;
0032 global t_ok_cnt;
0033 global t_not_ok_cnt;
0034 global t_skip_cnt;
0035
0036
0037 if ~verbose
0038 len = zeros(length(test_names), 1);
0039 for k = 1:length(test_names)
0040 len(k) = length(test_names{k});
0041 end
0042 maxlen = max(len);
0043 end
0044
0045
0046 num_of_tests = 0;
0047 counter = 0;
0048 ok_cnt = 0;
0049 not_ok_cnt = 0;
0050 skip_cnt = 0;
0051
0052 t0 = tic;
0053 for k = 1:length(test_names)
0054 if verbose
0055 fprintf('\n---------- %s ----------\n', test_names{k});
0056 else
0057 pad = maxlen + 4 - length(test_names{k});
0058 fprintf('%s', test_names{k});
0059 for m = 1:pad, fprintf('.'); end
0060 end
0061 feval( test_names{k}, ~verbose );
0062
0063 num_of_tests = num_of_tests + t_num_of_tests;
0064 counter = counter + t_counter;
0065 ok_cnt = ok_cnt + t_ok_cnt;
0066 not_ok_cnt = not_ok_cnt + t_not_ok_cnt;
0067 skip_cnt = skip_cnt + t_skip_cnt;
0068 end
0069
0070 if verbose
0071 fprintf('\n\n---------- Summary ----------\n');
0072 end
0073 if counter == num_of_tests && counter == ok_cnt + skip_cnt && not_ok_cnt == 0
0074 all_ok = 1;
0075 if skip_cnt
0076 fprintf('All tests successful (%d passed, %d skipped of %d)', ...
0077 ok_cnt, skip_cnt, num_of_tests);
0078 else
0079 fprintf('All tests successful (%d of %d)', ok_cnt, num_of_tests);
0080 end
0081 else
0082 all_ok = 0;
0083 fprintf('Ran %d of %d tests: %d passed, %d failed', ...
0084 counter, num_of_tests, ok_cnt, not_ok_cnt);
0085 if skip_cnt
0086 fprintf(', %d skipped', skip_cnt);
0087 end
0088 end
0089 fprintf('\nElapsed time %.2f seconds.\n', toc(t0));
0090
0091 if nargout
0092 all_ok_ = all_ok;
0093 end