+++ /dev/null
-function unit_init(verbosity, global_vars)
- ## Initialize the global structure unittest_results, which is needed
- ## in all functions of the *unittest module. Debugging information
- ## is printed if verbosity==1. global_vars is a cell array of the
- ## names of the global variables used in the tests.
- ##
- ## e.g. unit_init(1, {"g", "a", "x"})
-
- global unittest_results;
-
- unittest_results.verbose = 0;
- unittest_results.eval_globals = {};
- if (nargin > 0)
- if (!isscalar(verbosity) || verbosity < 0 || verbosity > 1)
- warning("unit_init: verbose must be 0 or 1");
- else
- unittest_results.verbose = verbosity;
- endif
-
- if (nargin == 2 && iscell(global_vars))
- for i = 1:length(global_vars)
- unittest_results.eval_globals{i} = strcat("global ", global_vars{i}, ";");
- endfor
- else
- error("global_vars must be a cell array");
- endif
-
- if (nargin > 2)
- usage("expecting 2 arguments only");
- end
- endif
-
- unittest_results.total = 0; # number of testcases attempted
- unittest_results.pass = 0; # number of expected passed
- unittest_results.fail = 0; # number of unexpected failures
- unittest_results.upass = 0; # number of unexpected passes
- unittest_results.xfail = 0; # number of expected failures
- unittest_results.unresolved = 0; # number of unresolved testcases
-
- default_eval_print_flag = 0;
-endfunction