changeset 32169:47cf72897a06

test: Add tests for deletion of non-existent dimensions. * index.tst: Add tests for deletion of non-existent dimensions.
author Rik <rik@octave.org>
date Mon, 26 Jun 2023 08:35:07 -0700
parents 69723478e84d
children cb56ab555113
files test/index.tst
diffstat 1 files changed, 22 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/test/index.tst	Sun Jun 25 17:14:52 2023 -0700
+++ b/test/index.tst	Mon Jun 26 08:35:07 2023 -0700
@@ -503,6 +503,28 @@
 %! x([], false, :) = [];
 %! assert (x, y);
 
+## Test deletion of non-existent dimensions
+%!test
+%! x = ones (10, 10, 2);
+%! x(:, :, 1) = [];
+%! x(:, :, 1) = [];
+%! assert (size (x), [10, 10, 0]);
+
+%!test
+%! x = ones (10, 10);
+%! x(:,:,:, 1) = [];
+%! assert (size (x), [10, 10, 1, 0]);
+
+%!test
+%! x = ones (10, 10);
+%! try
+%!   x(:,:,2) = [];
+%! catch
+%!   m = strfind (lasterr (), 'index out of bounds: value 2 out of bound 1');
+%!   assert (m > 0);
+%! end_try_catch
+%! assert (size (x), [10, 10]);
+
 ##  Test indexing of unnamed constants
 %!error <index \(0\): subscripts must be>     1(0)
 %!error <index \(-1\): subscripts must be>    1(-1)