# HG changeset patch # User Rik # Date 1388688909 28800 # Node ID 31d8e19a745dbdc9895f892261fd72e5a7a580ff # Parent f24d5bd050d9bbf774b8fbc2ee9722b59d2f5fc5 voronoi.m: Add input validation test for 2 points (bug #40996) * voronoi.m: Add input validation test for 2 points (bug #40996). Add %!tests for input validation. Correct misnamed variable harg to hax. diff -r f24d5bd050d9 -r 31d8e19a745d scripts/geometry/voronoi.m --- a/scripts/geometry/voronoi.m Wed Jan 01 18:10:50 2014 -0800 +++ b/scripts/geometry/voronoi.m Thu Jan 02 10:55:09 2014 -0800 @@ -76,8 +76,8 @@ narg = 1; if (isscalar (varargin{1}) && ishandle (varargin{1})) hax = varargin{1}; - if (! isaxes (harg)) - error ("imagesc: HAX argument must be an axes object"); + if (! isaxes (hax)) + error ("voronoi: HAX argument must be an axes object"); endif narg++; elseif (nargout < 2) @@ -108,6 +108,10 @@ if (length (x) != length (y)) error ("voronoi: X and Y must be vectors of the same length"); + elseif (length (x) < 3) + ## See bug #40996. + ## For 2 points it would be nicer to just calculate the bisection line. + error ("voronoi: minimum of 3 points needed"); endif ## Add box to approximate rays to infinity. For Voronoi diagrams the @@ -179,5 +183,12 @@ %! assert (vx(2,:), zeros (1, columns (vx)), eps); %! assert (vy(2,:), zeros (1, columns (vy)), eps); -%% FIXME: Need input validation tests +%% Input validation tests +%!error voronoi () +%!error voronoi (ones (3,1)) +%!error voronoi (ones (3,1), ones (3,1), "bogus1", "bogus2", "bogus3") +%!error voronoi (0, ones (3,1), ones (3,1)) +%!error voronoi (ones (3,1), ones (4,1)) +%!error voronoi (2.5, 3.5) +%!error voronoi ([2.5, 3.5], [2.5, 3.5])