Module:roman numerals/testcases
Appearance
- The following documentation is located at Module:roman numerals/testcases/documentation. [edit]
- Useful links: root page • root page’s subpages • links • transclusions • tested module • sandbox
All tests passed. (refresh)
Text | Expected | Actual | |
---|---|---|---|
![]() | 1 | I | I |
![]() | 2 | II | II |
![]() | 3 | III | III |
![]() | 4 | IV | IV |
![]() | 5 | V | V |
![]() | 6 | VI | VI |
![]() | 7 | VII | VII |
![]() | 8 | VIII | VIII |
![]() | 9 | IX | IX |
![]() | 10 | X | X |
![]() | 944 | CMXLIV | CMXLIV |
![]() | 2848 | MMDCCCXLVIII | MMDCCCXLVIII |
![]() | 3999 | MMMCMXCIX | MMMCMXCIX |
Text | Expected | Actual | |
---|---|---|---|
![]() | I | 1 | 1 |
![]() | II | 2 | 2 |
![]() | III | 3 | 3 |
![]() | IV | 4 | 4 |
![]() | V | 5 | 5 |
![]() | VI | 6 | 6 |
![]() | VII | 7 | 7 |
![]() | VIII | 8 | 8 |
![]() | IX | 9 | 9 |
![]() | X | 10 | 10 |
![]() | MCCXLI | 1241 | 1241 |
![]() | CMXCIX | 999 | 999 |
![]() | MMMCMXCIX | 3999 | 3999 |
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