Skip to content

Commit

Permalink
add indentation test
Browse files Browse the repository at this point in the history
  • Loading branch information
fangq committed Jun 20, 2023
1 parent b267858 commit 5bfde65
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion test/run_jsonlab_test.m
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ function run_jsonlab_test(tests)
test_jsonlab('empty name',@savejson,loadjson('{"":""}'),'{"":""}','compact',1);
if(exist('containers.Map'))
test_jsonlab('empty name with map',@savejson,loadjson('{"":""}','usemap',1),'{"":""}','compact',1);
test_jsonlab('indentation',@savejson,savejson(containers.Map({'a','b'},{[],struct('c',1.1,'d',struct('e',{1,2}))})),...
'"{\n\t\"a\":[],\n\t\"b\":{\n\t\t\"c\":1.1,\n\t\t\"d\":[\n\t\t\t{\n\t\t\t\t\"e\":1\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"e\":2\n\t\t\t}\n\t\t]\n\t}\n}\n"');
end
test_jsonlab('row vector',@savejson,[1,2,3],'[1,2,3]');
test_jsonlab('column vector',@savejson,[1;2;3],'[[1],[2],[3]]','compact',1);
Expand Down Expand Up @@ -95,7 +97,7 @@ function run_jsonlab_test(tests)
else
test_jsonlab('encoded fieldnames without decoding',@savejson,struct(encodevarname('_i'),1,encodevarname('i_'),'str'),...
'{"x0x5F_i":1,"i_":"str"}','compact',1,'UnpackHex',0);
end
end
if(exist('containers.Map'))
test_jsonlab('containers.Map',@savejson,containers.Map({'Andy','^_^'},{true,'-_-'}),...
'{"Andy":true,"^_^":"-_-"}','compact',1,'usemap',1);
Expand Down

0 comments on commit 5bfde65

Please sign in to comment.