|
1 | 1 | package com.fishercoder;
|
2 | 2 |
|
3 |
| -import com.fishercoder.common.utils.CommonUtils; |
4 | 3 | import com.fishercoder.solutions._189;
|
5 | 4 | import org.junit.BeforeClass;
|
6 | 5 | import org.junit.Test;
|
7 | 6 |
|
| 7 | +import static org.junit.Assert.assertArrayEquals; |
| 8 | + |
8 | 9 | public class _189Test {
|
9 | 10 | private static _189.Solution1 solution1;
|
10 | 11 | private static _189.Solution2 solution2;
|
11 | 12 | private static _189.Solution3 solution3;
|
| 13 | + private static _189.Solution4 solution4; |
12 | 14 | private static int[] nums;
|
13 | 15 |
|
14 | 16 | @BeforeClass
|
15 | 17 | public static void setup() {
|
16 | 18 | solution1 = new _189.Solution1();
|
17 | 19 | solution2 = new _189.Solution2();
|
18 | 20 | solution3 = new _189.Solution3();
|
| 21 | + solution4 = new _189.Solution4(); |
19 | 22 | }
|
20 | 23 |
|
21 | 24 | @Test
|
22 | 25 | public void test1() {
|
23 | 26 | nums = new int[]{1, 2, 3};
|
24 | 27 | solution1.rotate(nums, 1);
|
25 |
| - CommonUtils.printArray(nums); |
| 28 | + assertArrayEquals(new int[]{3, 1, 2}, nums); |
26 | 29 | }
|
27 | 30 |
|
28 | 31 | @Test
|
29 | 32 | public void test2() {
|
30 | 33 | nums = new int[]{1, 2, 3};
|
31 | 34 | solution2.rotate(nums, 1);
|
32 |
| - CommonUtils.printArray(nums); |
| 35 | + assertArrayEquals(new int[]{3, 1, 2}, nums); |
33 | 36 | }
|
34 | 37 |
|
35 | 38 | @Test
|
36 | 39 | public void test3() {
|
37 | 40 | nums = new int[]{1, 2, 3};
|
38 | 41 | solution3.rotate(nums, 1);
|
39 |
| - CommonUtils.printArray(nums); |
| 42 | + assertArrayEquals(new int[]{3, 1, 2}, nums); |
| 43 | + } |
| 44 | + |
| 45 | + @Test |
| 46 | + public void test4() { |
| 47 | + nums = new int[]{1, 2, 3}; |
| 48 | + solution4.rotate(nums, 1); |
| 49 | + assertArrayEquals(new int[]{3, 1, 2}, nums); |
| 50 | + } |
| 51 | + |
| 52 | + @Test |
| 53 | + public void test5() { |
| 54 | + nums = new int[]{-1, -100, 3, 99}; |
| 55 | + solution4.rotate(nums, 2); |
| 56 | + assertArrayEquals(new int[]{3, 99, -1, -100}, nums); |
40 | 57 | }
|
41 | 58 |
|
42 | 59 | }
|
0 commit comments