Skip to content

Commit

Permalink
day07: coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-ong committed Dec 27, 2023
1 parent df28d8c commit 7f699f4
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions day07/tests/test_day7.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import pytest

from day07.day7 import INPUT_SMALL, Hand, HandPart2, calculate_hands, parse_lines


Expand All @@ -21,3 +23,29 @@ def test_hand() -> None:
assert hand2 < hand1
assert hand1 > hand2
assert hand1 == hand3

# mypy actually stops us from doing `hand1 < 1`
# So we disable it so we can test our raise,
# in case a dev decides to do the comparison
with pytest.raises(ValueError):
hand1 < 1 # type: ignore[operator]

# here we don't need to disable it, since ruff
# tells us to use __eq__(self, other:object) -> bool:
# This means we do expect people to use hand1 == 6 and
# we want to throw that error
with pytest.raises(ValueError):
hand1 == 6

data = [
("32T3K", 765),
("T55J5", 684),
("KK677", 28),
("KTJJT", 220),
("QQQJA", 483),
("JJJJJ", 483),
]

hands = (HandPart2(cards, bet) for cards, bet in data)
oaks = [hand.calculate_of_a_kind() for hand in hands]
assert [oak[0] for oak in oaks] == [2, 4, 2, 4, 4, 5]

0 comments on commit 7f699f4

Please sign in to comment.