forked from gllmflndn/JSONio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_jsonwrite.m
35 lines (26 loc) · 1016 Bytes
/
test_jsonwrite.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
function tests = test_jsonwrite
% Unit Tests for jsonwrite
% $Id: test_jsonwrite.m 6984 2017-01-09 13:29:55Z guillaume $
tests = functiontests(localfunctions);
function test_jsonwrite_array(testCase)
exp = {'one';'two';'three'};
act = jsonread(jsonwrite(exp));
testCase.verifyTrue(isequal(exp, act));
function test_jsonwrite_object(testCase)
exp = struct('Width',800,'Height',600,'Title','View from the 15th Floor','Animated',false,'IDs',[116;943;234;38793]);
act = jsonread(jsonwrite(exp));
testCase.verifyTrue(isequal(exp, act));
function test_jsonwrite_all_types(testCase)
exp = [];
act = jsonread(jsonwrite(exp));
testCase.verifyTrue(isequal(exp, act));
exp = [true;false];
act = jsonread(jsonwrite(exp));
testCase.verifyTrue(isequal(exp, act));
exp = struct('a','');
act = jsonread(jsonwrite(exp));
testCase.verifyTrue(isequal(exp, act));
str = struct('str',reshape(1:9,3,3));
exp = jsonread('{"str":[[1,4,7],[2,5,8],[3,6,9]]}');
act = jsonread(jsonwrite(str));
testCase.verifyTrue(isequal(act, exp));