示例#1
0
def test_weird():
    """Odd/illegal numbers"""
    ## these are illegal, but might work this way
    vals = ["IXX","VX"]
    ans = [19,5]
    for i in range(len(vals)):
        assert_equal(rr.roman_to_int(vals[i]),ans[i], 'weird')
示例#2
0
def test_easy():
    """Single values"""
    vals = ["I","V","X","L","C","D","M"]
    ans = [1,5,10,50,100,500,1000]
    for i in range(len(vals)):
        assert_equal(rr.roman_to_int(vals[i]),ans[i], 'simple example')
示例#3
0
def test_subtraction():
    """Simple subtraction rule"""
    vals = ["IV","IX","XL","XC","CD","CM"]
    ans = [4,9,40,90,400,900]
    for i in range(len(vals)):
        assert_equal(rr.roman_to_int(vals[i]),ans[i], 'subtraction')
示例#4
0
def test_complex():
    """Subtraction rule plus extras"""
    vals = ["XIV","MCMXCIX","CDXVIII"]
    ans = [14,1999,418]
    for i in range(len(vals)):
        assert_equal(rr.roman_to_int(vals[i]),ans[i], 'subtraction 2')
示例#5
0
def test_combined():
    """Simple cases without subtraction rule"""
    vals = ["III","VI","XII","MDCCLXVI"]
    ans = [3,6,12,1766]
    for i in range(len(vals)):
        assert_equal(rr.roman_to_int(vals[i]),ans[i], 'medium example')