def test_intersection2(self): pathPositionsWire1 = {Position(0, 0), Position(1, 0)} pathPositionsWire2 = {Position(2, 0), Position(1, 0)} expectedPathPositions = {Position(1, 0)} self.assertEqual(expectedPathPositions, day3.intersections(pathPositionsWire1, pathPositionsWire2))
def test_getDistanceOfClosestIntersection(self): centralPortPosition = Position(0, 0) wireCrossPosition1 = Position(5, 5) wireCrossPosition2 = Position(3, 3) wireCrossPosition3 = Position(4, 4) distanceExpected = 6 self.assertEqual(distanceExpected, day3.getDistanceOfClosestIntersection(centralPortPosition, [wireCrossPosition1,wireCrossPosition2, wireCrossPosition3]) )
def test_getAllPositionsOnPath(self): path = "R2,L1" centralPosition = Position(0, 0) positionsOnPathExpected = list([Position(1, 0), Position(2, 0), Position(1, 0)]) positionsOnPath = day3.getAllPositionsOnPath(centralPosition, path) self.assertEqual(positionsOnPathExpected, positionsOnPath)
def test_getPositionsOnPath(self): path = "R1,U1,L1" centralPosition = Position(0,0) positionsOnPathExpected = {Position(1,0), Position(1,1), Position(0,1)} positionsOnPath = day3.getPositionsOnPath(centralPosition, path) self.assertEqual(positionsOnPathExpected, positionsOnPath)
def test_consolidatePositions(self): pathPositions = {Position(0, 0), Position(1, 0)} sectionPostions = [Position(2, 0), Position(1, 0)] expectedPathPositions = {Position(0, 0), Position(1, 0), Position(2, 0)} self.assertEqual(expectedPathPositions, day3.consolidatePositions(pathPositions, sectionPostions))
def test_computeManhattanDistance(self): centralPortPosition = Position(0, 0) wireCrossPosition = Position(3, 3) distanceExpected = 6 self.assertEqual(distanceExpected, day3.computeManhattanDistance(centralPortPosition, wireCrossPosition))
def test_getPositionsOnSection_distance_2_to_down(self): section = "D2" initialPostion = Position(0, 0) expectedPositions = [Position(0, -1), Position(0, -2)] positionsOnSection = day3.getPositionsOnSection(initialPostion, section) self.assertEqual(expectedPositions, positionsOnSection)
def test_getPositionsOnSection_distance_2_to_left(self): section = "L2" initialPostion = Position(0, 0) expectedPositions = [Position(-1, 0), Position(-2, 0)] positionsOnSection = day3.getPositionsOnSection(initialPostion, section) self.assertEqual(expectedPositions, positionsOnSection)
def test_getPositionsOnSection_distance_3(self): section = "R3" initialPostion = Position(0, 0) expectedPositions = [Position(1, 0), Position(2,0), Position(3,0)] positionsOnSection = day3.getPositionsOnSection(initialPostion, section) self.assertEqual(expectedPositions, positionsOnSection)
def test_getPositionsOnSection(self): section = "R1" initialPostion= Position(0, 0) expectedPositions = [Position(1, 0)] positionsOnSection = day3.getPositionsOnSection(initialPostion, section) self.assertEqual(expectedPositions, positionsOnSection)