comparison scripts/plot/draw/pie.m @ 25233:c64f7a95b464

pie.m, pie3.m: Validate that data input is finite (bug #53480). * pie.m, pie3.m: Use isfinite() to check input data X. Add BIST tests for input validation.
author Rik <rik@octave.org>
date Thu, 12 Apr 2018 13:30:50 -0700
parents 6652d3823428
children 996d78102a71
comparison
equal deleted inserted replaced
25232:8a92b651838b 25233:c64f7a95b464
58 58
59 if (nargin < 1) 59 if (nargin < 1)
60 print_usage (); 60 print_usage ();
61 endif 61 endif
62 62
63 if (! all (isfinite (varargin{1})))
64 error ("pie: all data in X must be finite");
65 endif
66
63 oldfig = []; 67 oldfig = [];
64 if (! isempty (hax)) 68 if (! isempty (hax))
65 oldfig = get (0, "currentfigure"); 69 oldfig = get (0, "currentfigure");
66 endif 70 endif
67 unwind_protect 71 unwind_protect
98 %! clf; 102 %! clf;
99 %! pie ([0.17, 0.34, 0.41], {"Cheddar", "Swiss", "Camembert"}); 103 %! pie ([0.17, 0.34, 0.41], {"Cheddar", "Swiss", "Camembert"});
100 %! colormap ([1,0,0;0,1,0;0,0,1;1,1,0;1,0,1;0,1,1]); 104 %! colormap ([1,0,0;0,1,0;0,0,1;1,1,0;1,0,1;0,1,1]);
101 %! axis ([-2,2,-2,2]); 105 %! axis ([-2,2,-2,2]);
102 %! title ("pie() with missing slice"); 106 %! title ("pie() with missing slice");
107
108 ## Test input validation
109 %!error pie ()
110 %!error <all data in X must be finite> pie ([1 2 Inf])
111 %!error <all data in X must be finite> pie ([1 2 NaN])