-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathBubleSortTest.java
More file actions
50 lines (30 loc) · 1.17 KB
/
BubleSortTest.java
File metadata and controls
50 lines (30 loc) · 1.17 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
38
39
40
41
42
43
44
45
46
47
48
49
50
package sorting;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
public class BubleSortTest {
@Test
@DisplayName("buble sorting with Integers")
public void testSortIntegerArray() {
Integer[] actualArray = new Integer[] { 7, 10, 8, 9, 2, 5, 3, 1, 0, -1, 4 };
BubleSort<Integer[]> bs = new BubleSort<Integer[]>();
bs.set(actualArray);
bs.sort();
String actual = bs.display();
String expected = "[ -1, 0, 1, 2, 3, 4, 5, 7, 8, 9, 10]";
assertEquals(expected, actual, "buble sorting with Integers should work");
System.out.println("Test - Sorting : Buble sort() - passed ok");
}
@Test
@DisplayName("buble sorting with Strings")
public void testSortStringArray() {
String[] actualArray = new String[] { "h", "a", "v", "c", "t", "i", "r" };
BubleSort<String[]> bs = new BubleSort<String[]>();
bs.set(actualArray);
bs.sort();
String actual = bs.display();
String expected = "[ a, c, h, i, r, t, v]";
assertEquals(expected, actual, "buble sorting with Strings should work");
System.out.println("Test - Sorting : Buble sort() - passed ok");
}
}