import pytest from roman import RomanNumeralConverter ERROR_MESSAGE = "ERROR: Invalid input" def test_valid_single_numerals(): converter = RomanNumeralConverter() assert converter.convert_to_number("I") == "I = 1" assert converter.convert_to_number("V") == "V = 5" assert converter.convert_to_number("X") == "X = 10" assert converter.convert_to_number("C") == "C = 100" assert converter.convert_to_number("M") == "M = 1000" def test_valid_multiple_numerals(): converter = RomanNumeralConverter() assert converter.convert_to_number("IV") == "IV = 1 + 5 = 6" assert converter.convert_to_number("XCM") == "XCM = 10 + 100 + 1000 = 1110" assert ( converter.convert_to_number("MCMXCIV") == "MCMXCIV = 1000 + 100 + 1000 + 10 + 100 + 1 + 5 = 2216" ) def test_lowercase_input(): converter = RomanNumeralConverter() assert ( converter.convert_to_number("ivxcm") == "IVXCM = 1 + 5 + 10 + 100 + 1000 = 1116" ) def test_mixed_case_input(): converter = RomanNumeralConverter() assert ( converter.convert_to_number("iVxCm") == "IVXCM = 1 + 5 + 10 + 100 + 1000 = 1116" ) def test_invalid_characters(): converter = RomanNumeralConverter() assert converter.convert_to_number("EFGH") == ERROR_MESSAGE assert converter.convert_to_number("123") == ERROR_MESSAGE assert converter.convert_to_number("!@#") == ERROR_MESSAGE def test_mixed_valid_and_invalid_characters(): converter = RomanNumeralConverter() assert converter.convert_to_number("AIXB") == "IX = 1 + 10 = 11" assert converter.convert_to_number("M1C2") == "MC = 1000 + 100 = 1100" def test_empty_string(): converter = RomanNumeralConverter() assert converter.convert_to_number("") == ERROR_MESSAGE def test_only_spaces(): converter = RomanNumeralConverter() assert converter.convert_to_number(" ") == ERROR_MESSAGE def test_spaces_and_valid_numerals(): converter = RomanNumeralConverter() assert converter.convert_to_number(" I V ") == "IV = 1 + 5 = 6" def test_filter_valid_numerals(): converter = RomanNumeralConverter() assert converter._filter_valid_numerals("M1X2V") == "MXV" assert converter._filter_valid_numerals("def") == "" assert converter._filter_valid_numerals(" I V ") == "IV" def test_convert_numerals_to_values(): converter = RomanNumeralConverter() assert converter._convert_numerals_to_values("IV") == [1, 5] assert converter._convert_numerals_to_values("MXV") == [1000, 10, 5] assert converter._convert_numerals_to_values("C") == [100] def test_format_output(): converter = RomanNumeralConverter() assert converter._format_output("I", [1]) == "I = 1" assert converter._format_output("IV", [1, 5]) == "IV = 1 + 5 = 6" assert ( converter._format_output("MXV", [1000, 10, 5]) == "MXV = 1000 + 10 + 5 = 1015" )