def test_single_x(self):
     self.assertEqual(RomanToInt.convert('I'), 1)
     self.assertEqual(RomanToInt.convert('V'), 5)
     self.assertEqual(RomanToInt.convert('X'), 10)
     self.assertEqual(RomanToInt.convert('L'), 50)
     self.assertEqual(RomanToInt.convert('C'), 100)
     self.assertEqual(RomanToInt.convert('D'), 500)
     self.assertEqual(RomanToInt.convert('M'), 1000)
 def test_composite_x(self):
     self.assertEqual(RomanToInt.convert('LX'), 60)
     self.assertEqual(RomanToInt.convert('LXV'), 65)
     self.assertEqual(RomanToInt.convert('MMMD'), 3500)
     self.assertEqual(RomanToInt.convert('IV'), 4)
     self.assertEqual(RomanToInt.convert('MMIV'), 2004)
     self.assertEqual(RomanToInt.convert('XC'), 90)
     self.assertEqual(RomanToInt.convert('CLX'), 160)
示例#3
0
 def test_single_x(self):
     self.assertEqual(RomanToInt.convert('X'), 10)
 def test_single_l(self):
     self.assertEqual(RomanToInt.convert('L'), 50)
 def test_error(self):
     with self.assertRaises(ValueError):
         RomanToInt.convert('Q')
 def test_sub_3(self):
     self.assertEqual(RomanToInt.convert('XC'), 90)
 def test_sub_2(self):
     self.assertEqual(RomanToInt.convert('MMIV'), 2004)
 def test_sub_1(self):
     self.assertEqual(RomanToInt.convert('IV'), 4)
 def test_comp_3(self):
     self.assertEqual(RomanToInt.convert('MMMD'), 3500)
 def test_comp_2(self):
     self.assertEqual(RomanToInt.convert('LXV'), 65)
 def test_comp_1(self):
     self.assertEqual(RomanToInt.convert('LX'), 60)
 def test_single_m(self):
     self.assertEqual(RomanToInt.convert('M'), 1000)
 def test_single_d(self):
     self.assertEqual(RomanToInt.convert('D'), 500)
import sys

from roman_numerals.roman_to_int import RomanToInt

if __name__ == "__main__":
    s = sys.argv[1]

    print("The Roman numerals {} are {} in decimal.".format(
        s, RomanToInt.convert(s)))
 def test_valid_x(self):
     self.assertRaises(ValueError, RomanToInt.value_of('w'))