-
Notifications
You must be signed in to change notification settings - Fork 0
/
WindowsTest.java
77 lines (69 loc) · 1.72 KB
/
WindowsTest.java
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
package MathProbGene;
import java.util.Random;
import static org.junit.Assert.*;
import org.junit.Test;
public class WindowsTest {
static long lCurrenTime = System.currentTimeMillis();
private static Random Rand = new Random(lCurrenTime);
private static int intRand(int min,int max){
return min + Rand.nextInt( max - min + 1 );
}
private static int[] arrRand(){
int[] res = new int[6];
for(int i=0;i<6;++i)
res[i] = intRand(1, 100);
return res;
}
private static boolean[] brrRand(){
boolean[] res = new boolean[8];
for(int i=0;i<8;++i)
res[i] = Rand.nextBoolean();
return res;
}
@Test
public void testOnce() {
int[] arr = arrRand();
boolean[] brr = brrRand();
assertEquals( true, new Windows().Start(arr,brr));
}
@Test
public void testMore() {
int[] arr = arrRand();
boolean[] brr = brrRand();
for(int i=0;i<128;++i){
for(int j=i,k=0;k<8;j/=2,k++)
brr[k]=( j % 2 == 0 ? false : true );
assertEquals( true, new Windows().Start(arr,brr));
}
}
@Test
public void testNegative0() {
for(int i=0;i<128;++i){
int[] arr = arrRand();
boolean[] brr = brrRand();
arr[2] = -arr[2];
arr[3] = arr[3];
assertEquals( true, new Windows().Start(arr,brr));
}
}
@Test
public void testNegative1() {
for(int i=0;i<128;++i){
int[] arr = arrRand();
boolean[] brr = brrRand();
arr[2] = -arr[2];
arr[3] = -arr[3];
assertEquals( true, new Windows().Start(arr,brr));
}
}
@Test
public void testNegative2() {
for(int i=0;i<128;++i){
int[] arr = arrRand();
boolean[] brr = brrRand();
arr[2] = arr[2];
arr[3] = -arr[3];
assertEquals( true, new Windows().Start(arr,brr));
}
}
}