T_BEGIN Begin running tests. T_BEGIN(NUM_OF_TESTS, QUIET) initializes the global test counters, setting everything up to execute NUM_OF_TESTS tests using T_OK and T_IS. If QUIET is true, it will not print anything for the individual tests, only a summary when T_END is called. Example: quiet = 0; t_begin(5, quiet); t_ok(pi > 3, 'size of pi'); t_skip(3, 'not yet written'); t_is(2+2, 4, 12, '2+2 still equals 4'); t_end; See also T_END, T_OK, T_IS, T_SKIP, T_RUN_TESTS.
0001 function t_begin(num_of_tests, quiet) 0002 %T_BEGIN Begin running tests. 0003 % T_BEGIN(NUM_OF_TESTS, QUIET) initializes the global test counters, 0004 % setting everything up to execute NUM_OF_TESTS tests using T_OK 0005 % and T_IS. If QUIET is true, it will not print anything for the 0006 % individual tests, only a summary when T_END is called. 0007 % 0008 % Example: 0009 % quiet = 0; 0010 % t_begin(5, quiet); 0011 % t_ok(pi > 3, 'size of pi'); 0012 % t_skip(3, 'not yet written'); 0013 % t_is(2+2, 4, 12, '2+2 still equals 4'); 0014 % t_end; 0015 % 0016 % See also T_END, T_OK, T_IS, T_SKIP, T_RUN_TESTS. 0017 0018 % MATPOWER 0019 % $Id: t_begin.m,v 1.7 2010/04/26 19:45:26 ray Exp $ 0020 % by Ray Zimmerman, PSERC Cornell 0021 % Copyright (c) 2004-2010 by Power System Engineering Research Center (PSERC) 0022 % 0023 % This file is part of MATPOWER. 0024 % See http://www.pserc.cornell.edu/matpower/ for more info. 0025 % 0026 % MATPOWER is free software: you can redistribute it and/or modify 0027 % it under the terms of the GNU General Public License as published 0028 % by the Free Software Foundation, either version 3 of the License, 0029 % or (at your option) any later version. 0030 % 0031 % MATPOWER is distributed in the hope that it will be useful, 0032 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0033 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0034 % GNU General Public License for more details. 0035 % 0036 % You should have received a copy of the GNU General Public License 0037 % along with MATPOWER. If not, see <http://www.gnu.org/licenses/>. 0038 % 0039 % Additional permission under GNU GPL version 3 section 7 0040 % 0041 % If you modify MATPOWER, or any covered work, to interface with 0042 % other modules (such as MATLAB code and MEX-files) available in a 0043 % MATLAB(R) or comparable environment containing parts covered 0044 % under other licensing terms, the licensors of MATPOWER grant 0045 % you additional permission to convey the resulting work. 0046 0047 global t_quiet; 0048 global t_num_of_tests; 0049 global t_counter; 0050 global t_ok_cnt; 0051 global t_not_ok_cnt; 0052 global t_skip_cnt; 0053 global t_clock; 0054 0055 if nargin < 2 0056 quiet = 0; 0057 end 0058 0059 t_quiet = quiet; 0060 t_num_of_tests = num_of_tests; 0061 t_counter = 1; 0062 t_ok_cnt = 0; 0063 t_not_ok_cnt = 0; 0064 t_skip_cnt = 0; 0065 t_clock = clock; 0066 0067 if ~t_quiet 0068 fprintf('1..%d\n', num_of_tests); 0069 end