]> gitweb.michael.orlitzky.com - octave.git/blobdiff - tests/extended_rosenbrock1_tests.m
Add extended_rosenbrock1() and its tests.
[octave.git] / tests / extended_rosenbrock1_tests.m
diff --git a/tests/extended_rosenbrock1_tests.m b/tests/extended_rosenbrock1_tests.m
new file mode 100644 (file)
index 0000000..2f0eb8f
--- /dev/null
@@ -0,0 +1,14 @@
+## Test the optimal point.
+
+for m = [ 1 : 10 ]
+  x = repmat([1;1], m, 1);
+
+  msg = sprintf("extended_rosenbrock1([1;1;...]) == 0 (m = %d)", m);
+  unit_test_equals(msg, 0, extended_rosenbrock1(x));
+end
+
+## It should fail with the wrong number of coordinates.
+f = extended_rosenbrock1([1]);
+unit_test_equals("extended_rosenbrock1 fails when length(x) is odd", ...
+                true, ...
+                isna(f));