def test_load_input(): """Test the load_input function""" processed_input = load_input("input.txt") assert processed_input[:2] == [ ("1001X0X00110011X01X1000110100011000X", 5228, 409649), ("1001X0X00110011X01X1000110100011000X", 64037, 474625), ]
def test_load_input(): expected_algorithm = "..#.#..#####.#.#.#.###.##.....###.##.#..###.####..#####..#....#..#..##..###..######.###...####..#..#####..##..#.#####...##.#.#..#.##..#.#......#.###.######.###.####...#.##.##..#..#..#####.....#.#....###..#.##......#.....#..#..#..##..#...##.######.####.####.#.#...#.......#..#.#.#...####.##.#......#..#...##.#.##..#...##.#.##..###.#......#.#.......#.#.#.####.###.##...#.....####.#..#..#.##.#....##..#.####....##...##..#...#......#.#.......#.......##..####..#...#.#.#...##..#.#..###..#####........#..####......#..#" expected_image = [ ["#", ".", ".", "#", "."], ["#", ".", ".", ".", "."], ["#", "#", ".", ".", "#"], [".", ".", "#", ".", "."], [".", ".", "#", "#", "#"], ] actual_algorithm, actual_image = load_input("sample_input.txt") assert actual_algorithm == expected_algorithm assert actual_image == expected_image
def test_load_input(): """Test load input function""" # fmt: off assert load_input("test_input.txt") == ( { "class": {1, 2, 3, 5, 6, 7}, "row": { 6, 7, 8, 9, 10, 11, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44 }, "seat": { 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, 45, 46, 47, 48, 49, 50, }, }, [7, 1, 14], [[7, 3, 47], [40, 4, 50], [55, 2, 20], [38, 6, 12]], )
def test_load_input(): expected = [ { (404, -588, -901), (528, -643, 409), (-838, 591, 734), }, { (686, 422, 578), (605, 423, 415), (515, 917, -361), }, { (649, 640, 665), (682, -795, 504), (-784, 533, -524), }, ] actual = load_input("loading_sample.txt") assert actual == expected
def test_input(): """Load the test input for testing""" return load_input("test_input.txt")
"""Day 19 tests""" from solution import load_input, part1 test_rules, test_msgs = load_input("test_input.txt") def test_part1(rules=test_rules, msgs=test_msgs, expected=2): """Test part1 function""" assert part1(rules, msgs) == expected
def test_find_max_scanner_distance(): scanners = load_input("sample_input.txt") _, scanner_locations = merge_scanners_lazy(scanners) assert find_max_scanner_distance(scanner_locations) == 3621
def test_merge_scanners_lazy_scanner_locations(): scanners = load_input("sample_input.txt") _, scanner_locations = merge_scanners_lazy(scanners) assert scanner_locations[0] == (0, 0, 0) assert scanner_locations[2] == (1105, -1205, 1229) assert scanner_locations[3] == (-92, -2380, -20)
def test_merge_scanners_lazy_merged_point(): scanners = load_input("sample_input.txt") merged, _ = merge_scanners_lazy(scanners) assert len(merged) == 79
def test_try_match_scanner_pair_from_sample(a, b): scanners = load_input("sample_input.txt") assert _try_match_scanner_pair(scanners[a], scanners[b])
def test_find_overlapping_pairs(): scanners = load_input("sample_input.txt") pairs = _find_overlapping_pairs(scanners) assert len(pairs) >= len(scanners) - 1
def test_full(): expected_lit = 35 algorithm, image = load_input("sample_input.txt") end_image = apply_algorithm_n(algorithm, image, 2) actual_lit = count_lit_pixels(end_image) assert actual_lit == expected_lit