forked from TheAlgorithms/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBubbleSortTest.java
More file actions
37 lines (26 loc) · 1.11 KB
/
BubbleSortTest.java
File metadata and controls
37 lines (26 loc) · 1.11 KB
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
package com.sorts;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
class BubbleSortTest {
@Test
void bubbleSortTestIntegers() {
BubbleSort<Integer> bubbleSort = new BubbleSort<>();
Integer[] unsortedInt = {0, 5, 9, 2, 1, 3, 4, 8, 6, 7};
Integer[] sortedInt = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
Assertions.assertArrayEquals(sortedInt, bubbleSort.sort(unsortedInt));
}
@Test
void bubbleSortTestCharacters() {
BubbleSort<Character> bubbleSort = new BubbleSort<>();
Character[] unsortedChar = {'f', 'h', 'c', 'a', 'b', 'd', 'g', 'e'};
Character[] sortedChar = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'};
Assertions.assertArrayEquals(sortedChar, bubbleSort.sort(unsortedChar));
}
@Test
void bubbleSortTestStrings() {
BubbleSort<String> bubbleSort = new BubbleSort<>();
String[] unsortedChar = {"abc", "adc", "bcd", "abb", "abc", "acb"};
String[] sortedChar = {"abb", "abc", "abc", "acb", "adc", "bcd"};
Assertions.assertArrayEquals(sortedChar, bubbleSort.sort(unsortedChar));
}
}