1 function unit_init(verbosity, global_vars)
2 ## Initialize the global structure unittest_results, which is needed
3 ## in all functions of the *unittest module. Debugging information
4 ## is printed if verbosity==1. global_vars is a cell array of the
5 ## names of the global variables used in the tests.
7 ## e.g. unit_init(1, {"g", "a", "x"})
9 global unittest_results;
11 unittest_results.verbose = 0;
12 unittest_results.eval_globals = {};
14 if (!isscalar(verbosity) || verbosity < 0 || verbosity > 1)
15 warning("unit_init: verbose must be 0 or 1");
17 unittest_results.verbose = verbosity;
20 if (nargin == 2 && iscell(global_vars))
21 for i = 1:length(global_vars)
22 unittest_results.eval_globals{i} = strcat("global ", global_vars{i}, ";");
25 error("global_vars must be a cell array");
29 usage("expecting 2 arguments only");
33 unittest_results.total = 0; # number of testcases attempted
34 unittest_results.pass = 0; # number of expected passed
35 unittest_results.fail = 0; # number of unexpected failures
36 unittest_results.upass = 0; # number of unexpected passes
37 unittest_results.xfail = 0; # number of expected failures
38 unittest_results.unresolved = 0; # number of unresolved testcases
40 default_eval_print_flag = 0;