Skip to content
Permalink
Browse files

20 is written as XX

  • Loading branch information
michaelbannister committed Jul 3, 2016
1 parent e0aea26 commit 1deedff0cd62201b7c636daf6c8bbfd2a0aec912
Showing with 6 additions and 5 deletions.
  1. +3 −3 src/main/kotlin/RomanNumerals.kt
  2. +3 −2 src/test/kotlin/DecimalToRomanConverterTest.kt
@@ -1,7 +1,7 @@
fun Int.toRoman(): String {
if (this < 10) {
return "I".repeat(this)
if (this >= 10) {
return "X".repeat(this / 10)
} else {
return "X"
return "I".repeat(this)
}
}
@@ -12,14 +12,15 @@ class DecimalToRomanConverterTest {
@TestCaseName("{0} is written as {1}")
@Parameters
fun testIntToRomanConversion(number: Int, romanRepresentation: String) {
assertEquals(romanRepresentation, number.toRoman())
assertEquals(romanRepresentation, number.toRoman(), "Incorrect conversion of ${number} to Roman numerals")
}

private fun parametersForTestIntToRomanConversion() =
arrayOf(
arrayOf(1, "I"),
arrayOf(2, "II"),
arrayOf(10, "X")
arrayOf(10, "X"),
arrayOf(20, "XX")
)
}

0 comments on commit 1deedff

Please sign in to comment.
You can’t perform that action at this time.