Skip to content

Commit bdfecbe

Browse files
authored
Added test cases to CombSort. (TheAlgorithms#3776)
* Add testcase to CocktailShakerSort Algorithm * fixed method name to lowerCamelCase * Added test cases to OddEvenSortTest * Added test case to CombSort
1 parent 7692e8f commit bdfecbe

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
package com.thealgorithms.sorts;
2+
3+
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
4+
5+
import org.junit.jupiter.api.Test;
6+
7+
/**
8+
* @author Tabbygray (https://github.com/Tabbygray)
9+
* @see CombSort
10+
*/
11+
12+
public class CombSortTest {
13+
14+
private CombSort combSort = new CombSort();
15+
16+
@Test
17+
public void combSortEmptyArray() {
18+
Integer[] inputArray = {};
19+
Integer[] outputArray = combSort.sort(inputArray);
20+
Integer[] expectedOutput = {};
21+
assertArrayEquals(outputArray, expectedOutput);
22+
}
23+
24+
@Test
25+
public void combSortSingleStringElement() {
26+
String[] inputArray = {"Test"};
27+
String[] outputArray = combSort.sort(inputArray);
28+
String[] expectedArray = {"Test"};
29+
assertArrayEquals(outputArray, expectedArray);
30+
}
31+
32+
@Test
33+
public void combSortStringArray() {
34+
String[] inputArray = {
35+
"4gp8",
36+
"aBJ2",
37+
"85cW",
38+
"Pmk9",
39+
"ewZO",
40+
"meuU",
41+
"RhNd",
42+
"5TKB",
43+
"eDd5",
44+
"zzyo"
45+
};
46+
String[] outputArray = combSort.sort(inputArray);
47+
String[] expectedArray = {
48+
"4gp8",
49+
"5TKB",
50+
"85cW",
51+
"Pmk9",
52+
"RhNd",
53+
"aBJ2",
54+
"eDd5",
55+
"ewZO",
56+
"meuU",
57+
"zzyo"
58+
};
59+
assertArrayEquals(outputArray, expectedArray);
60+
}
61+
62+
@Test
63+
public void combSortIntegerArray() {
64+
Integer[] inputArray = { 36, 98, -51, -23, 66, -58, 31, 25, -30, 40 };
65+
Integer[] outputArray = combSort.sort(inputArray);
66+
Integer[] expectedArray = { -58, -51, -30, -23, 25, 31, 36, 40, 66, 98 };
67+
assertArrayEquals(outputArray, expectedArray);
68+
}
69+
70+
@Test
71+
public void combSortDoubleArray() {
72+
Double[] inputArray = {
73+
0.8335545399, 0.9346214114,
74+
0.3096396752, 0.6433840668,
75+
0.3973191975, 0.6118850724,
76+
0.0553975453, 0.1961108601,
77+
0.6172800885, 0.1065247772
78+
};
79+
Double[] outputArray = combSort.sort(inputArray);
80+
Double[] expectedArray = {
81+
0.0553975453, 0.1065247772,
82+
0.1961108601, 0.3096396752,
83+
0.3973191975, 0.6118850724,
84+
0.6172800885, 0.6433840668,
85+
0.8335545399, 0.9346214114,
86+
};
87+
assertArrayEquals(outputArray, expectedArray);
88+
}
89+
}

0 commit comments

Comments
 (0)