-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDay6Test.java
109 lines (90 loc) · 3.91 KB
/
Day6Test.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
package aoc2018.day06;
import org.junit.jupiter.api.Test;
import java.awt.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class Day6Test {
@Test
public void test_manhattan_distance() {
assertEquals(4, Day6.getManhattanDistance(new Point(0,0), new Point(3,1)));
assertEquals(7, Day6.getManhattanDistance(new Point(0,0), new Point(3,4)));
assertEquals(7, Day6.getManhattanDistance(new Point(3,4), new Point(0,0)));
assertEquals(5, Day6.getManhattanDistance(new Point(3,1), new Point(0,3)));
assertEquals(0, Day6.getManhattanDistance(new Point(3,1), new Point(3,1)));
assertEquals(1, Day6.getManhattanDistance(new Point(0,0), new Point(0,1)));
assertEquals(2, Day6.getManhattanDistance(new Point(0,0), new Point(1,1)));
}
@Test
public void test_get_closest_point(){
ArrayList<Point> coordinateList = new ArrayList<>();
coordinateList.add(new Point(3,1));
coordinateList.add(new Point(3,4));
ArrayList<Point> minimumList = new ArrayList<>();
minimumList.add(new Point(3,1));
assertEquals(minimumList, Day6.getClosestPoint(new Point(0,0), coordinateList));
}
@Test
public void test_get_closest_point_2(){
ArrayList<Point> coordinateList = new ArrayList<>();
coordinateList.add(new Point(3,1));
coordinateList.add(new Point(1,3));
ArrayList<Point> minimumList = new ArrayList<>();
minimumList.add(new Point(3,1));
minimumList.add(new Point(1,3));
assertEquals(minimumList, Day6.getClosestPoint(new Point(0,0), coordinateList));
}
@Test
public void test_get_closest_point_name(){
Map<String, Point> coordinateList = new HashMap<>();
coordinateList.put("1", new Point(3,1));
coordinateList.put("2", new Point(1,3));
assertEquals("1", Day6.getClosestPointName(new Point(3,2), coordinateList));
assertEquals("2", Day6.getClosestPointName(new Point(1,4), coordinateList));
assertEquals(".", Day6.getClosestPointName(new Point(0,0), coordinateList));
assertEquals("1", Day6.getClosestPointName(new Point(3,1), coordinateList));
assertEquals("2", Day6.getClosestPointName(new Point(1,3), coordinateList));
}
@Test
public void test_read_input_file(){
Map map = Day6.readInputFile("src/main/java/aoc2018/day06/assets/in2");
// System.out.println(map);
map = Day6.readInputFile("src/main/java/aoc2018/day06/assets/in1");
// System.out.println(map);
}
@Test
public void test_draw_matrix(){
Map map = Day6.readInputFile("src/main/java/aoc2018/day06/assets/in1");
// Day6.drawMatrix(map);
}
@Test
public void test_get_largest_area(){
Map map = Day6.readInputFile("src/main/java/aoc2018/day06/assets/in1");
// assertEquals(4475, Day6.drawMatrix(map));
map = Day6.readInputFile("src/main/java/aoc2018/day06/assets/in4");
// assertEquals(17, Day6.drawMatrix(map));
}
@Test
public void test_get_manhattan_distance_sum() {
Map map = Day6.readInputFile("src/main/java/aoc2018/day06/assets/in4");
assertEquals(30, Day6.getManhattanDistanceSum(new Point(4,3), map));
}
@Test
public void test_compute_area() {
Map map = Day6.readInputFile("src/main/java/aoc2018/day06/assets/in4");
assertEquals(16, Day6.computeArea(map, 32));
map = Day6.readInputFile("src/main/java/aoc2018/day06/assets/in1");
assertEquals(35237, Day6.computeArea(map, 10000));
}
@Test
public void test_fib(){
assertEquals(1, Day6.fib(0));
assertEquals(1, Day6.fib(1));
assertEquals(2, Day6.fib(2));
assertEquals(3, Day6.fib(3));
assertEquals(5, Day6.fib(4));
assertEquals(8, Day6.fib(5));
assertEquals(13, Day6.fib(6));
}
}