|
9 | 9 | public class _540Test {
|
10 | 10 | private static _540.Solution1 solution1;
|
11 | 11 | private static _540.Solution2 solution2;
|
| 12 | + private static _540.Solution3 solution3; |
12 | 13 | private static int[] nums;
|
| 14 | + private static int expected; |
13 | 15 |
|
14 | 16 | @BeforeClass
|
15 | 17 | public static void setup() {
|
16 | 18 | solution1 = new _540.Solution1();
|
17 | 19 | solution2 = new _540.Solution2();
|
| 20 | + solution3 = new _540.Solution3(); |
18 | 21 | }
|
19 | 22 |
|
20 | 23 | @Test
|
21 | 24 | public void test1() {
|
22 | 25 | nums = new int[]{1, 1, 2, 3, 3, 4, 4, 8, 8};
|
23 |
| - assertEquals(2, solution1.singleNonDuplicate(nums)); |
24 |
| - assertEquals(2, solution2.singleNonDuplicate(nums)); |
| 26 | + expected = 2; |
| 27 | + assertEquals(expected, solution1.singleNonDuplicate(nums)); |
| 28 | + assertEquals(expected, solution2.singleNonDuplicate(nums)); |
| 29 | + assertEquals(expected, solution3.singleNonDuplicate(nums)); |
25 | 30 | }
|
26 | 31 |
|
27 | 32 | @Test
|
28 | 33 | public void test2() {
|
29 | 34 | nums = new int[]{3, 3, 7, 7, 10, 11, 11};
|
30 |
| - assertEquals(10, solution1.singleNonDuplicate(nums)); |
31 |
| - assertEquals(10, solution2.singleNonDuplicate(nums)); |
| 35 | + expected = 10; |
| 36 | + assertEquals(expected, solution1.singleNonDuplicate(nums)); |
| 37 | + assertEquals(expected, solution2.singleNonDuplicate(nums)); |
| 38 | + assertEquals(expected, solution3.singleNonDuplicate(nums)); |
32 | 39 | }
|
33 | 40 |
|
34 | 41 | @Test
|
35 | 42 | public void test3() {
|
36 | 43 | nums = new int[]{1, 1, 2};
|
37 |
| - assertEquals(2, solution1.singleNonDuplicate(nums)); |
38 |
| - assertEquals(2, solution2.singleNonDuplicate(nums)); |
| 44 | + expected = 2; |
| 45 | + assertEquals(expected, solution1.singleNonDuplicate(nums)); |
| 46 | + assertEquals(expected, solution2.singleNonDuplicate(nums)); |
| 47 | + assertEquals(expected, solution3.singleNonDuplicate(nums)); |
| 48 | + } |
| 49 | + |
| 50 | + @Test |
| 51 | + public void test4() { |
| 52 | + nums = new int[]{1, 1, 2, 2, 3}; |
| 53 | + expected = 3; |
| 54 | + assertEquals(expected, solution1.singleNonDuplicate(nums)); |
| 55 | + assertEquals(expected, solution2.singleNonDuplicate(nums)); |
| 56 | + assertEquals(expected, solution3.singleNonDuplicate(nums)); |
39 | 57 | }
|
40 | 58 | }
|
0 commit comments