-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestSelectionSort.java
More file actions
38 lines (32 loc) · 1.19 KB
/
testSelectionSort.java
File metadata and controls
38 lines (32 loc) · 1.19 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
package FinalExam;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import org.junit.jupiter.api.Test;
public class testSelectionSort {
@Test
public void test() {
testPositive();
testNegative();
testMixed();
}
public void testPositive() {
int[] arr = {8, 9, 7, 10, 2};
SelectionSort sorter = new SelectionSort();
sorter.selectionSort(arr); // fix: call selectionSort instead of basicSelectionSort
int[] expectedArr = {2, 7, 8, 9, 10};
assertArrayEquals(expectedArr, arr);
}
public void testNegative() {
int[] arr = {-5, -10, -3, -1, -8};
SelectionSort sorter = new SelectionSort();
sorter.selectionSort(arr); // fix: call selectionSort instead of basicSelectionSort
int[] expectedArr = {-10, -8, -5, -3, -1};
assertArrayEquals(expectedArr, arr);
}
public void testMixed() {
int[] arr = {-5, 10, 0, -1, 3};
SelectionSort sorter = new SelectionSort();
sorter.selectionSort(arr); // fix: call selectionSort instead of basicSelectionSort
int[] expectedArr = {-5, -1, 0, 3, 10};
assertArrayEquals(expectedArr, arr);
}
}