changeset 19205:702aa79dc482

Add BIST tests for various quasi-internal m-files. * __actual_axis_position__.m, __default_plot_options__.m, __next_line_color__.m, __next_line_style__.m, __pltopt__.m, __have_feature__.m, __printf_assert__.m, __prog_output_assert__.m, __run_test_suite__.m: Add BIST tests for various quasi-internal m-files.
author Rik <rik@octave.org>
date Sat, 27 Sep 2014 20:21:46 -0700
parents a6d44158bc6d
children 4318cb91deac
files scripts/plot/util/__actual_axis_position__.m scripts/plot/util/__default_plot_options__.m scripts/plot/util/__next_line_color__.m scripts/plot/util/__next_line_style__.m scripts/plot/util/__pltopt__.m scripts/testfun/__have_feature__.m scripts/testfun/__printf_assert__.m scripts/testfun/__prog_output_assert__.m scripts/testfun/__run_test_suite__.m
diffstat 9 files changed, 104 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/plot/util/__actual_axis_position__.m	Sat Sep 27 18:19:47 2014 -0700
+++ b/scripts/plot/util/__actual_axis_position__.m	Sat Sep 27 20:21:46 2014 -0700
@@ -84,3 +84,6 @@
   endif
 endfunction
 
+
+## No test coverage for internal function.  It is tested through calling fcn.
+%!assert (1)
--- a/scripts/plot/util/__default_plot_options__.m	Sat Sep 27 18:19:47 2014 -0700
+++ b/scripts/plot/util/__default_plot_options__.m	Sat Sep 27 20:21:46 2014 -0700
@@ -33,3 +33,13 @@
 
 endfunction
 
+
+%!test
+%! options = __default_plot_options__ ();
+%! assert (isfield (options, "key"));
+%! assert (options.key, "");
+%! assert (options.color, []);
+%! assert (options.linestyle, []);
+%! assert (options.marker, []);
+%! assert (options.errorstyle, []);
+
--- a/scripts/plot/util/__next_line_color__.m	Sat Sep 27 18:19:47 2014 -0700
+++ b/scripts/plot/util/__next_line_color__.m	Sat Sep 27 20:21:46 2014 -0700
@@ -52,3 +52,22 @@
 
 endfunction
 
+
+%!test
+%! hf = figure ("visible", "off");
+%! unwind_protect
+%!   hax = axes ();
+%!   set (hax, "colororder", [1 0 0; 0 1 0; 0 0 1]);
+%!   hold on;
+%!   h = plot (1:5,1:5,'o', 1:4,1:4, "x", 1:3,1:3, "d");
+%!   assert (get (h, "color"), {[1 0 0]; [0 1 0]; [0 0 1]});
+%!   cla (hax);
+%!   hold all;
+%!   h1 = plot (1:5,1:5,'o');
+%!   h2 = plot (1:4,1:4, "x");
+%!   h3 = plot (1:3,1:3, "d");
+%!   assert (get ([h1;h2;h3], "color"), {[1 0 0]; [0 1 0]; [0 0 1]});
+%! unwind_protect_cleanup
+%!   close (hf);
+%! end_unwind_protect
+
--- a/scripts/plot/util/__next_line_style__.m	Sat Sep 27 18:19:47 2014 -0700
+++ b/scripts/plot/util/__next_line_style__.m	Sat Sep 27 20:21:46 2014 -0700
@@ -56,3 +56,23 @@
 
 endfunction
 
+
+%!test
+%! hf = figure ("visible", "off");
+%! unwind_protect
+%!   hax = axes ();
+%!   set (hax, "colororder", [0 0 1]);
+%!   set (hax, "linestyleorder", {"-", ":", "--"});
+%!   hold on;
+%!   h = plot (1:5,1:5, 1:4,1:4, 1:3,1:3);
+%!   assert (get (h, "linestyle"), {"-"; ":"; "--"});
+%!   cla (hax);
+%!   hold all;
+%!   h1 = plot (1:5,1:5);
+%!   h2 = plot (1:4,1:4);
+%!   h3 = plot (1:3,1:3);
+%!   assert (get ([h1;h2;h3], "linestyle"), {"-"; ":"; "--"});
+%! unwind_protect_cleanup
+%!   close (hf);
+%! end_unwind_protect
+
--- a/scripts/plot/util/__pltopt__.m	Sat Sep 27 18:19:47 2014 -0700
+++ b/scripts/plot/util/__pltopt__.m	Sat Sep 27 20:21:46 2014 -0700
@@ -233,3 +233,39 @@
 
 endfunction
 
+
+## Only cursory testing.  Real testing done by appearance of plots.
+%test
+%! opts = __pltopt__ ("abc", "");
+%! assert (opts.color, []);
+%! assert (opts.linestyle, []);
+%! assert (opts.marker, []);
+%! assert (opts.key, "");
+%!test
+%! opts = __pltopt__ ("abc", "r:x");
+%! assert (opts.color, [1 0 0]);
+%! assert (opts.linestyle, ":");
+%! assert (opts.marker, "x");
+%!test
+%! opts = __pltopt__ ("abc", "2square");
+%! assert (opts.color, [0 1 0]);
+%! assert (opts.linestyle, "none");
+%! assert (opts.marker, "s");
+%!test
+%! opts = __pltopt__ ("abc", ";Title;");
+%! assert (opts.key, "Title");
+%! assert (opts.color, []);
+%! assert (opts.linestyle, []);
+%! assert (opts.marker, []);
+%!test
+%! opts = __pltopt__ ("__errplot__", "~>r");
+%! assert (opts.errorstyle, "~>");
+%! assert (opts.color, [1 0 0 ]);
+%! assert (opts.linestyle, []);
+%! assert (opts.marker, []);
+
+## Test input validation
+%!error <argument must be a character string or cell array> __pltopt__ ("abc", 1)
+%!error <unfinished key label> __pltopt__ ("abc", "rx;my_title", true)
+%!error <unrecognized format character: 'u'> __pltopt__ ("abc", "u", true)
+
--- a/scripts/testfun/__have_feature__.m	Sat Sep 27 18:19:47 2014 -0700
+++ b/scripts/testfun/__have_feature__.m	Sat Sep 27 20:21:46 2014 -0700
@@ -33,3 +33,7 @@
   endif
 endfunction
 
+
+## No test coverage for internal function.  It is tested through calling fcn.
+%!assert (1)
+
--- a/scripts/testfun/__printf_assert__.m	Sat Sep 27 18:19:47 2014 -0700
+++ b/scripts/testfun/__printf_assert__.m	Sat Sep 27 20:21:46 2014 -0700
@@ -26,3 +26,7 @@
   _assert_printf = cat (2, _assert_printf, sprintf (varargin{:}));
 endfunction
 
+
+## No test coverage for internal function.  It is tested through calling fcn.
+%!assert (1)
+
--- a/scripts/testfun/__prog_output_assert__.m	Sat Sep 27 18:19:47 2014 -0700
+++ b/scripts/testfun/__prog_output_assert__.m	Sat Sep 27 20:21:46 2014 -0700
@@ -33,3 +33,7 @@
   _assert_printf = "";
 endfunction
 
+
+## No test coverage for internal function.  It is tested through calling fcn.
+%!assert (1)
+
--- a/scripts/testfun/__run_test_suite__.m	Sat Sep 27 18:19:47 2014 -0700
+++ b/scripts/testfun/__run_test_suite__.m	Sat Sep 27 20:21:46 2014 -0700
@@ -275,3 +275,7 @@
   printf ("\n%d (of %d) %s files have no tests.\n", n_without, n_tot, typ);
 endfunction
 
+
+## No test coverage for internal function.  It is tested through calling fcn.
+%!assert (1)
+