11classdef Test_m2json < matlab .unittest .TestCase
22 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+
39 function testInRange0to10(tc )
410 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]" ;
613 tc .verifyEqual(string(m2json(values )), expected );
714 end
815
916 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]" ;
1327 tc .verifyEqual(string(m2json(values )), expected );
1428 end
1529
1630 function testInRange1e6to1e5(tc )
1731 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]" ;
2034 tc .verifyEqual(string(m2json(values )), expected );
2135 end
2236
@@ -36,21 +50,28 @@ function testInRange1e14Plus1e7Plus0to1(tc)
3650
3751 function testLogScaledVariables(tc )
3852 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]" ;
4161 tc .verifyEqual(string(m2json(values )), expected );
4262 end
4363
4464 function testInRangeMinus10to0(tc )
4565 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]" ;
4768 tc .verifyEqual(string(m2json(values )), expected );
4869 end
4970
5071 function testInRangeMinus1e5toMinus1e6(tc )
5172 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]" ;
5475 tc .verifyEqual(string(m2json(values )), expected );
5576 end
5677
0 commit comments