forked from TheAlgorithms/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCombSortTest.java
More file actions
66 lines (56 loc) · 2.12 KB
/
CombSortTest.java
File metadata and controls
66 lines (56 loc) · 2.12 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
package com.thealgorithms.sorts;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import org.junit.jupiter.api.Test;
/**
* @author Tabbygray (https://github.com/Tabbygray)
* @see CombSort
*/
public class CombSortTest {
private CombSort combSort = new CombSort();
@Test
public void combSortEmptyArray() {
Integer[] inputArray = {};
Integer[] outputArray = combSort.sort(inputArray);
Integer[] expectedOutput = {};
assertArrayEquals(outputArray, expectedOutput);
}
@Test
public void combSortSingleStringElement() {
String[] inputArray = {"Test"};
String[] outputArray = combSort.sort(inputArray);
String[] expectedArray = {"Test"};
assertArrayEquals(outputArray, expectedArray);
}
@Test
public void combSortStringArray() {
String[] inputArray = {"4gp8", "aBJ2", "85cW", "Pmk9", "ewZO", "meuU", "RhNd", "5TKB", "eDd5", "zzyo"};
String[] outputArray = combSort.sort(inputArray);
String[] expectedArray = {"4gp8", "5TKB", "85cW", "Pmk9", "RhNd", "aBJ2", "eDd5", "ewZO", "meuU", "zzyo"};
assertArrayEquals(outputArray, expectedArray);
}
@Test
public void combSortIntegerArray() {
Integer[] inputArray = {36, 98, -51, -23, 66, -58, 31, 25, -30, 40};
Integer[] outputArray = combSort.sort(inputArray);
Integer[] expectedArray = {-58, -51, -30, -23, 25, 31, 36, 40, 66, 98};
assertArrayEquals(outputArray, expectedArray);
}
@Test
public void combSortDoubleArray() {
Double[] inputArray = {0.8335545399, 0.9346214114, 0.3096396752, 0.6433840668, 0.3973191975, 0.6118850724, 0.0553975453, 0.1961108601, 0.6172800885, 0.1065247772};
Double[] outputArray = combSort.sort(inputArray);
Double[] expectedArray = {
0.0553975453,
0.1065247772,
0.1961108601,
0.3096396752,
0.3973191975,
0.6118850724,
0.6172800885,
0.6433840668,
0.8335545399,
0.9346214114,
};
assertArrayEquals(outputArray, expectedArray);
}
}