1
1
classdef Test_m2json < matlab .unittest .TestCase
2
2
methods (Test )
3
+ function testLowPrecisionInRange0to10(tc )
4
+ values = 1 + (1 : 5 ) + 0.234 ;
5
+ expected = " [2.234,3.234,4.234,5.234,6.234]" ;
6
+ tc .verifyEqual(string(m2json(values )), expected );
7
+ end
8
+
3
9
function testInRange0to10(tc )
4
10
values = 1 + (1 : 5 ) + 0.23456789 ;
5
- expected = " [2.235,3.235,4.235,5.235,6.235]" ;
11
+ expected = " [2.23456789,3.23456789,4.23456789,5.23456789," ...
12
+ + " 6.23456789]" ;
6
13
tc .verifyEqual(string(m2json(values )), expected );
7
14
end
8
15
9
16
function test2dArrayInRange0to10(tc )
10
- values = 1 + (1 : 5 ) + (0 : 1 )' + 0.23456789 ;
11
- expected = " [[2.235,3.235,4.235,5.235,6.235]," ...
12
- + " [3.235,4.235,5.235,6.235,7.235]]" ;
17
+ values = 1 + (1 : 5 ) + (0 : 1 )' + 0.234 ;
18
+ expected = " [[2.234,3.234,4.234,5.234,6.234]," ...
19
+ + " [3.234,4.234,5.234,6.234,7.234]]" ;
20
+ tc .verifyEqual(string(m2json(values )), expected );
21
+ end
22
+
23
+ function testLowPrecisionInRange1e6to1e5(tc )
24
+ values = 1e-6 * (1 + (1 : 5 ) + 0.234 );
25
+ expected = " [2.234e-06,3.234e-06,4.234e-06,5.234e-06," ...
26
+ + " 6.234e-06]" ;
13
27
tc .verifyEqual(string(m2json(values )), expected );
14
28
end
15
29
16
30
function testInRange1e6to1e5(tc )
17
31
values = 1e-6 * (1 + (1 : 5 ) + 0.23456789 );
18
- expected = " [2.235e -06,3.235e -06,4.235e-06,5.235e -06," ...
19
- + " 6.235e -06]" ;
32
+ expected = " [2.23456789e -06,3.23456789e -06,4.23456789e -06," ...
33
+ + " 5.23456789e-06,6.23456789e -06]" ;
20
34
tc .verifyEqual(string(m2json(values )), expected );
21
35
end
22
36
@@ -36,21 +50,28 @@ function testInRange1e14Plus1e7Plus0to1(tc)
36
50
37
51
function testLogScaledVariables(tc )
38
52
values = 1e14 + 10 .^(1 : 5 ) + 0.23456789 ;
39
- expected = " [1e+14,1.000000000001e+14,1.00000000001e+14," ...
40
- + " 1.0000000001e+14,1.000000001e+14]" ;
53
+ expected = " [100000000000010,100000000000100," ...
54
+ + " 100000000001000,100000000010000,100000000100000]" ;
55
+ tc .verifyEqual(string(m2json(values )), expected );
56
+ end
57
+
58
+ function testLowPrecisionInRangeMinus10to0(tc )
59
+ values = -(1 + (1 : 5 ) + 0.234 );
60
+ expected = " [-2.234,-3.234,-4.234,-5.234,-6.234]" ;
41
61
tc .verifyEqual(string(m2json(values )), expected );
42
62
end
43
63
44
64
function testInRangeMinus10to0(tc )
45
65
values = -(1 + (1 : 5 ) + 0.23456789 );
46
- expected = " [-2.235,-3.235,-4.235,-5.235,-6.235]" ;
66
+ expected = " [-2.23456789,-3.23456789,-4.23456789," ...
67
+ + " -5.23456789,-6.23456789]" ;
47
68
tc .verifyEqual(string(m2json(values )), expected );
48
69
end
49
70
50
71
function testInRangeMinus1e5toMinus1e6(tc )
51
72
values = - 1e-6 * (1 + (1 : 5 ) + 0.23456789 );
52
- expected = " [-2.235e -06,-3.235e-06,-4.235e-06,-5.235e -06," ...
53
- + " -6.235e -06]" ;
73
+ expected = " [-2.23456789e -06,-3.23456789e -06," ...
74
+ + " -4.23456789e-06,-5.23456789e-06,-6.23456789e -06]" ;
54
75
tc .verifyEqual(string(m2json(values )), expected );
55
76
end
56
77
0 commit comments