comparison scripts/plot/draw/pie3.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
59 59
60 if (nargin < 1) 60 if (nargin < 1)
61 print_usage (); 61 print_usage ();
62 endif 62 endif
63 63
64 if (! all (isfinite (varargin{1})))
65 error ("pie3: all data in X must be finite");
66 endif
67
64 oldfig = []; 68 oldfig = [];
65 if (! isempty (hax)) 69 if (! isempty (hax))
66 oldfig = get (0, "currentfigure"); 70 oldfig = get (0, "currentfigure");
67 endif 71 endif
68 unwind_protect 72 unwind_protect
98 %! clf; 102 %! clf;
99 %! pie3 ([0.17, 0.34, 0.41], {"Cheddar", "Swiss", "Camembert"}); 103 %! pie3 ([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 ("pie3() with missing slice"); 106 %! title ("pie3() with missing slice");
107
108 ## Test input validation
109 %!error pie3 ()
110 %!error <all data in X must be finite> pie3 ([1 2 Inf])
111 %!error <all data in X must be finite> pie3 ([1 2 NaN])