def test_part_two(self): "Test part two example of Folding object" # 1. Create Folding object from text myobj = folding.Folding(part2=True, text=aoc_13.from_text(PART_TWO_TEXT)) # 2. Check the part two result self.assertEqual(myobj.part_two(verbose=False), PART_TWO_RESULT)
def test_part_one(self): "Test part one example of Folding object" # 1. Create Folding object from text myobj = folding.Folding(text=aoc_13.from_text(PART_ONE_TEXT)) # 2. Check the part one result self.assertEqual(myobj.part_one(verbose=False), PART_ONE_RESULT)
def test_text_init(self): "Test the Buses object creation from text" # 1. Create Buses object from text myobj = buses.Buses(text=aoc_13.from_text(EXAMPLE_TEXT)) # 2. Make sure it has the expected values self.assertEqual(myobj.part2, False) self.assertEqual(len(myobj.text), 2) self.assertEqual(myobj.earliest, 939) self.assertEqual(len(myobj.buses), 5)
def test_text_init(self): "Test the Seating object creation from text" # 1. Create Seating object from text myobj = seating.Seating(text=aoc_13.from_text(EXAMPLE_TEXT)) # 2. Make sure it has the expected values self.assertEqual(myobj.part2, False) self.assertEqual(len(myobj.text), 12) self.assertEqual(len(myobj.people), 4) self.assertEqual(len(myobj.preferences), 12)
def test_part_two_mod(self): """Test the part two example with modulo""" # 1. Create default Pipes object myfw = firewall.Firewall(part2=True, text=aoc_13.from_text(EXAMPLE_TEXT)) # 2. Make sure it has the specified values self.assertEqual(myfw.part2, True) self.assertEqual(len(myfw.levels), 4) self.assertEqual(myfw.picosecond, 0) self.assertEqual(myfw.final, 6) # 3. Test the trip methos self.assertEqual(myfw.part_two_mod(verbose=False, limit=20), 10)
def test_part_one(self): """Test the part one example""" # 1. Create default Pipes object myfw = firewall.Firewall(text=aoc_13.from_text(EXAMPLE_TEXT)) # 2. Make sure it has the specified values self.assertEqual(myfw.part2, False) self.assertEqual(len(myfw.levels), 4) self.assertEqual(myfw.picosecond, 0) self.assertEqual(myfw.final, 6) # 3. Test the trip methos self.assertEqual(myfw.trip(verbose=False), 24)
def test_text_init_two(self): "Test the Folding object creation from text for part 2" # 1. Create Folding object from text myobj = folding.Folding(text=aoc_13.from_text(EXAMPLE_TEXT), part2=True) # 2. Make sure it has the expected values self.assertEqual(myobj.part2, True) self.assertEqual(len(myobj.text), 20) self.assertEqual(len(myobj.dots), 18) self.assertEqual(len(myobj.instructions), 2) self.assertEqual(myobj.instructions[0], ('y', 7)) self.assertEqual(myobj.instructions[1], ('x', 5)) # 3. Check methods self.assertEqual(myobj.fold_all(), 16) self.assertEqual(PART_TWO_IMAGE.strip(), str(myobj))
def test_text_init(self): "Test the Folding object creation from text" # 1. Create Folding object from text myobj = folding.Folding(text=aoc_13.from_text(EXAMPLE_TEXT)) # 2. Make sure it has the expected values self.assertEqual(myobj.part2, False) self.assertEqual(len(myobj.text), 20) self.assertEqual(len(myobj.dots), 18) self.assertEqual(len(myobj.instructions), 2) self.assertEqual(myobj.instructions[0], ('y', 7)) self.assertEqual(myobj.instructions[1], ('x', 5)) # 3. Check methods self.assertEqual(myobj.fold_up(7), 17) self.assertEqual(myobj.fold_left(5), 16)
def test_text_init(self): """Test firewall creation from text""" # 1. Create default Pipes object myfw = firewall.Firewall(text=aoc_13.from_text(EXAMPLE_TEXT)) # 2. Make sure it has the specified values self.assertEqual(myfw.part2, False) self.assertEqual(len(myfw.levels), 4) self.assertEqual(myfw.picosecond, 0) self.assertEqual(myfw.final, 6) self.assertEqual(myfw.levels[0].level, 0) self.assertEqual(myfw.levels[0].depth, 3) self.assertEqual(myfw.levels[0].position, 0) self.assertEqual(myfw.levels[0].direction, 1) self.assertEqual(myfw.levels[1].depth, 2) self.assertEqual(myfw.levels[4].depth, 4) self.assertEqual(myfw.levels[6].depth, 4) # 3. Test advance method myfw.advance() self.assertEqual(myfw.levels[0].position, 1) self.assertEqual(myfw.levels[1].position, 1) self.assertEqual(myfw.levels[4].position, 1) self.assertEqual(myfw.levels[6].position, 1) self.assertEqual(myfw.picosecond, 1) myfw.advance() self.assertEqual(myfw.levels[0].position, 2) self.assertEqual(myfw.levels[1].position, 0) self.assertEqual(myfw.levels[4].position, 2) self.assertEqual(myfw.levels[6].position, 2) self.assertEqual(myfw.picosecond, 2) myfw.advance() self.assertEqual(myfw.levels[0].position, 1) self.assertEqual(myfw.levels[1].position, 1) self.assertEqual(myfw.levels[4].position, 3) self.assertEqual(myfw.levels[6].position, 3) self.assertEqual(myfw.picosecond, 3)
def test_text_init(self): "Test the Cubicles object creation from text" # 1. Create Cubicles object from text myobj = cubicles.Cubicles(text=aoc_13.from_text(EXAMPLE_TEXT)) # 2. Make sure it has the expected values self.assertEqual(myobj.part2, False) self.assertEqual(len(myobj.text), 1) self.assertEqual(len(myobj.maze), 1) self.assertEqual(myobj.number, 10) # 3. Check methods self.assertEqual(myobj.which(0, 0), cubicles.OPEN) self.assertEqual(myobj.which(1, 1), cubicles.OPEN) self.assertEqual(len(myobj.maze), 2) self.assertEqual(myobj.which(-1, 0), cubicles.WALL) self.assertEqual(myobj.which(12, -34), cubicles.WALL) self.assertEqual(len(myobj.maze), 2) self.assertEqual(myobj.which(2, 0), cubicles.OPEN) self.assertEqual(myobj.which(6, 1), cubicles.OPEN) self.assertEqual(myobj.which(5, 3), cubicles.OPEN) self.assertEqual(myobj.which(1, 6), cubicles.OPEN) self.assertEqual(len(myobj.maze), 6) self.assertEqual(myobj.which(1, 6), cubicles.OPEN) self.assertEqual(len(myobj.maze), 6) self.assertEqual(myobj.which(9, 0), cubicles.WALL) self.assertEqual(myobj.which(5, 1), cubicles.WALL) self.assertEqual(myobj.which(4, 3), cubicles.WALL) self.assertEqual(myobj.which(0, 6), cubicles.WALL) self.assertEqual(len(myobj.maze), 10) self.assertEqual(myobj.directions(1, 1), [(1, 2), (0, 1)]) self.assertEqual(myobj.directions(5, 3), []) self.assertEqual(myobj.directions(3, 2), [(4, 2), (3, 3), (2, 2), (3, 1)]) self.assertEqual(myobj.shortest(0, 0), 2) self.assertEqual(myobj.shortest(7, 4), 11)