|
1 | 1 | packagecom.fishercoder; |
2 | 2 |
|
| 3 | +importcom.fishercoder.common.utils.CommonUtils; |
3 | 4 | importcom.fishercoder.solutions._970; |
| 5 | + |
4 | 6 | importjava.util.Arrays; |
5 | 7 | importjava.util.Collections; |
6 | 8 | importjava.util.List; |
| 9 | + |
7 | 10 | importorg.junit.BeforeClass; |
8 | 11 | importorg.junit.Test; |
9 | 12 |
|
10 | 13 | importstaticorg.junit.Assert.assertEquals; |
11 | 14 |
|
12 | 15 | publicclass_970Test { |
13 | | -privatestatic_970.Solution1solution1; |
14 | | -privatestatic_970.Solution2solution2; |
15 | | - |
16 | | -@BeforeClass |
17 | | -publicstaticvoidsetup() { |
18 | | -solution1 =new_970.Solution1(); |
19 | | -solution2 =new_970.Solution2(); |
20 | | - } |
21 | | - |
22 | | -@Test |
23 | | -publicvoidtest1() { |
24 | | -assertEquals(Arrays.asList(2,3,4,5,7,9,10),solution1.powerfulIntegers(2,3,10)); |
25 | | -assertEquals(Arrays.asList(2,3,4,5,7,9,10),solution2.powerfulIntegers(2,3,10)); |
26 | | - } |
27 | | - |
28 | | -@Test |
29 | | -publicvoidtest2() { |
30 | | -assertEquals(Arrays.asList(2,4,6,8,10,14),solution1.powerfulIntegers(3,5,15)); |
31 | | -assertEquals(Arrays.asList(2,4,6,8,10,14),solution2.powerfulIntegers(3,5,15)); |
32 | | - } |
33 | | - |
34 | | -@Test |
35 | | -publicvoidtest3() { |
36 | | -assertEquals(Arrays.asList(2,3,5,7,8,9,10),solution1.powerfulIntegers(2,6,12)); |
37 | | -assertEquals(Arrays.asList(2,3,5,7,8,9,10),solution2.powerfulIntegers(2,6,12)); |
38 | | - } |
39 | | - |
40 | | -@Test |
41 | | -publicvoidtest4() { |
42 | | -assertEquals(Arrays.asList(2,3,5,9,10,11),solution1.powerfulIntegers(2,9,12)); |
43 | | -assertEquals(Arrays.asList(2,3,5,9,10,11),solution2.powerfulIntegers(2,9,12)); |
44 | | - } |
45 | | - |
46 | | -@Test |
47 | | -publicvoidtest5() { |
48 | | -assertEquals(Arrays.asList(2,91,180,8101,8190,16200,729001,729090, |
49 | | -737100),solution1.powerfulIntegers(90,90,1000000)); |
50 | | -List<Integer>actual =solution2.powerfulIntegers(90,90,1000000); |
51 | | -Collections.sort(actual); |
52 | | -assertEquals(Arrays.asList(2,91,180,8101,8190,16200,729001,729090, |
53 | | -737100),actual); |
54 | | - } |
| 16 | +privatestatic_970.Solution1solution1; |
| 17 | +privatestatic_970.Solution2solution2; |
| 18 | + |
| 19 | +@BeforeClass |
| 20 | +publicstaticvoidsetup() { |
| 21 | +solution1 =new_970.Solution1(); |
| 22 | +solution2 =new_970.Solution2(); |
| 23 | + } |
| 24 | + |
| 25 | +@Test |
| 26 | +publicvoidtest1() { |
| 27 | +assertEquals(Arrays.asList(2,3,4,5,7,9,10),solution1.powerfulIntegers(2,3,10)); |
| 28 | +assertEquals(Arrays.asList(2,3,4,5,7,9,10),solution2.powerfulIntegers(2,3,10)); |
| 29 | + } |
| 30 | + |
| 31 | +@Test |
| 32 | +publicvoidtest2() { |
| 33 | +assertEquals(Arrays.asList(2,4,6,8,10,14),solution1.powerfulIntegers(3,5,15)); |
| 34 | +assertEquals(Arrays.asList(2,4,6,8,10,14),solution2.powerfulIntegers(3,5,15)); |
| 35 | + } |
| 36 | + |
| 37 | +@Test |
| 38 | +publicvoidtest3() { |
| 39 | +assertEquals(Arrays.asList(2,3,5,7,8,9,10),solution1.powerfulIntegers(2,6,12)); |
| 40 | +assertEquals(Arrays.asList(2,3,5,7,8,9,10),solution2.powerfulIntegers(2,6,12)); |
| 41 | + } |
| 42 | + |
| 43 | +@Test |
| 44 | +publicvoidtest4() { |
| 45 | +assertEquals(Arrays.asList(2,3,5,9,10,11),solution1.powerfulIntegers(2,9,12)); |
| 46 | +assertEquals(Arrays.asList(2,3,5,9,10,11),solution2.powerfulIntegers(2,9,12)); |
| 47 | + } |
| 48 | + |
| 49 | +@Test |
| 50 | +publicvoidtest5() { |
| 51 | +CommonUtils.printList(solution1.powerfulIntegers(90,90,1000000)); |
| 52 | +CommonUtils.printList(solution2.powerfulIntegers(90,90,1000000)); |
| 53 | + } |
| 54 | + |
| 55 | +@Test |
| 56 | +publicvoidtest6() { |
| 57 | +assertEquals(Arrays.asList(2),solution1.powerfulIntegers(1,1,40000)); |
| 58 | +assertEquals(Arrays.asList(2),solution2.powerfulIntegers(1,1,40000)); |
| 59 | + } |
55 | 60 | } |