@@ -0,0 +1,1787 @@
+//%0A//  TestJSONDecoding.java%0A//  xal%0A//%0A//  Created by Tom Pelaia on 2/17/2011.%0A//  Copyright 2011 Oak Ridge National Lab. All rights reserved.%0A//%0A%0Apackage xal.tools.text;%0A%0Aimport org.junit.*;%0A%0A%0A/** test the ScientificNumberFormat class */%0Apublic class TestScientificNumberFormat %7B%0A%09@Test%0A%09public void testPositiveSimpleFormats() %7B%0A%09%09assertFormat( %22    3.1416%22, 5, 10, 3.14159265 );%0A%09%7D%0A%0A%0A%09@Test%0A%09public void testNegativeSimpleFormats() %7B%0A%09%09assertFormat( %22   -3.1416%22, 5, 10, -3.14159265 );%0A%09%7D%0A%0A%0A%09@Test%0A%09public void testPositiveExponentialFormats() %7B%0A%09%09assertFormat( %22   1.000E1%22, 4, 10, 10.0 );%0A%09%09assertFormat( %22    3.00E2%22, 3, 10, 300.0 );%0A%09%09assertFormat( %22  5.24E250%22, 3, 10, 5.2395E+250 );%0A%09%09assertFormat( %22  1.000E-1%22, 4, 10, 0.1 );%0A%09%09assertFormat( %22  9.900E-1%22, 4, 10, 0.99 );%0A%09%7D%0A%0A%0A%09@Test%0A%09public void testNegativeExponentialFormats() %7B%0A%09%09assertFormat( %22  -1.000E1%22, 4, 10, -10.0 );%0A%09%09assertFormat( %22 -1.000E-1%22, 4, 10, -0.1 );%0A%09%09assertFormat( %22 -9.900E-1%22, 4, 10, -0.99 );%0A%09%09assertFormat( %22   -3.00E2%22, 3, 10, -300.0 );%0A%09%09assertFormat( %22  -5.2395E250%22, 5, 13, -5.2395E+250 );%0A%09%09assertFormat( %22 -5.2395E-250%22, 5, 13, -5.2395E-250 );%0A%09%7D%0A%0A%0A%09@Test%0A%09public void testRoundingFormats() %7B%0A%09%09assertFormat( %22    1.49%22, 3, 8, 1.494999 );%0A%09%09assertFormat( %22    1.50%22, 3, 8, 1.495 );%0A%09%7D%0A%0A%0A%09/** Assert whether the formatted output matches the specified reference */%0A%09static private void assertFormat( final String reference, final int significantDigits, final int width, final double value ) %7B%0A%09%09final ScientificNumberFormat format = new ScientificNumberFormat( significantDigits, width );%0A%09%09final String output = format.format( value );%0A%09%09Assert.assertEquals( %22Failed format equality for number: %22 + value + %22 with output: %22 + output + %22 of length: %22 + output.length(), reference, output );%0A%09%7D%0A%7D

Add unit tests for ScientificNumberFormat