X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=unit_test.m;fp=unit_test.m;h=0000000000000000000000000000000000000000;hb=ef3085ef3c40eab925219bad1c6dbb2c6e106727;hp=e21739dfee0a659ec8daa2c7af9b6e627603cbc7;hpb=33e4dd7a64f35fb22774d59af11f5670ab566fbc;p=octave.git diff --git a/unit_test.m b/unit_test.m deleted file mode 100644 index e21739d..0000000 --- a/unit_test.m +++ /dev/null @@ -1,67 +0,0 @@ -function result = unit_test(test_title, expect_pass, actual_result) - ## Function unittest compares the ACTUAL_RESULT of running - ## a test (either 0 for failure, or 1 for success) with the - ## expected outcome of the test EXPECT_PASS (either 0 for expecting - ## a failure, or 1 for expecting pass). TEST_TITLE is the name of - ## the test. All test results will be accompanied by the test's - ## title. - ## - ## The result of unit_test is on of the following: UNRESOLVED: The - ## test did neither return 0 nor 1. PASS: expected pass, got pass. - ## FAIL: expected pass, got fail. UPASS: expected fail, got pass. - ## XFAIL: expected fail, got fail. - ## - ## 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 - ## (expect_pass), and what we actually got (actual_result). - if (actual_result != 0 && actual_result != 1) - result = "UNRESOLVED"; - unittest_results.unresolved++; - if (actual_result == 2) - printf("SYNTAX ERROR: %s\n", test_title); - endif - return; - endif - - if (expect_pass == 1 && actual_result == 1) - result = "PASS"; - if (unittest_results.verbose != 0) - printf("PASS: %s\n", test_title); - else - printf('.'); - endif - unittest_results.pass++; - elseif (expect_pass == 1 && actual_result == 0) - result = "FAIL"; - printf("FAIL: %s\n\n", test_title); - unittest_results.fail++; - elseif (expect_pass == 0 && actual_result == 0) - result = "XFAIL"; - printf("XFAIL: %s\n", test_title); - unittest_results.xfail++; - elseif (expect_pass == 0 && actual_result == 1) - result = "UPASS"; - printf("UPASS: %s\n", test_title); - unittest_results.upass++; - endif -endfunction