changeset 28802:191538bdae3f

Add BIST test for bug #59198. * jsonencode_BIST.tst: Add BIST test for encoding N-D logical arrays.
author Rik <rik@octave.org>
date Mon, 28 Sep 2020 08:43:52 -0700
parents ffa6c50c2eaa
children aab67699cbf6
files test/json/jsonencode_BIST.tst
diffstat 1 files changed, 11 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/test/json/jsonencode_BIST.tst	Sat Sep 26 14:19:23 2020 +0200
+++ b/test/json/jsonencode_BIST.tst	Mon Sep 28 08:43:52 2020 -0700
@@ -13,6 +13,7 @@
 
 %!testif HAVE_RAPIDJSON
 %! assert (isequal (jsonencode (logical (1)), 'true'));
+%! assert (isequal (jsonencode (logical (0)), 'false'));
 %! assert (isequal (jsonencode (50.025), '50.025'));
 %! assert (isequal (jsonencode (NaN), 'null'));
 %! assert (isequal (jsonencode (NA), 'null'));    % Octave-only test
@@ -247,12 +248,22 @@
 %! assert (isequal (obs, exp));
 
 %% Try logical array (tests above were all with numeric data)
+
+%% 2-D logical array
 %!testif HAVE_RAPIDJSON
 %! data = [true, false; true, false; true, false];
 %! exp  = '[[true,false],[true,false],[true,false]]';
 %! obs  = jsonencode (data);
 %! assert (isequal (obs, exp));
 
+%% N-D logical array
+%!testif HAVE_RAPIDJSON <59198>
+%! data = true (2,2,2);
+%! data(1,1,2) = false;
+%! exp  = '[[[true,false],[true,true]],[[true,true],[true,true]]]';
+%! obs  = jsonencode (data);
+%! assert (isequal (obs, exp));
+
 %%% Test 4: encode containers.Map
 
 %% KeyType must be char to encode objects of containers.Map