add zero die tests
This commit is contained in:
parent
5e5b8b82c8
commit
0bef9a1869
1 changed files with 58 additions and 0 deletions
|
@ -11,30 +11,41 @@ def dice_roller():
|
|||
@pytest.mark.parametrize(
|
||||
"expression, range_min, range_max",
|
||||
[
|
||||
# normal roll
|
||||
("d20", 1, 20),
|
||||
("d12", 1, 12),
|
||||
("d10", 1, 10),
|
||||
("d8", 1, 8),
|
||||
("d6", 1, 6),
|
||||
("d4", 1, 4),
|
||||
# multiple dies
|
||||
("2d20", 2, 40),
|
||||
("2d12", 2, 24),
|
||||
("2d10", 2, 20),
|
||||
("2d8", 2, 16),
|
||||
("2d6", 2, 12),
|
||||
("2d4", 2, 8),
|
||||
# positive modifier
|
||||
("d20+1", 1, 21),
|
||||
("d12+1", 1, 13),
|
||||
("d10+1", 1, 11),
|
||||
("d8+1", 1, 9),
|
||||
("d6+1", 1, 7),
|
||||
("d4+1", 1, 5),
|
||||
# negative modifier
|
||||
("d20-1", 1, 19),
|
||||
("d12-1", 1, 11),
|
||||
("d10-1", 1, 9),
|
||||
("d8-1", 1, 7),
|
||||
("d6-1", 1, 5),
|
||||
("d4-1", 1, 3),
|
||||
# white-space in expression
|
||||
("1d20 +0", 1, 20),
|
||||
("1d12 + 0", 1, 12),
|
||||
("1 d10 + 0", 1, 10),
|
||||
("1 d8 +0", 1, 8),
|
||||
("1 d 6 +0", 1, 6),
|
||||
("1d 4 +0", 1, 4),
|
||||
],
|
||||
)
|
||||
def test_die_roll(expression, range_min, range_max, dice_roller):
|
||||
|
@ -42,3 +53,50 @@ def test_die_roll(expression, range_min, range_max, dice_roller):
|
|||
for i in range(100):
|
||||
result = dice_roller.roll(expression)
|
||||
assert range_min <= result <= range_max
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"expression, range_min, range_max",
|
||||
[
|
||||
# normal roll
|
||||
("zd20", 0, 20),
|
||||
("zd12", 0, 12),
|
||||
("zd10", 0, 10),
|
||||
("zd8", 0, 8),
|
||||
("zd6", 0, 6),
|
||||
("zd4", 0, 4),
|
||||
# multiple dies
|
||||
("2zd20", 0, 40),
|
||||
("2zd12", 0, 24),
|
||||
("2zd10", 0, 20),
|
||||
("2zd8", 0, 16),
|
||||
("2zd6", 0, 12),
|
||||
("2zd4", 0, 8),
|
||||
# positive modifier
|
||||
("zd20+1", 0, 21),
|
||||
("zd12+1", 0, 13),
|
||||
("zd10+1", 0, 11),
|
||||
("zd8+1", 0, 9),
|
||||
("zd6+1", 0, 7),
|
||||
("zd4+1", 0, 5),
|
||||
# negative modifier
|
||||
("zd20-1", 0, 19),
|
||||
("zd12-1", 0, 11),
|
||||
("zd10-1", 0, 9),
|
||||
("zd8-1", 0, 7),
|
||||
("zd6-1", 0, 5),
|
||||
("zd4-1", 0, 3),
|
||||
# white-space in expression
|
||||
("1zd20 +0", 0, 20),
|
||||
("1zd12 + 0", 0, 12),
|
||||
("1 zd10 + 0", 0, 10),
|
||||
("1 zd8 +0", 0, 8),
|
||||
("1 zd 6 +0", 0, 6),
|
||||
("1zd 4 +0", 0, 4),
|
||||
],
|
||||
)
|
||||
def test_zero_die_roll(expression, range_min, range_max, dice_roller):
|
||||
# let the dies roll...
|
||||
for i in range(100):
|
||||
result = dice_roller.roll(expression)
|
||||
assert range_min <= result <= range_max
|
||||
|
|
Loading…
Reference in a new issue