advent-of-code-2k20/day5/tests.py

28 lines
662 B
Python
Raw Normal View History

2020-12-05 10:49:49 +00:00
#! /usr/bin/env python3
2020-12-06 14:59:57 +00:00
from day5 import *
2020-12-05 10:49:49 +00:00
def tests():
inputs = {
"FBFBBFFRLR": (44, 5, 357),
"BFFFBBFRRR": (70, 7, 567),
"FFFBBBFRRR": (14, 7, 119),
"BBFFBBFRLL": (102, 4, 820)
}
2020-12-06 14:59:57 +00:00
test("bisect", inputs)
test("binary", inputs)
def test(strategy, inputs):
2020-12-05 10:49:49 +00:00
for boarding_pass, expected in inputs.items():
2020-12-06 14:59:57 +00:00
row, col = parse_boarding_pass(boarding_pass, strategy=strategy)
2020-12-05 10:49:49 +00:00
seat_id = get_seat_id(row, col)
assert row == expected[0]
assert col == expected[1]
assert seat_id == expected[2]
print(row, col, seat_id, expected)
if __name__ == "__main__":
tests()