summaryrefslogtreecommitdiffstats
path: root/junit4/src/test/java/junit/tests/framework/FloatAssertTest.java
blob: 2d22549291912b9666a09398efcbd35a898cb7b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package junit.tests.framework;

import junit.framework.AssertionFailedError;
import junit.framework.TestCase;

public class FloatAssertTest extends TestCase {

	/**
		 * Test for the special Double.NaN value.
		 */
	public void testAssertEqualsNaNFails() {
		try {
			assertEquals(1.234f, Float.NaN, 0.0);
			fail();
		} catch (AssertionFailedError e) {
		}
	}

	public void testAssertNaNEqualsFails() {
		try {
			assertEquals(Float.NaN, 1.234f, 0.0);
			fail();
		} catch (AssertionFailedError e) {
		}
	}

	public void testAssertNaNEqualsNaN() {
		assertEquals(Float.NaN, Float.NaN, 0.0);
	}

	public void testAssertPosInfinityNotEqualsNegInfinity() {
		try {
			assertEquals(Float.POSITIVE_INFINITY, Float.NEGATIVE_INFINITY, 0.0);
			fail();
		} catch (AssertionFailedError e) {
		}
	}

	public void testAssertPosInfinityNotEquals() {
		try {
			assertEquals(Float.POSITIVE_INFINITY, 1.23f, 0.0);
			fail();
		} catch (AssertionFailedError e) {
		}
	}

	public void testAssertPosInfinityEqualsInfinity() {
		assertEquals(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY, 0.0);
	}

	public void testAssertNegInfinityEqualsInfinity() {
		assertEquals(Float.NEGATIVE_INFINITY, Float.NEGATIVE_INFINITY, 0.0);
	}
	
	public void testAllInfinities() {
		try {
			assertEquals(Float.POSITIVE_INFINITY, Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY);
			fail();
		} catch (AssertionFailedError e) {
		}
	}

}