forked from ryudung/effective-java3-E
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Item61Test.java
53 lines (35 loc) · 858 Bytes
/
Item61Test.java
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
package ch09.item61;
import org.junit.Test;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
public class Item61Test {
@Test(expected = NullPointerException.class)
public void test() {
//given
int a = 1;
Integer b = null;
//then
if (b == a) {
//someThing job
}
}
@Test
public void test1() {
//given
Integer a = new Integer(1);
Integer b = new Integer(1);
//then
//a와 b의 객체 참조 값을 비교한다!!
assertFalse(a == b);
assertTrue(a == b.intValue());
assertTrue(a.intValue() == b.intValue());
}
@Test
public void name() {
//given
Integer a = 1;
Integer b = 1;
//then
assertTrue(a == b);
}
}