|
6 | 6 | class BubbleSortTest { |
7 | 7 |
|
8 | 8 | @Test |
9 | | - void bubbleSortTest() { |
10 | | - BubbleSort bubbleSort = new BubbleSort(); |
| 9 | + void bubbleSortTestIntegers() { |
| 10 | + BubbleSort<Integer> bubbleSort = new BubbleSort<>(); |
11 | 11 |
|
12 | | - Integer[] unsortedInt = new Integer[]{0, 5, 9, 2, 1, 3, 4, 8, 6, 7}; |
13 | | - Integer[] sortedInt = new Integer[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; |
| 12 | + Integer[] unsortedInt = {0, 5, 9, 2, 1, 3, 4, 8, 6, 7}; |
| 13 | + Integer[] sortedInt = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; |
14 | 14 | Assertions.assertArrayEquals(sortedInt, bubbleSort.sort(unsortedInt)); |
15 | 15 |
|
16 | | - Character[] unsortedChar = new Character[]{'f', 'h', 'c', 'a', 'b', 'd', 'g', 'e'}; |
17 | | - Character[] sortedChar = new Character[]{'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'}; |
| 16 | + } |
| 17 | + |
| 18 | + @Test |
| 19 | + void bubbleSortTestCharacters() { |
| 20 | + BubbleSort<Character> bubbleSort = new BubbleSort<>(); |
| 21 | + |
| 22 | + Character[] unsortedChar = {'f', 'h', 'c', 'a', 'b', 'd', 'g', 'e'}; |
| 23 | + Character[] sortedChar = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'}; |
18 | 24 | Assertions.assertArrayEquals(sortedChar, bubbleSort.sort(unsortedChar)); |
19 | 25 |
|
20 | 26 | } |
21 | 27 |
|
| 28 | + @Test |
| 29 | + void bubbleSortTestStrings() { |
| 30 | + BubbleSort<String> bubbleSort = new BubbleSort<>(); |
| 31 | + |
| 32 | + String[] unsortedChar = {"abc", "adc", "bcd", "abb", "abc", "acb"}; |
| 33 | + String[] sortedChar = {"abb", "abc", "abc", "acb", "adc", "bcd"}; |
| 34 | + Assertions.assertArrayEquals(sortedChar, bubbleSort.sort(unsortedChar)); |
| 35 | + |
| 36 | + } |
22 | 37 | } |
0 commit comments