Skip to content

Commit ac71f6e

Browse files
authored
Added test cases to CocktailShakerSort. (TheAlgorithms#3766)
* Add testcase to CocktailShakerSort Algorithm * fixed method name to lowerCamelCase
1 parent f7dee0d commit ac71f6e

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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 CocktailShakerSort
10+
*/
11+
public class CocktailShakerSortTest {
12+
13+
private CocktailShakerSort cocktailShakerSort = new CocktailShakerSort();
14+
15+
@Test
16+
public void cocktailShakerSortEmptyArray(){
17+
Integer[] inputArray = {};
18+
Integer[] outputArray = cocktailShakerSort.sort(inputArray);
19+
Integer[] expectedOutput = {};
20+
assertArrayEquals(outputArray, expectedOutput);
21+
}
22+
23+
@Test
24+
public void cocktailShakerSortSingleStringElementArray(){
25+
String[] inputArray = {"Test"};
26+
String[] outputArray = cocktailShakerSort.sort(inputArray);
27+
String[] expectedOutput = {"Test"};
28+
assertArrayEquals(outputArray, expectedOutput);
29+
}
30+
31+
@Test
32+
public void cocktailShakerSortIntegerArray(){
33+
Integer[] inputArray = { 2, 92, 1, 33, -33, 27, 5, 100, 78, 99, -100};
34+
Integer[] outputArray = cocktailShakerSort.sort(inputArray);
35+
Integer[] expectedOutput = { -100, -33, 1, 2, 5, 27, 33, 78, 92, 99, 100};
36+
assertArrayEquals(outputArray, expectedOutput);
37+
}
38+
39+
@Test
40+
public void cocktailShakerSortStringArray(){
41+
String[] inputArray = {
42+
"g3x1",
43+
"dN62",
44+
"oMdr",
45+
"KL2b",
46+
"JddJ",
47+
"mvE8",
48+
"Ej7Q",
49+
"n7n7",
50+
"LGTg",
51+
"2E1w",
52+
};
53+
String[] outputArray = cocktailShakerSort.sort(inputArray);
54+
String[] expectedOutput = {
55+
"2E1w",
56+
"Ej7Q",
57+
"JddJ",
58+
"KL2b",
59+
"LGTg",
60+
"dN62",
61+
"g3x1",
62+
"mvE8",
63+
"n7n7",
64+
"oMdr",
65+
};
66+
assertArrayEquals(outputArray, expectedOutput);
67+
}
68+
}

0 commit comments

Comments
 (0)