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