Release 0.9.3
[debian/openrocket] / test / net / sf / openrocket / util / TextUtilTest.java
index 72eee8f86f2a3d90888696a395770b30ea18bbfb..73930cf879c478c3e958b8ce4452ef06d50ab074 100644 (file)
@@ -133,6 +133,9 @@ public class TextUtilTest {
        @Test
        public void roundingTest() {
                
+               assertEquals("1.001", TextUtil.doubleToString(1.00096));
+               
+               
                /*
                 * Not testing with 1.00015 because it might be changed during number formatting
                 * calculations.  Its rounding is basically arbitrary anyway.
@@ -207,4 +210,20 @@ public class TextUtilTest {
                
        }
        
+       
+       @Test
+       public void randomTest() {
+               for (int i=0; i<10000; i++) {
+                       double orig = Math.random();
+                       double result;
+                       double expected = Math.rint(orig*100000) / 100000.0;
+                       
+                       if (orig < 0.1)
+                               continue;
+                       String s = TextUtil.doubleToString(orig);
+                       result = Double.parseDouble(s);
+                       assertEquals(expected, result, 0.00000001);
+               }
+       }
+       
 }