1 package junit.tests.framework;
2
3 import junit.framework.AssertionFailedError;
4 import junit.framework.TestCase;
5
|
6 public class DoublePrecisionAssertTest extends TestCase {
|
7
8 /**
9 * Test for the special Double.NaN value.
10 */
11 public void testAssertEqualsNaNFails() {
12 try {
|
13 assertEquals(1.234, Double.NaN, 0.0);
|
14 > } catch (AssertionFailedError e) {
|
15 return;
|
16 }
|
17 > fail();
18 > }
|
19
20 public void testAssertNaNEqualsFails() {
21 try {
|
22 assertEquals(Double.NaN, 1.234, 0.0);
|
23 > } catch (AssertionFailedError e) {
|
24 return;
|
25 }
|
26 > fail();
27 > }
|
28
29 public void testAssertNaNEqualsNaNFails() {
30 try {
|
31 assertEquals(Double.NaN, Double.NaN, 0.0);
|
32 > } catch (AssertionFailedError e) {
|
33 return;
|
34 }
|
35 > fail();
36 > }
|
37
38 public void testAssertPosInfinityNotEqualsNegInfinity() {
39 try {
|
40 assertEquals(Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, 0.0);
|
41 > } catch (AssertionFailedError e) {
|
42 return;
|
43 }
|
44 > fail();
45 > }
|
46
47 public void testAssertPosInfinityNotEquals() {
48 try {
|
49 assertEquals(Double.POSITIVE_INFINITY, 1.23, 0.0);
|
50 > } catch (AssertionFailedError e) {
|
51 return;
|
52 }
|
53 > fail();
54 > }
|
55
56 public void testAssertPosInfinityEqualsInfinity() {
|
57 assertEquals(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, 0.0);
58 }
|
59
60 public void testAssertNegInfinityEqualsInfinity() {
|
61 assertEquals(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, 0.0);
62 }
|
63
64 }
|