01: // Copyright (C) 2003,2004,2005 by Object Mentor, Inc. All rights reserved.
02: // Released under the terms of the GNU General Public License version 2 or later.
03: package fit;
04:
05: import junit.framework.TestCase;
06:
07: public class ScientificDoubleTest extends TestCase {
08: public void testScientificDouble() {
09: Double pi = new Double(3.141592653589793);
10: assertEquals(ScientificDouble.valueOf("3.14"), pi);
11: assertEquals(ScientificDouble.valueOf("3.142"), pi);
12: assertEquals(ScientificDouble.valueOf("3.1416"), pi);
13: assertEquals(ScientificDouble.valueOf("3.14159"), pi);
14: assertEquals(ScientificDouble.valueOf("3.141592653589793"), pi);
15: assertFalse(ScientificDouble.valueOf("3.140").equals(pi));
16: assertFalse(ScientificDouble.valueOf("3.144").equals(pi));
17: assertFalse(ScientificDouble.valueOf("3.1414").equals(pi));
18: assertFalse(ScientificDouble.valueOf("3.141592863").equals(pi));
19: assertEquals(ScientificDouble.valueOf("6.02e23"), new Double(
20: 6.02e23));
21: assertEquals(ScientificDouble.valueOf("6.02E23"), new Double(
22: 6.024E23));
23: assertEquals(ScientificDouble.valueOf("6.02e23"), new Double(
24: 6.016e23));
25: assertFalse(ScientificDouble.valueOf("6.02e23").equals(
26: new Double(6.026e23)));
27: assertFalse(ScientificDouble.valueOf("6.02e23").equals(
28: new Double(6.014e23)));
29: }
30:
31: }
|