forked from fishercoder1534/Leetcode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_201Test.java
71 lines (63 loc) · 1.81 KB
/
_201Test.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
package com.fishercoder;
import com.fishercoder.solutions._201;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
/**
* Created by fishercoder on 5/3/17.
*/
public class _201Test {
private static _201 test;
private static int m;
private static int n;
private static int actual;
private static int expected;
@BeforeClass
public static void setup(){
test = new _201();
}
@Test
public void test1(){
m = 5;
n = 7;
actual = test.rangeBitwiseAnd_TLE(m, n);
expected = 4;
assertEquals(expected, actual);
actual = test.rangeBitwiseAnd(m, n);
assertEquals(expected, actual);
}
@Test
public void test2(){
m = 1;
n = 2;
actual = test.rangeBitwiseAnd_TLE(m, n);
expected = 0;
assertEquals(expected, actual);
actual = test.rangeBitwiseAnd(m, n);
assertEquals(expected, actual);
}
@Test
public void test3(){
m = 0;
n = 2147483647;
long start = System.currentTimeMillis();
actual = test.rangeBitwiseAnd_TLE(m, n);
System.out.println("It took " + (System.currentTimeMillis() - start) + " ms to finish.");
expected = 0;
assertEquals(expected, actual);
actual = test.rangeBitwiseAnd(m, n);
assertEquals(expected, actual);
}
@Test
public void test4(){
m = 20000;
n = 2147483647;
long start = System.currentTimeMillis();
// actual = test.rangeBitwiseAnd_TLE(m, n);
System.out.println("It took " + (System.currentTimeMillis() - start) + " ms to finish.");
expected = 0;
assertEquals(expected, actual);
actual = test.rangeBitwiseAnd(m, n);
assertEquals(expected, actual);
}
}