]> gitweb.michael.orlitzky.com - octave.git/blob - unit_init.m
b692a80b8827096576728ee3de0be5773ab7c9a3
[octave.git] / unit_init.m
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.
6 ##
7 ## e.g. unit_init(1, {"g", "a", "x"})
8
9 global unittest_results;
10
11 unittest_results.verbose = 0;
12 unittest_results.eval_globals = {};
13 if (nargin > 0)
14 if (!isscalar(verbosity) || verbosity < 0 || verbosity > 1)
15 warning("unit_init: verbose must be 0 or 1");
16 else
17 unittest_results.verbose = verbosity;
18 endif
19
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}, ";");
23 endfor
24 else
25 error("global_vars must be a cell array");
26 endif
27
28 if (nargin > 2)
29 usage("expecting 2 arguments only");
30 end
31 endif
32
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
39
40 default_eval_print_flag = 0;
41 endfunction