- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringPoolTest.java
More file actions
Latest commit
52 lines (40 loc) · 1.08 KB
/
Copy pathStringPoolTest.java
File metadata and controls
52 lines (40 loc) · 1.08 KB
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
packagebasics;
importorg.junit.jupiter.api.Assertions;
importorg.junit.jupiter.api.Test;
publicclassStringPoolTest {
@Test
publicvoidsameMemoryTest() {
//given
Strings1 = "minseok";
Strings2 = "minseok";
//then
Assertions.assertTrue(s1 == s2);
}
@Test
publicvoidnew로_생성한객체는_같은메모리를_공유하지않는다() {
//given
Strings1 = newString("minseok");
Strings2 = newString("minseok");
//then
Assertions.assertFalse(s1 == s2);
}
@Test
publicvoidnew로_생성한객체와_리터럴String은_동일하지않다() {
//given
Strings1 = "minseok";
Strings2 = newString("minseok");
//then
Assertions.assertFalse(s1 == s2);
}
@Test
publicvoidInterningTest() {
//given
Strings1 = "minseok";
Strings2 = newString("minseok");
//when
Assertions.assertFalse(s1 == s2);
s2 = s2.intern();
//then
Assertions.assertTrue(s1 == s2);
}
}