01: package junit.tests.framework;
02:
03: import junit.framework.AssertionFailedError;
04: import junit.framework.TestCase;
05:
06: public class DoublePrecisionAssertTest extends TestCase {
07:
08: /**
09: * Test for the special Double.NaN value.
10: */
11: public void testAssertEqualsNaNFails() {
12: try {
13: assertEquals(1.234, Double.NaN, 0.0);
14: fail();
15: } catch (AssertionFailedError e) {
16: }
17: }
18:
19: public void testAssertNaNEqualsFails() {
20: try {
21: assertEquals(Double.NaN, 1.234, 0.0);
22: fail();
23: } catch (AssertionFailedError e) {
24: }
25: }
26:
27: public void testAssertNaNEqualsNaN() {
28: assertEquals(Double.NaN, Double.NaN, 0.0);
29: }
30:
31: public void testAssertPosInfinityNotEqualsNegInfinity() {
32: try {
33: assertEquals(Double.POSITIVE_INFINITY,
34: Double.NEGATIVE_INFINITY, 0.0);
35: fail();
36: } catch (AssertionFailedError e) {
37: }
38: }
39:
40: public void testAssertPosInfinityNotEquals() {
41: try {
42: assertEquals(Double.POSITIVE_INFINITY, 1.23, 0.0);
43: fail();
44: } catch (AssertionFailedError e) {
45: }
46: }
47:
48: public void testAssertPosInfinityEqualsInfinity() {
49: assertEquals(Double.POSITIVE_INFINITY,
50: Double.POSITIVE_INFINITY, 0.0);
51: }
52:
53: public void testAssertNegInfinityEqualsInfinity() {
54: assertEquals(Double.NEGATIVE_INFINITY,
55: Double.NEGATIVE_INFINITY, 0.0);
56: }
57:
58: }
|