|
1 | 1 | package com.thealgorithms.sorts;
|
2 | 2 |
|
3 |
| -import static org.junit.jupiter.api.Assertions.assertArrayEquals; |
4 |
| - |
5 |
| -import org.junit.jupiter.api.Test; |
6 |
| - |
7 |
| -public class ShellSortTest { |
8 |
| - |
9 |
| - private ShellSort shellSort = new ShellSort(); |
10 |
| - |
11 |
| - @Test |
12 |
| - public void shellSortEmptyArray() { |
13 |
| - Integer[] inputArray = {}; |
14 |
| - Integer[] outputArray = shellSort.sort(inputArray); |
15 |
| - Integer[] expectedOutput = {}; |
16 |
| - assertArrayEquals(outputArray, expectedOutput); |
17 |
| - } |
18 |
| - |
19 |
| - @Test |
20 |
| - public void shellSortSingleIntegerArray() { |
21 |
| - Integer[] inputArray = {4}; |
22 |
| - Integer[] outputArray = shellSort.sort(inputArray); |
23 |
| - Integer[] expectedOutput = {4}; |
24 |
| - assertArrayEquals(outputArray, expectedOutput); |
25 |
| - } |
26 |
| - |
27 |
| - @Test |
28 |
| - public void shellSortSingleStringArray() { |
29 |
| - String[] inputArray = {"s"}; |
30 |
| - String[] outputArray = shellSort.sort(inputArray); |
31 |
| - String[] expectedOutput = {"s"}; |
32 |
| - assertArrayEquals(outputArray, expectedOutput); |
33 |
| - } |
34 |
| - |
35 |
| - @Test |
36 |
| - public void shellSortNonDuplicateIntegerArray() { |
37 |
| - Integer[] inputArray = {6, -1, 99, 27, -15, 23, -36}; |
38 |
| - Integer[] outputArray = shellSort.sort(inputArray); |
39 |
| - Integer[] expectedOutput = {-36, -15, -1, 6, 23, 27, 99}; |
40 |
| - assertArrayEquals(outputArray, expectedOutput); |
41 |
| - } |
42 |
| - |
43 |
| - @Test |
44 |
| - public void shellSortDuplicateIntegerArray() { |
45 |
| - Integer[] inputArray = {6, -1, 27, -15, 23, 27, -36, 23}; |
46 |
| - Integer[] outputArray = shellSort.sort(inputArray); |
47 |
| - Integer[] expectedOutput = {-36, -15, -1, 6, 23, 23, 27, 27}; |
48 |
| - assertArrayEquals(outputArray, expectedOutput); |
49 |
| - } |
50 |
| - |
51 |
| - @Test |
52 |
| - public void shellSortNonDuplicateStringArray() { |
53 |
| - String[] inputArray = {"s", "b", "k", "a", "d", "c", "h"}; |
54 |
| - String[] outputArray = shellSort.sort(inputArray); |
55 |
| - String[] expectedOutput = {"a", "b", "c", "d", "h", "k", "s"}; |
56 |
| - assertArrayEquals(outputArray, expectedOutput); |
57 |
| - } |
58 |
| - |
59 |
| - @Test |
60 |
| - public void shellSortDuplicateStringArray() { |
61 |
| - String[] inputArray = {"s", "b", "d", "a", "d", "c", "h", "b"}; |
62 |
| - String[] outputArray = shellSort.sort(inputArray); |
63 |
| - String[] expectedOutput = {"a", "b", "b", "c", "d", "d", "h", "s"}; |
64 |
| - assertArrayEquals(outputArray, expectedOutput); |
| 3 | +public class ShellSortTest extends SortingAlgorithmTest { |
| 4 | + @Override |
| 5 | + SortAlgorithm getSortAlgorithm() { |
| 6 | + return new ShellSort(); |
65 | 7 | }
|
66 | 8 | }
|
0 commit comments