-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMySorterTest.java
More file actions
82 lines (69 loc) · 1.81 KB
/
MySorterTest.java
File metadata and controls
82 lines (69 loc) · 1.81 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
package ntou.cs.sorter;
import static org.junit.Assert.*;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
public class MySorterTest
{
private MySorter sorter;
private double tc1[][] = { {}, {} };
private double tc2[][] = { { 1.0 }, { 1.0 } };
private double tc3[][] = { { 1.0, 1.1, 2.0, 2.1, 10.10, 100 },{ 1.0, 1.1, 2.0, 2.1, 10.10, 100 } };
private double tc4[][] = { { 100, 10.10, 2.1, 2.0, 1.1, 1.0 },{ 1.0, 1.1, 2.0, 2.1, 10.10, 100 } };
private double tc5[][] = { { 2.0, 2.1, 1.1, 10.10, 100, 1.0 },{ 1.0, 1.1, 2.0, 2.1, 10.10, 100 } };
private double tc6[][] = { { 1, 2, 5, 4, 3 }, { 1, 2, 3, 4, 5 } };
private double tc7[][] = { { 1, 2, -99 }, {1, 2,-99} };
private void assertArrayEquals (double[] expected, double[] actual)
{
assertEquals(expected.length, actual.length);
for (int i = 0; i < expected.length; i++)
{
assertEquals(expected[i], actual[i], 0.0001);
}
}
@Before
public void setUp() throws Exception {
sorter = new MySorter();
}
@After
public void tearDown() throws Exception {
sorter = null;
}
@Test
public void testsort1() {
sorter.sort(tc1[0]);
assertArrayEquals(tc1[0], tc1[1]);
}
@Test
public void testsort2() {
sorter.sort(tc2[0]);
assertArrayEquals(tc2[0], tc2[1]);
}
@Test
public void testsort3() {
sorter.sort(tc3[0]);
assertArrayEquals(tc3[0], tc3[1]);
}
@Test
public void testsort4() {
sorter.sort(tc4[0]);
assertArrayEquals(tc4[0], tc4[1]);
}
@Test
public void testsort5() {
sorter.sort(tc5[0]);
assertArrayEquals(tc5[0], tc5[1]);
}
@Test
public void testsort6() {
sorter.sort(tc6[0]);
assertArrayEquals(tc6[0], tc6[1]);
}
@Test
public void testsort7() {
sorter.sort(tc7[0]);
assertArrayEquals(tc7[0], tc7[1]);
}
}