Check for existence of the include path before including it in divided_difference.m.
authorMichael Orlitzky <michael@orlitzky.com>
Sun, 16 Sep 2012 05:28:45 +0000 (01:28 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Sun, 16 Sep 2012 05:28:45 +0000 (01:28 -0400)
Rename the unit test script.
Check for satisfaction of all elements in unit_test_equals.m.

divided_difference.m
run-tests.m [moved from unit-tests with 68% similarity]
unit_test_equals.m

index 785b66f27e812ff0d908bdbf317b05077e15d694..cd4b0181b10ed4eb7c460798a9a55c711ee813ab 100644 (file)
@@ -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)
similarity index 68%
rename from unit-tests
rename to run-tests.m
index c0737bab8da70d0754fe84af9c06b74eac55336e..ef72b10731fecb8f6f324d4b25150153140af948 100755 (executable)
@@ -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]));
index e8b00d6fe3d2923108f485c871d0828ad4befd76..3b1e182bd75dd8b791084f0882b4e87900e8390c 100644 (file)
@@ -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