X-Git-Url: http://gitweb.michael.orlitzky.com/?p=octave.git;a=blobdiff_plain;f=run-tests.m;h=001e7409d00004d7cdc85a2e676cb29c9aa8e2f8;hp=1682d18d20acbdf7938ba5d81c68780bd2df3351;hb=f232366c34a718cde40d20c19759826280220e9e;hpb=9fb5a1527f1ea90f9074b6e318791e0cc43e18f7 diff --git a/run-tests.m b/run-tests.m index 1682d18..001e740 100755 --- a/run-tests.m +++ b/run-tests.m @@ -1,53 +1,32 @@ #!/usr/bin/octave --silent +# +# You'll need to use the .octaverc in this directory to get the proper +# paths. You can pass it an integer on the command-line to specify how +# many times we should run the test suite in succession. The default +# is 1. +# -unit_init(1, {}); - -unit_test_equals("sin[0] == 0", ... - 0, ... - divided_difference(@sin, 0)); - -unit_test_equals("sin[0, pi] == 0", ... - 0, ... - divided_difference(@sin, [0,pi])); - -unit_test_equals("sin[0, pi, 2*pi] == 0", ... - 0, ... - divided_difference(@sin, [0,pi,2*pi])); +addpath('./unit_test'); -unit_test_equals("zero order divided_difference_coefficients", ... - [1], ... - divided_difference_coefficients([0])); - -unit_test_equals("first order divided_difference_coefficients", ... - [-1, 1] / pi, ... - divided_difference_coefficients([0, pi])); - -unit_test_equals("second order divided_difference_coefficients", ... - [1, -2, 1] / (2*pi^2), ... - divided_difference_coefficients([0, pi, 2*pi])); +global unittest_results; +unit_init(1, {}); -unit_test_equals("1 is odd", ... - true, ... - odd(1)); +test_files = glob('tests/*.m'); -unit_test_equals("1 is not even", ... - false, ... - even(1)); +loop_count = 1; +arg_list = argv(); +if (length(arg_list) > 0) + loop_count = arg_list{1}; +end -unit_test_equals("2 is not odd", ... - false, ... - odd(2)); +## Source every file that matches the glob above. +for idx = [ 1 : loop_count ] + cellfun(@source, test_files); +end -unit_test_equals("2 is even", ... - true, ... - even(2)); -expected_A = [1, 0, 0, 0, 0; ... - 16, -32, 16, 0, 0; ... - 0, 16, -32, 16, 0; ... - 0, 0, 16, -32, 16; ... - 0, 0, 0, 0, 1]; -unit_test_equals("Homework #1 problem #1 Poisson matrix is correct", ... - true, ... - expected_A == poisson_matrix(4, 0, 1)); +fprintf('\n'); +fprintf('Total tests attempted: %d\n', unittest_results.total); +fprintf('Total tests passed: %d\n', unittest_results.pass); +fprintf('Total tests failed: %d\n', unittest_results.fail);