-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestSelectionSort.java
More file actions
76 lines (60 loc) · 1.48 KB
/
Copy pathtestSelectionSort.java
File metadata and controls
76 lines (60 loc) · 1.48 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import static org.junit.Assert.*;
import org.junit.Test;
public class testSelectionSort {
@Test
public void test() {
//testPositive();
testNegative();
//testMixed();
}
public testSelectionSort() {
}
public void testPositive(){
int[] arr = new int[5];
arr[0] = 8;
arr[1] = 9;
arr[2] = 7;
arr[3] = 10;
arr[4] = 2;
int[] Sortedarr = new int[5];
Sortedarr[0] = 2;
Sortedarr[1] = 7;
Sortedarr[2] = 8;
Sortedarr[3] = 9;
Sortedarr[4] = 10;
selectionSort.sort(arr);
assertArrayEquals("Wrong!!", Sortedarr, arr);
}
public void testNegative(){
int[] arr = new int[5];
arr[0] = -8;
arr[1] = -9;
arr[2] = -7;
arr[3] = -10;
arr[4] = -2;
int[] Sortedarr = new int[5];
Sortedarr[0] = -10;
Sortedarr[1] = -9;
Sortedarr[2] = -8;
Sortedarr[3] = -7;
Sortedarr[4] = -2;
selectionSort.sort(arr);
assertArrayEquals("Wrong!!", Sortedarr, arr);
}
public void testMixed(){
int[] arr = new int[5];
arr[0] = 8;
arr[1] = -9;
arr[2] = -7;
arr[3] = 10;
arr[4] = 0;
int[] Sortedarr = new int[5];
Sortedarr[0] = -9;
Sortedarr[1] = -7;
Sortedarr[2] = 0;
Sortedarr[3] = 8;
Sortedarr[4] = 10;
selectionSort.sort(arr);
assertArrayEquals("Wrong!!", Sortedarr, arr);
}
}