From: Michael Orlitzky Date: Sun, 16 Sep 2012 05:28:45 +0000 (-0400) Subject: Check for existence of the include path before including it in divided_difference.m. X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=62d652799ded51169bda744d8728e1d33582fa5f;p=octave.git Check for existence of the include path before including it in divided_difference.m. Rename the unit test script. Check for satisfaction of all elements in unit_test_equals.m. --- diff --git a/divided_difference.m b/divided_difference.m index 785b66f..cd4b018 100644 --- a/divided_difference.m +++ b/divided_difference.m @@ -16,7 +16,10 @@ function dd = divided_difference(f, xs) ## ## * ``dd`` - The divided difference f[xs(1), xs(2),...] ## - addpath('../homework1/src'); + if (exist('../homework1/src', 'dir')) + addpath('../homework1/src'); + end + order = length(xs) - 1; if (order < 0) diff --git a/unit-tests b/run-tests.m similarity index 68% rename from unit-tests rename to run-tests.m index c0737ba..ef72b10 100755 --- a/unit-tests +++ b/run-tests.m @@ -9,3 +9,7 @@ unit_test_equals("sin[0] == 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])); diff --git a/unit_test_equals.m b/unit_test_equals.m index e8b00d6..3b1e182 100644 --- a/unit_test_equals.m +++ b/unit_test_equals.m @@ -1,5 +1,5 @@ function unit_test_equals(test_title, result_A, result_B) tol = 0.0001; err = abs(result_A - result_B); - unit_test(test_title, 1, all(err < tol)); + unit_test(test_title, 1, all(all(err < tol))); endfunction