Skip to content

Commit 11a65f6

Browse files
authored
Merge pull request #33 from Data-Structure-Study/yoonexample
매개변수화된 테스트 작성을 위한 의존성 추가 및 테스트 코드 리팩토링😊
2 parents 1c22e45 + 76bf763 commit 11a65f6

File tree

3 files changed

+212
-104
lines changed

3 files changed

+212
-104
lines changed

yoonexample/build.gradle

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,16 @@ repositories {
1111
mavenCentral()
1212
}
1313

14+
test {
15+
useJUnitPlatform()
16+
testLogging {
17+
events "passed", "skipped", "failed"
18+
}
19+
}
20+
1421
dependencies {
1522
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.6.2'
23+
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.6.2'
24+
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.6.2'
1625
testImplementation 'org.assertj:assertj-core:3.16.1'
1726
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
package heap;
2+
3+
import static org.assertj.core.api.Assertions.assertThat;
4+
5+
import org.junit.jupiter.api.DisplayName;
6+
import org.junit.jupiter.api.Test;
7+
import org.junit.jupiter.params.ParameterizedTest;
8+
import org.junit.jupiter.params.provider.CsvSource;
9+
10+
class SimpleHeapTest {
11+
12+
@Test
13+
@DisplayName("힙의_초기화_테스트")
14+
void 힙의_초기화_테스트() {
15+
SimpleHeap<Character> charHeap = new ArraySimpleHeap<>();
16+
17+
assertThat(charHeap).isNotNull();
18+
assertThat(charHeap.isEmpty()).isTrue();
19+
}
20+
21+
@ParameterizedTest
22+
@CsvSource({"'A','B','C'"})
23+
@DisplayName("힙_저장_테스트")
24+
void 힙_저장_테스트(char firstElem, char secondElem, char thirdElem) {
25+
SimpleHeap<Character> charHeap = new ArraySimpleHeap<>();
26+
27+
charHeap.insert(firstElem, 1);
28+
charHeap.insert(secondElem, 2);
29+
charHeap.insert(thirdElem, 3);
30+
31+
assertThat(charHeap).isNotNull();
32+
assertThat(charHeap.isEmpty()).isFalse();
33+
}
34+
35+
@ParameterizedTest
36+
@CsvSource({"'A','B','C'"})
37+
@DisplayName("힙_저장_후_제거_테스트")
38+
void 힙_저장_후_제거_테스트(char firstElem, char secondElem, char thirdElem) {
39+
SimpleHeap<Character> charHeap = new ArraySimpleHeap<>();
40+
41+
charHeap.insert(firstElem, 1);
42+
charHeap.insert(secondElem, 2);
43+
charHeap.insert(thirdElem, 3);
44+
45+
assertThat(charHeap).isNotNull();
46+
assertThat(charHeap.isEmpty()).isFalse();
47+
assertThat(charHeap.delete()).isEqualTo(firstElem);
48+
assertThat(charHeap.delete()).isEqualTo(secondElem);
49+
assertThat(charHeap.delete()).isEqualTo(thirdElem);
50+
assertThat(charHeap.isEmpty()).isTrue();
51+
}
52+
53+
@ParameterizedTest
54+
@CsvSource({"'A','B','C'"})
55+
@DisplayName("힙_사용_테스트")
56+
void 힙_사용_테스트(char firstElem, char secondElem, char thirdElem) {
57+
SimpleHeap<Character> charHeap = new ArraySimpleHeap<>();
58+
59+
charHeap.insert(firstElem, 1);
60+
charHeap.insert(secondElem, 2);
61+
charHeap.insert(thirdElem, 3);
62+
63+
assertThat(charHeap.delete()).isEqualTo('A');
64+
65+
charHeap.insert(firstElem, 1);
66+
charHeap.insert(secondElem, 2);
67+
charHeap.insert(thirdElem, 3);
68+
69+
assertThat(charHeap).isNotNull();
70+
assertThat(charHeap.isEmpty()).isFalse();
71+
assertThat(charHeap.delete()).isEqualTo(firstElem);
72+
assertThat(charHeap.delete()).isEqualTo(secondElem);
73+
assertThat(charHeap.delete()).isEqualTo(secondElem);
74+
assertThat(charHeap.delete()).isEqualTo(thirdElem);
75+
assertThat(charHeap.delete()).isEqualTo(thirdElem);
76+
assertThat(charHeap.isEmpty()).isTrue();
77+
}
78+
}

0 commit comments

Comments
 (0)