29 lines
754 B
Python
29 lines
754 B
Python
import unittest
|
|
|
|
from roll_dice import roll_dice
|
|
|
|
|
|
class TestRollDice(unittest.TestCase):
|
|
def test_constant(self):
|
|
self.assertEqual(roll_dice("1"), 1)
|
|
self.assertEqual(roll_dice("2"), 2)
|
|
|
|
def test_sum(self):
|
|
self.assertEqual(roll_dice("1+2"), 3)
|
|
|
|
def test_dice(self):
|
|
self.assertGreaterEqual(roll_dice("4d4"), 4)
|
|
self.assertLessEqual(roll_dice("4d4"), 16)
|
|
|
|
def test_dice_plus_constant(self):
|
|
self.assertGreaterEqual(roll_dice("1d4+4"), 5)
|
|
self.assertLessEqual(roll_dice("1d4+4"), 8)
|
|
|
|
def test_dice_plus_dice(self):
|
|
self.assertGreaterEqual(roll_dice("1d8+2d10"), 3)
|
|
self.assertLessEqual(roll_dice("1d8+2d10"), 28)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|