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