Mercurial > octave
comparison libinterp/corefcn/rand.cc @ 32060:1203a2d81a42
Add BIST tests for Matlab compatibility for functions which accept negative dimensions.
* data.cc (Fones, Finf, Feps, Feye): Add BIST test for negative dimensions.
* rand.cc (Frand): Add BIST test for negative dimensions.
* ov-cell.cc (Fcell): Add BIST test for negative dimensions.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 26 Apr 2023 16:26:32 -0700 |
parents | 597f3ee61a48 |
children | 2e484f9f1f18 |
comparison
equal
deleted
inserted
replaced
32059:bade9602c5a1 | 32060:1203a2d81a42 |
---|---|
536 %!assert (__rand_sample__ (Inf), __rand_sample__ (0)) | 536 %!assert (__rand_sample__ (Inf), __rand_sample__ (0)) |
537 %!assert (__rand_sample__ (NaN), __rand_sample__ (0)) | 537 %!assert (__rand_sample__ (NaN), __rand_sample__ (0)) |
538 */ | 538 */ |
539 | 539 |
540 /* | 540 /* |
541 ## Check that negative dimensions are treated as zero for Matlab compatibility | 541 ## Note: Matlab compatibility requires using 0 for negative dimensions. |
542 %!assert (size (rand (1, -1, 2)), [1, 0, 2]) | 542 %!assert (size (rand (1, -1, 2)), [1, 0, 2]) |
543 | 543 |
544 ## Test input validation | 544 ## Test input validation |
545 %!error <conversion of 1.1 to.* failed> rand (1, 1.1) | 545 %!error <conversion of 1.1 to.* failed> rand (1, 1.1) |
546 %!error <dimensions must be .* array of integers> rand ([1, 1.1]) | 546 %!error <dimensions must be .* array of integers> rand ([1, 1.1]) |