From 2cd077d099b5581fff3952ca578ab429d8c0ccef Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Tue, 7 Apr 2026 10:38:10 -0400 Subject: [PATCH] unit_test/*.m: delete trailing whitespace --- unit_test/erreval.m | 6 +++--- unit_test/unit_init.m | 12 ++++++------ unit_test/unit_results.m | 6 +++--- unit_test/unit_test.m | 12 ++++++------ 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/unit_test/erreval.m b/unit_test/erreval.m index 995d854..ab7acbc 100644 --- a/unit_test/erreval.m +++ b/unit_test/erreval.m @@ -2,16 +2,16 @@ function rv = erreval(error_prefix, try_str, catch_str) ## erreval() extends the built-in function eval(). Return 0 if ## try_str does not raise the error of type error_prefix, return 1 ## otherwise. - + global unittest_results; for k = 1:length(unittest_results.eval_globals) eval(unittest_results.eval_globals{k}); end - + rv = 0; try eval(try_str); catch rv = errcheck(error_prefix); - end + end endfunction diff --git a/unit_test/unit_init.m b/unit_test/unit_init.m index b692a80..f7fa7ef 100644 --- a/unit_test/unit_init.m +++ b/unit_test/unit_init.m @@ -5,9 +5,9 @@ function unit_init(verbosity, global_vars) ## 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) @@ -16,7 +16,7 @@ function unit_init(verbosity, global_vars) 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}, ";"); @@ -24,18 +24,18 @@ function unit_init(verbosity, global_vars) 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 diff --git a/unit_test/unit_results.m b/unit_test/unit_results.m index f6485ba..d2683c3 100644 --- a/unit_test/unit_results.m +++ b/unit_test/unit_results.m @@ -1,8 +1,8 @@ function unit_results() ## Print the results from previous unittest calls in pretty format. - + global unittest_results; - + printf("\n"); printf("# of testcases attempted %d\n", unittest_results.total); printf("# of expected passes %d\n", unittest_results.pass); @@ -11,7 +11,7 @@ function unit_results() printf("# of unexpected failures %d\n", unittest_results.fail); printf("# of unresolved testcases %d\n", unittest_results.unresolved); printf("\n"); - + if (unittest_results.total == unittest_results.pass + unittest_results.xfail) printf("Unit testing completed successfully!\n"); else diff --git a/unit_test/unit_test.m b/unit_test/unit_test.m index e21739d..3f8331e 100644 --- a/unit_test/unit_test.m +++ b/unit_test/unit_test.m @@ -14,22 +14,22 @@ function result = unit_test(test_title, expect_pass, actual_result) ## A call to unit_test typically looks like this: ## ## unit_test("scalar integer addition", 1, eval("1 + 1 == 2;")); - + global unittest_results; - + ## Sanity check input parameters if ( nargin < 3 || nargin > 4 ) error("Function run_rest expects 3 or 4 parameters."); endif - + if (!ischar(test_title)) error("Expecting TEST_TITLE (arg 1) to be a string."); endif - + if (expect_pass != 0 && expect_pass != 1) error("Expecting EXPECT_PASS (arg 2) to be 0 or 1."); endif - + unittest_results.total++; ## Take actions depending on what test result we expect @@ -42,7 +42,7 @@ function result = unit_test(test_title, expect_pass, actual_result) endif return; endif - + if (expect_pass == 1 && actual_result == 1) result = "PASS"; if (unittest_results.verbose != 0) -- 2.51.0