|
1 | 1 | package com.fishercoder;
|
2 | 2 |
|
3 |
| -import com.fishercoder.common.classes.Interval; |
4 | 3 | import com.fishercoder.solutions._56;
|
5 |
| -import java.util.ArrayList; |
6 |
| -import java.util.List; |
7 | 4 | import org.junit.BeforeClass;
|
8 | 5 | import org.junit.Test;
|
9 | 6 |
|
10 | 7 | import static org.junit.Assert.assertEquals;
|
11 | 8 |
|
12 | 9 | public class _56Test {
|
13 |
| - private static _56.Solution1 solution1; |
14 |
| - private static List<Interval> intervals; |
15 |
| - private static List<Interval> expected; |
| 10 | + private static _56.Solution1 solution1; |
| 11 | + private static int[][] intervals; |
| 12 | + private static int[][] expected; |
| 13 | + |
| 14 | + @BeforeClass |
| 15 | + public static void setup() { |
| 16 | + solution1 = new _56.Solution1(); |
| 17 | + } |
| 18 | + |
| 19 | + @Test |
| 20 | + public void test1() { |
| 21 | + intervals = new int[][]{ |
| 22 | + {2, 3}, |
| 23 | + {5, 5}, |
| 24 | + {2, 2}, |
| 25 | + {3, 4}, |
| 26 | + {3, 4} |
| 27 | + }; |
| 28 | + expected = new int[][]{ |
| 29 | + {2, 4}, |
| 30 | + {5, 5} |
| 31 | + }; |
| 32 | + assertEquals(expected, solution1.merge(intervals)); |
| 33 | + } |
16 | 34 |
|
17 |
| - @BeforeClass |
18 |
| - public static void setup() { |
19 |
| - solution1 = new _56.Solution1(); |
20 |
| - } |
21 |
| - |
22 |
| - @Test |
23 |
| - public void test1() { |
24 |
| - intervals = new ArrayList(); |
25 |
| - intervals.add(new Interval(2, 3)); |
26 |
| - intervals.add(new Interval(5, 5)); |
27 |
| - intervals.add(new Interval(2, 2)); |
28 |
| - intervals.add(new Interval(3, 4)); |
29 |
| - intervals.add(new Interval(3, 4)); |
30 |
| - |
31 |
| - expected = new ArrayList<>(); |
32 |
| - expected.add(new Interval(2, 4)); |
33 |
| - expected.add(new Interval(5, 5)); |
34 |
| - assertEquals(expected, solution1.merge(intervals)); |
35 |
| - } |
36 |
| - |
37 |
| - @Test |
38 |
| - public void test2() { |
39 |
| - intervals = new ArrayList(); |
40 |
| - intervals.add(new Interval(1, 3)); |
41 |
| - intervals.add(new Interval(2, 6)); |
42 |
| - intervals.add(new Interval(8, 10)); |
43 |
| - intervals.add(new Interval(15, 18)); |
44 |
| - |
45 |
| - expected = new ArrayList<>(); |
46 |
| - expected.add(new Interval(1, 6)); |
47 |
| - expected.add(new Interval(8, 10)); |
48 |
| - expected.add(new Interval(15, 18)); |
49 |
| - assertEquals(expected, solution1.merge(intervals)); |
50 |
| - } |
51 | 35 | }
|
0 commit comments