day02 finished
This commit is contained in:
parent
86dab16b47
commit
656df6deb6
5 changed files with 2743 additions and 0 deletions
45
advent/days/day02/test_solution.py
Normal file
45
advent/days/day02/test_solution.py
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
from advent.common import utils
|
||||
|
||||
from .solution import day_num, part1, part2, Shape, Result
|
||||
|
||||
|
||||
def test_part1():
|
||||
data = utils.read_data(day_num, 'test01.txt')
|
||||
expected = 15
|
||||
result = part1(data)
|
||||
assert result == expected
|
||||
|
||||
|
||||
def test_part2():
|
||||
data = utils.read_data(day_num, 'test01.txt')
|
||||
expected = 12
|
||||
result = part2(data)
|
||||
assert result == expected
|
||||
|
||||
|
||||
def test_parse_line():
|
||||
input = "A Y"
|
||||
expected = Shape.Rock, Shape.Paper
|
||||
result = Shape.parse(input)
|
||||
assert result == expected
|
||||
|
||||
|
||||
def test_round1():
|
||||
input = "A Y"
|
||||
expected = 8
|
||||
opponent, player = Shape.parse(input)
|
||||
assert player.score(opponent) == expected
|
||||
|
||||
|
||||
def test_round2():
|
||||
input = "A Y"
|
||||
expected = 4
|
||||
opponent, player = Result.parse(input)
|
||||
assert player.score(opponent) == expected
|
||||
|
||||
|
||||
def test_round3():
|
||||
input = "B X"
|
||||
expected = 1
|
||||
opponent, player = Result.parse(input)
|
||||
assert player.score(opponent) == expected
|
||||
Loading…
Add table
Add a link
Reference in a new issue