|
| 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 | +public class SimpleSortTest { |
| 8 | + |
| 9 | + private SimpleSort simpleSort = new SimpleSort(); |
| 10 | + |
| 11 | + @Test |
| 12 | + public void simpleSortEmptyArray() { |
| 13 | + Integer[] inputArray = {}; |
| 14 | + Integer[] outputArray = simpleSort.sort(inputArray); |
| 15 | + Integer[] expectedOutput = {}; |
| 16 | + assertArrayEquals(outputArray, expectedOutput); |
| 17 | + } |
| 18 | + |
| 19 | + @Test |
| 20 | + public void simpleSortSingleIntegerArray() { |
| 21 | + Integer[] inputArray = { 4 }; |
| 22 | + Integer[] outputArray = simpleSort.sort(inputArray); |
| 23 | + Integer[] expectedOutput = { 4 }; |
| 24 | + assertArrayEquals(outputArray, expectedOutput); |
| 25 | + } |
| 26 | + |
| 27 | + @Test |
| 28 | + public void simpleSortSingleStringArray() { |
| 29 | + String[] inputArray = { "s" }; |
| 30 | + String[] outputArray = simpleSort.sort(inputArray); |
| 31 | + String[] expectedOutput = { "s" }; |
| 32 | + assertArrayEquals(outputArray, expectedOutput); |
| 33 | + } |
| 34 | + |
| 35 | + @Test |
| 36 | + public void simpleSortNonDuplicateIntegerArray() { |
| 37 | + Integer[] inputArray = { 6, -1, 99, 27, -15, 23, -36 }; |
| 38 | + Integer[] outputArray = simpleSort.sort(inputArray); |
| 39 | + Integer[] expectedOutput = { -36, -15, -1, 6, 23, 27, 99}; |
| 40 | + assertArrayEquals(outputArray, expectedOutput); |
| 41 | + } |
| 42 | + |
| 43 | + @Test |
| 44 | + public void simpleSortDuplicateIntegerArray() { |
| 45 | + Integer[] inputArray = { 6, -1, 27, -15, 23, 27, -36, 23 }; |
| 46 | + Integer[] outputArray = simpleSort.sort(inputArray); |
| 47 | + Integer[] expectedOutput = { -36, -15, -1, 6, 23, 23, 27, 27}; |
| 48 | + assertArrayEquals(outputArray, expectedOutput); |
| 49 | + } |
| 50 | + |
| 51 | + @Test |
| 52 | + public void simpleSortNonDuplicateStringArray() { |
| 53 | + String[] inputArray = { "s", "b", "k", "a", "d", "c", "h" }; |
| 54 | + String[] outputArray = simpleSort.sort(inputArray); |
| 55 | + String[] expectedOutput = {"a", "b", "c", "d", "h", "k", "s" }; |
| 56 | + assertArrayEquals(outputArray, expectedOutput); |
| 57 | + } |
| 58 | + |
| 59 | + @Test |
| 60 | + public void simpleSortDuplicateStringArray() { |
| 61 | + String[] inputArray = { "s", "b", "d", "a", "d", "c", "h", "b" }; |
| 62 | + String[] outputArray = simpleSort.sort(inputArray); |
| 63 | + String[] expectedOutput = {"a", "b", "b", "c", "d", "d", "h", "s" }; |
| 64 | + assertArrayEquals(outputArray, expectedOutput); |
| 65 | + } |
| 66 | +} |
0 commit comments