Module:roman numerals/testcases

local tests = require('Module:UnitTests') local m_roman = require('Module:roman_numerals')

function tests:check_roman_to_arabic(roman, arabic) self:equals(		roman,		m_roman.roman_to_arabic(roman), arabic	) end

function tests:check_arabic_to_roman(arabic, roman) self:equals(		arabic,		m_roman.arabic_to_roman(arabic), roman	) end

function tests:test_arabic_to_roman self:check_arabic_to_roman(1, "I") self:check_arabic_to_roman(2, "II") self:check_arabic_to_roman(3, "III") self:check_arabic_to_roman(4, "IV") self:check_arabic_to_roman(5, "V") self:check_arabic_to_roman(6, "VI") self:check_arabic_to_roman(7, "VII") self:check_arabic_to_roman(8, "VIII") self:check_arabic_to_roman(9, "IX") self:check_arabic_to_roman(10, "X") self:check_arabic_to_roman(944, "CMXLIV") self:check_arabic_to_roman(2848, "MMDCCCXLVIII") self:check_arabic_to_roman(3999, "MMMCMXCIX") end

function tests:test_roman_to_arabic self:check_roman_to_arabic("I", 1) self:check_roman_to_arabic("II", 2) self:check_roman_to_arabic("III", 3) self:check_roman_to_arabic("IV", 4) self:check_roman_to_arabic("V", 5) self:check_roman_to_arabic("VI", 6) self:check_roman_to_arabic("VII", 7) self:check_roman_to_arabic("VIII", 8) self:check_roman_to_arabic("IX", 9) self:check_roman_to_arabic("X", 10) self:check_roman_to_arabic("MCCXLI", 1241) self:check_roman_to_arabic("CMXCIX", 999) self:check_roman_to_arabic("MMMCMXCIX", 3999) end

return tests