]> gitweb.michael.orlitzky.com - octave.git/blobdiff - tests/rosenbrock1_tests.m
Add the Rosenbrock functions and their tests.
[octave.git] / tests / rosenbrock1_tests.m
diff --git a/tests/rosenbrock1_tests.m b/tests/rosenbrock1_tests.m
new file mode 100644 (file)
index 0000000..4931403
--- /dev/null
@@ -0,0 +1,16 @@
+## Test the optimal point.
+
+unit_test_equals("rosenbrock1([1;1]) == 0", ...
+                0, ...
+                rosenbrock1([1;1]));
+
+## It should fail with the wrong number of coordinates.
+f = rosenbrock1([1]);
+unit_test_equals("rosenbrock1 fails with too few coordinates", ...
+                true, ...
+                isna(f));
+
+f = rosenbrock1([1;2;3]);
+unit_test_equals("rosenbrock1 fails with too many coordinates", ...
+                true, ...
+                isna(f));