add tests for parsing errors

This commit is contained in:
Denis-Cosmin Nutiu 2024-01-21 23:00:02 +02:00
parent 6b0148241a
commit 43c76aa073

View file

@ -100,3 +100,23 @@ def test_zero_die_roll(expression, range_min, range_max, dice_roller):
for i in range(100): for i in range(100):
result = dice_roller.roll(expression) result = dice_roller.roll(expression)
assert range_min <= result <= range_max assert range_min <= result <= range_max
@pytest.mark.parametrize(
"expression",
[
"20d",
"d",
"zd",
"20",
"20+3",
"20q+3",
"123q*3",
"20d*3",
"20d20*3",
"20d20/3",
],
)
def test_die_parsing_fail(expression, dice_roller):
with pytest.raises(ValueError):
dice_roller.roll(expression)