-
-
Notifications
You must be signed in to change notification settings - Fork 314
/
Copy pathTestSort.java
75 lines (64 loc) · 1.82 KB
/
TestSort.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import org.junit.jupiter.api.*;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
public class TestSort {
@BeforeAll
public static void BeforeAll() {
System.out.println("Start All Test");
}
@AfterAll
public static void AfterAll() {
System.out.println("End All Test");
}
@BeforeEach
public void BeforeEach() {
System.out.println("Begin Test");
}
@AfterEach
public void AfterEach() {
System.out.println("After Test");
}
@Test
@DisplayName("Default Test")
void testArray() {
int[] ar = {2, 5, 1, 7, 8};
BubbleSort.bubbleSort(ar);
int[] expected = {1, 2, 5, 7, 8};
assertArrayEquals(expected, ar);
}
@Test
@Tag("Array")
@DisplayName("Test With Empty Array")
public void testEmptyArray() {
int[] ar = {};
BubbleSort.bubbleSort(ar);
int[] expected = {};
assertArrayEquals(expected, ar);
}
@Test
@Tag("Array")
@DisplayName("Test With Duplicate Element")
public void testDuplicateParameter() {
int[] ar = {9, 5, 6, 0, 5, 6, 11, 2, 4};
BubbleSort.bubbleSort(ar);
int[] expected = {0, 2, 4, 5, 5, 6, 6, 9, 11};
assertArrayEquals(expected, ar);
}
@Test
@Tag("Array")
@DisplayName("Test With Negative Integer Element")
public void testSameArray() {
int[] ar = {-1, -2, 5, 7, -8};
BubbleSort.bubbleSort(ar);
int[] expected = {-8, -2, -1, 5, 7};
Assertions.assertArrayEquals(expected, ar);
}
@Test
@Tag("Array")
@DisplayName("Test With Array Reverse")
public void testReverseArray() {
int[] ar = {8, 7, 5, 2, 1};
BubbleSort.bubbleSort(ar);
int[] expected = {1, 2, 5, 7, 8};
assertArrayEquals(expected, ar);
}
}