-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestSelectionSort.java
More file actions
103 lines (89 loc) · 2.32 KB
/
Copy pathtestSelectionSort.java
File metadata and controls
103 lines (89 loc) · 2.32 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*
* testSelectionSort.java
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
import static org.junit.Assert.*;
import org.junit.Assert;
import org.junit.Test;
public class testSelectionSort {
@Test
public void test() {
testPositive();
testNegative();
testMixed();
testDuplicates();
}
public testSelectionSort() {
}
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 temp1 = new SelectionSort();
arr = temp1.basicSelectionSort(arr);
assertEquals("Wrong!!", Sortedarr, arr);
/** add tests to check for this unit test **/
}
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 temp1 = new SelectionSort();
int sorted[] = temp1.basicSelectionSort(arr);
assertEquals("Wrong!!", Sortedarr, sorted);
}
public void testDuplicates(){
int[] arr = new int[5];
arr[0] = 8;
arr[1] = 8;
arr[2] = 2;
arr[3] = 7;
arr[4] = 2;
int[] Sortedarr = new int[5];
Sortedarr[0] = 2;
Sortedarr[1] = 2;
Sortedarr[2] = 8;
Sortedarr[3] = 8;
Sortedarr[4] = 9;
}
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 temp1 = new SelectionSort();
int[] sorted = temp1.basicSelectionSort(arr);
assertEquals("Wrong!!", Sortedarr, sorted);
/** Test data contains with both positive, negative and zeros **/
}
}