forked from jieli4970/Algorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest.java
More file actions
77 lines (55 loc) · 1.44 KB
/
Test.java
File metadata and controls
77 lines (55 loc) · 1.44 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import org.junit.Assert;
public class Test {
private Integer[][] numsBefore = {
{1, 2, 3},
{3, 2, 1},
{1},
{1, 3, 5, 7, 6, 4, 2, 0, -1, -2},
{Integer.MAX_VALUE, Integer.MIN_VALUE}
};
private Integer[][] numsAfter = {
{1, 2, 3},
{1, 2, 3},
{1},
{-2, -1, -0, 1, 2, 3, 4, 5, 6, 7},
{Integer.MIN_VALUE, Integer.MAX_VALUE}
};
@org.junit.Test
public void SelectionTest() {
test(new Selection<>());
}
@org.junit.Test
public void BubbleTest() {
test(new Bubble<>());
}
@org.junit.Test
public void InsertionTest() {
test(new Insertion<>());
}
@org.junit.Test
public void ShellTest() {
test(new Shell<>());
}
@org.junit.Test
public void Up2DownMergeSortTest() {
test(new Up2DownMergeSort<>());
}
@org.junit.Test
public void Down2UpMergeSortTest() {
test(new Down2UpMergeSort<>());
}
@org.junit.Test
public void QuickSortTest() {
test(new QuickSort<>());
}
@org.junit.Test
public void ThreeWayQuickSortTest() {
test(new ThreeWayQuickSort<>());
}
private void test(Sort<Integer> sort) {
for (int i = 0; i < numsBefore.length; i++) {
sort.sort(numsBefore[i]);
Assert.assertArrayEquals(numsBefore[i], numsAfter[i]);
}
}
}