-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnitTest.java
More file actions
40 lines (32 loc) · 791 Bytes
/
UnitTest.java
File metadata and controls
40 lines (32 loc) · 791 Bytes
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
package util;
import org.junit.*; // for @Test
import static org.junit.Assert.*; // for assertXXX methods
public class UnitTest {
@Test
public void testPowerOperator() {
//assertEquals(8, 2^3, 0);
assertEquals(8, Math.pow(2, 3), 0);
}
@Test
public void testDivision() {
// 4/5 should be 0.8
assertEquals( 0.8, 4.0 / 5, 0);
}
@Test
public void testStringCompare() {
assertTrue( "dmit2015" == "dmit2015");
//assertTrue( "dmit2015" == "DMIT2015");
//assertEquals("dmit2015","DMIT2015");
assertTrue( "dmit2015".equalsIgnoreCase("DMIT2015") );
}
@Test(expected=ArithmeticException.class)
public void testForException() {
assertEquals( 0, 3/0 );
}
// @Test(timeout=5000)
// public void testForInfiniteLoop() {
// while( true ) {
//
// }
// }
}