advent-of-code/tests/aoc_2024/day4/test_part1.py
2024-12-04 15:52:43 +01:00

33 lines
596 B
Python

from pathlib import Path
from aoc_2024.day4 import part1
import numpy as np
def test_find_all():
data_str = """MMMSXXMASM
MSAMXMSMSA
AMXSXMAAMM
MSAMASMSMX
XMASAMXAMM
XXAMMXXAMA
SMSMSASXSS
SAXAMASAAA
MAMMMXMMMM
MXMXAXMASX"""
data = np.full((10, 10), "")
i, j = 0, 0
for character in data_str:
if character != "\n":
data[i, j] = character
j += 1
else:
i += 1
j = 0
assert part1.find_xmas(data) == 18
def test_main():
data_file = Path(__file__).parent / "test-data"
assert part1.main(data_file) == 18