Created
December 26, 2023 11:59
-
-
Save birojow/3825f3ad7a48fe2978658439901560d1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unittest | |
class RomanNumeralTest(unittest.TestCase): | |
def test_should_create_roman_numeral_object_from_int(self): | |
actual_numerals = [RomanNumeral(i).as_roman() for i in [ | |
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, | |
200, 300, 400, 500, 600, 700, 800, 900, 1000 | |
]] | |
expected_numerals = [ | |
"I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X", "XX", | |
"XXX", "XL", "L", "LX", "LXX", "LXXX", "XC", "C", "CC", "CCC", "CD", "D", | |
"DC", "DCC", "DCCC", "DCCCC", "M" | |
] | |
self.assertListEqual(expected_numerals, actual_numerals) | |
def test_should_create_roman_numeral_object_from_string(self): | |
actual_numerals = [RomanNumeral(s).as_arabic() for s in [ | |
"I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X", "XX", | |
"XXX", "XL", "L", "LX", "LXX", "LXXX", "XC", "C", "CC", "CCC", "CD", "D", | |
"DC", "DCC", "DCCC", "DCCC", "M" | |
]] | |
expected_numerals = [ | |
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, | |
200, 300, 400, 500, 600, 700, 800, 900, 1000 | |
] | |
self.assertListEqual(expected_numerals, actual_numerals) | |
if __name__ == '__main__': | |
unittest.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment