@@ -15,25 +15,29 @@ function test2dArrayInRange0to10(tc)
15
15
16
16
function testInRange1e6to1e5(tc )
17
17
values = 1e-6 * (1 + (1 : 5 ) + 0.23456789 );
18
- expected = " [2.235e-06,3.235e-06,4.235e-06,5.235e-06,6.235e-06]" ;
18
+ expected = " [2.235e-06,3.235e-06,4.235e-06,5.235e-06," ...
19
+ + " 6.235e-06]" ;
19
20
tc .verifyEqual(string(m2json(values )), expected );
20
21
end
21
22
22
23
function testInRange1e14Plus0to1(tc )
23
24
values = 1e14 + (1 : 5 ) + 0.23456789 ;
24
- expected = " [100000000000001,100000000000002,100000000000003,100000000000004,100000000000005]" ;
25
+ expected = " [100000000000001,100000000000002," ...
26
+ + " 100000000000003,100000000000004,100000000000005]" ;
25
27
tc .verifyEqual(string(m2json(values )), expected );
26
28
end
27
29
28
30
function testInRange1e14Plus1e7Plus0to1(tc )
29
31
values = 1e14 + 1e7 + (1 : 5 ) + 0.23456789 ;
30
- expected = " [100000010000001,100000010000002,100000010000003,100000010000004,100000010000005]" ;
32
+ expected = " [100000010000001,100000010000002," ...
33
+ + " 100000010000003,100000010000004,100000010000005]" ;
31
34
tc .verifyEqual(string(m2json(values )), expected );
32
35
end
33
36
34
37
function testLogScaledVariables(tc )
35
38
values = 1e14 + 10 .^(1 : 5 ) + 0.23456789 ;
36
- expected = " [1e+14,1.000000000001e+14,1.00000000001e+14,1.0000000001e+14,1.000000001e+14]" ;
39
+ expected = " [1e+14,1.000000000001e+14,1.00000000001e+14," ...
40
+ + " 1.0000000001e+14,1.000000001e+14]" ;
37
41
tc .verifyEqual(string(m2json(values )), expected );
38
42
end
39
43
@@ -45,14 +49,65 @@ function testInRangeMinus10to0(tc)
45
49
46
50
function testInRangeMinus1e5toMinus1e6(tc )
47
51
values = - 1e-6 * (1 + (1 : 5 ) + 0.23456789 );
48
- expected = " [-2.235e-06,-3.235e-06,-4.235e-06,-5.235e-06,-6.235e-06]" ;
52
+ expected = " [-2.235e-06,-3.235e-06,-4.235e-06,-5.235e-06," ...
53
+ + " -6.235e-06]" ;
49
54
tc .verifyEqual(string(m2json(values )), expected );
50
55
end
51
56
52
57
function testInRangeMinus1e14Plus0to1(tc )
53
58
values = - 1e14 + (1 : 5 ) + 0.23456789 ;
54
- expected = " [-99999999999998.8,-99999999999997.8,-99999999999996.8,-99999999999995.8,-99999999999994.8]" ;
59
+ expected = " [-99999999999998.8,-99999999999997.8," ...
60
+ + " -99999999999996.8,-99999999999995.8," ...
61
+ + " -99999999999994.8]" ;
55
62
tc .verifyEqual(string(m2json(values )), expected );
56
63
end
64
+
65
+ function testCell(tc )
66
+ values = {1 , " text" , [1 ,2 ,3 ]};
67
+ expected = " [1, "" text"" , [1,2,3]]" ;
68
+ tc .verifyEqual(string(m2json(values )), expected );
69
+ end
70
+
71
+ function testStruct(tc )
72
+ values = struct(" a" , 1 , " b" , " text" );
73
+ expected = " {"" a"" : 1, "" b"" : "" text"" }" ;
74
+ tc .verifyEqual(string(m2json(values )), expected );
75
+ end
76
+
77
+ function testDatetime(tc )
78
+ value = datetime(" 2023-05-01 12:30:45" );
79
+ expected = " "" 2023-05-01 12:30:45"" " ;
80
+ tc .verifyEqual(string(m2json(value )), expected );
81
+ end
82
+
83
+ function testDate(tc )
84
+ value = datetime(" 2023-05-01" );
85
+ expected = " "" 2023-05-01"" " ;
86
+ tc .verifyEqual(string(m2json(value )), expected );
87
+ end
88
+
89
+ function testLogicalTrue(tc )
90
+ value = true ;
91
+ expected = " true" ;
92
+ tc .verifyEqual(string(m2json(value )), expected );
93
+ end
94
+
95
+ function testLogicalFalse(tc )
96
+ value = false ;
97
+ expected = " false" ;
98
+ tc .verifyEqual(string(m2json(value )), expected );
99
+ end
100
+
101
+ function testCharArray(tc )
102
+ value = ' Hello' ;
103
+ expected = " "" Hello"" " ;
104
+ tc .verifyEqual(string(m2json(value )), expected );
105
+ end
106
+
107
+ function testString(tc )
108
+ value = " World" ;
109
+ expected = " "" World"" " ;
110
+ tc .verifyEqual(string(m2json(value )), expected );
111
+ end
57
112
end
58
113
end
0 commit comments