# HG changeset patch # User Rik # Date 1601307832 25200 # Node ID 191538bdae3f9300fef7aba05410dfcf23946a51 # Parent ffa6c50c2eaaf5f4d91c4bd619a2c6dff98dbc62 Add BIST test for bug #59198. * jsonencode_BIST.tst: Add BIST test for encoding N-D logical arrays. diff -r ffa6c50c2eaa -r 191538bdae3f test/json/jsonencode_BIST.tst --- 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