comparison test/mk-sparse-tst.sh @ 32059:bade9602c5a1

Validate M and N dimension inputs to sparse(). * sparse.cc (Fsparse): Use xidx_type_value() to extract an octave_idx_type for M and N inputs or throw an error. Remove call to get_dimensions(). Remove FIXME note about unreachable code. Update error messages to be specific about what is wrong with M or N inputs. * mk-sparse-tst.sh: Remove FIXME notes. Update BIST tests for M and N inputs.
author Rik <rik@octave.org>
date Wed, 26 Apr 2023 14:40:37 -0700
parents e242124f1240
children 3b9305e62bb7
comparison
equal deleted inserted replaced
32058:e242124f1240 32059:bade9602c5a1
180 %!warning <input array cast to double> 180 %!warning <input array cast to double>
181 %! warning ("on", "Octave:sparse:double-conversion", "local"); 181 %! warning ("on", "Octave:sparse:double-conversion", "local");
182 %! s = sparse (single ([1 2])); 182 %! s = sparse (single ([1 2]));
183 %!error <wrong type argument 'uint8 matrix'> 183 %!error <wrong type argument 'uint8 matrix'>
184 %! s = sparse (uint8 ([1 2])); 184 %! s = sparse (uint8 ([1 2]));
185 %% FIXME: negative dimensions are allowed and replaced with 0. 185 %!error <M must be a non-negative integer> sparse ({1}, 2)
186 %% If this is fixed, re-instate these tests. 186 %!error <N must be a non-negative integer> sparse (1, {2})
187 %!#error <dimensions must be non-negative> sparse (-1, 2) 187 %!error <dimensions M and N must be non-negative> sparse (-1, 2)
188 %!#error <dimensions must be non-negative> sparse (1, -2) 188 %!error <dimensions M and N must be non-negative> sparse (1, -2)
189 %!error <dimension mismatch> sparse (1,[2,3],[1,2,3]) 189 %!error <dimension mismatch> sparse (1,[2,3],[1,2,3])
190 %!error <invalid option: foobar> sparse ([1,1],[1,1],[1,2],"foobar") 190 %!error <invalid option: foobar> sparse ([1,1],[1,1],[1,2],"foobar")
191 %% negative subscripts are disallowed 191 %% negative subscripts are disallowed
192 %!error <subscripts must be> sparse ([1,3],[1,-4],[3,5],2,2) 192 %!error <subscripts must be> sparse ([1,3],[1,-4],[3,5],2,2)
193 %!error <subscripts must be> sparse ([1,3],[1,-4],[3,5i],2,2) 193 %!error <subscripts must be> sparse ([1,3],[1,-4],[3,5i],2,2)
194 %% FIXME: negative dimensions are allowed and replaced with 0. 194 %!error <M must be a non-negative integer> sparse ([1,1],[1,1],[1,2], {1}, 2)
195 %% If this is fixed, re-instate these tests. 195 %!error <N must be a non-negative integer> sparse ([1,1],[1,1],[1,2], 1, {2})
196 %!#error <dimensions must be non-negative> sparse ([1,1],[1,1],[1,2], -1, 2) 196 %!error <dimensions M and N must be non-negative> sparse ([1,1],[1,1],[1,2], -1, 2)
197 %!#error <dimensions must be non-negative> sparse ([1,1],[1,1],[1,2], 1, -2) 197 %!error <dimensions M and N must be non-negative> sparse ([1,1],[1,1],[1,2], 1, -2)
198 %!warning <input array cast to double> 198 %!warning <input array cast to double>
199 %! warning ("on", "Octave:sparse:double-conversion", "local"); 199 %! warning ("on", "Octave:sparse:double-conversion", "local");
200 %! s = sparse ([1,1],[1,1], single ([1,2]), 2, 2); 200 %! s = sparse ([1,1],[1,1], single ([1,2]), 2, 2);
201 %!error <wrong type argument 'uint8 matrix'> 201 %!error <wrong type argument 'uint8 matrix'>
202 %! s = sparse ([1,1],[1,1], uint8 ([1,2]), 2, 2); 202 %! s = sparse ([1,1],[1,1], uint8 ([1,2]), 2, 2);