/
SlowSortTest.java
79 lines (66 loc) · 2.71 KB
/
SlowSortTest.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
75
76
77
78
79
package com.thealgorithms.sorts;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import org.junit.jupiter.api.Test;
/**
* @author Rebecca Velez (https://github.com/rebeccavelez)
* @see SlowSort
*/
public class SlowSortTest {
private SlowSort slowSort = new SlowSort();
@Test
public void slowSortEmptyArray() {
Integer[] inputArray = {};
Integer[] outputArray = slowSort.sort(inputArray);
Integer[] expectedOutput = {};
assertArrayEquals(outputArray, expectedOutput);
}
@Test
public void slowSortSingleIntegerElementArray() {
Integer[] inputArray = {5};
Integer[] outputArray = slowSort.sort(inputArray);
Integer[] expectedOutput = {5};
assertArrayEquals(outputArray, expectedOutput);
}
@Test
public void slowSortSingleStringElementArray() {
String[] inputArray = {"k"};
String[] outputArray = slowSort.sort(inputArray);
String[] expectedOutput = {"k"};
assertArrayEquals(outputArray, expectedOutput);
}
@Test
public void slowSortIntegerArray() {
Integer[] inputArray = {8, 84, 53, -683, 953, 64, 2, 202, 98, -10};
Integer[] outputArray = slowSort.sort(inputArray);
Integer[] expectedOutput = {-683, -10, 2, 8, 53, 64, 84, 98, 202, 953};
assertArrayEquals(outputArray, expectedOutput);
}
@Test
public void slowSortDuplicateIntegerArray() {
Integer[] inputArray = {8, 84, 8, -2, 953, 64, 2, 953, 98};
Integer[] outputArray = slowSort.sort(inputArray);
Integer[] expectedOutput = {-2, 2, 8, 8, 64, 84, 98, 953, 953};
assertArrayEquals(outputArray, expectedOutput);
}
@Test
public void slowSortStringArray() {
String[] inputArray = {"g", "d", "a", "b", "f", "c", "e"};
String[] outputArray = slowSort.sort(inputArray);
String[] expectedOutput = {"a", "b", "c", "d", "e", "f", "g"};
assertArrayEquals(outputArray, expectedOutput);
}
@Test
public void slowSortDuplicateStringArray() {
String[] inputArray = {"g", "d", "a", "g", "b", "f", "d", "c", "e"};
String[] outputArray = slowSort.sort(inputArray);
String[] expectedOutput = {"a", "b", "c", "d", "d", "e", "f", "g", "g"};
assertArrayEquals(outputArray, expectedOutput);
}
@Test
public void slowSortStringSymbolArray() {
String[] inputArray = {"cbf", "auk", "ó", "(b", "a", ")", "au", "á", "cba", "auk", "(a", "bhy", "cba"};
String[] outputArray = slowSort.sort(inputArray);
String[] expectedOutput = {"(a", "(b", ")", "a", "au", "auk", "auk", "bhy", "cba", "cba", "cbf", "á", "ó"};
assertArrayEquals(outputArray, expectedOutput);
}
}