@@ -15,25 +15,29 @@ function test2dArrayInRange0to10(tc)
1515
1616 function testInRange1e6to1e5(tc )
1717 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]" ;
1920 tc .verifyEqual(string(m2json(values )), expected );
2021 end
2122
2223 function testInRange1e14Plus0to1(tc )
2324 values = 1e14 + (1 : 5 ) + 0.23456789 ;
24- expected = " [100000000000001,100000000000002,100000000000003,100000000000004,100000000000005]" ;
25+ expected = " [100000000000001,100000000000002," ...
26+ + " 100000000000003,100000000000004,100000000000005]" ;
2527 tc .verifyEqual(string(m2json(values )), expected );
2628 end
2729
2830 function testInRange1e14Plus1e7Plus0to1(tc )
2931 values = 1e14 + 1e7 + (1 : 5 ) + 0.23456789 ;
30- expected = " [100000010000001,100000010000002,100000010000003,100000010000004,100000010000005]" ;
32+ expected = " [100000010000001,100000010000002," ...
33+ + " 100000010000003,100000010000004,100000010000005]" ;
3134 tc .verifyEqual(string(m2json(values )), expected );
3235 end
3336
3437 function testLogScaledVariables(tc )
3538 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]" ;
3741 tc .verifyEqual(string(m2json(values )), expected );
3842 end
3943
@@ -45,14 +49,65 @@ function testInRangeMinus10to0(tc)
4549
4650 function testInRangeMinus1e5toMinus1e6(tc )
4751 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]" ;
4954 tc .verifyEqual(string(m2json(values )), expected );
5055 end
5156
5257 function testInRangeMinus1e14Plus0to1(tc )
5358 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]" ;
5562 tc .verifyEqual(string(m2json(values )), expected );
5663 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
57112 end
58113end
0 commit comments