Skip to content

Commit

Permalink
separate test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
CalMWolfs committed Dec 22, 2024
1 parent c8f7299 commit a21f967
Showing 1 changed file with 26 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,52 @@ import org.junit.jupiter.api.Test
class ReplaceRomanNumeralsTest {

@Test
fun testTransformLine() {
// Simple case with no Roman numerals
fun `Regular words shouldn't be modified`() {
Assertions.assertEquals("hello", "hello".transformLine())
}

// I should never be converted
@Test
fun `'I' should never be converted`() {
Assertions.assertEquals("I", "I".transformLine())
}

// Single Roman numeral should be converted
@Test
fun `Single Roman numeral should be converted`() {
Assertions.assertEquals("5", "V".transformLine())
}

// Multiple Roman numerals separated by spaces
@Test
fun `Multiple Roman numerals separated by spaces should be converted`() {
Assertions.assertEquals("5 10 world", "V X world".transformLine())
}

// Roman numeral next to punctuation
@Test
fun `Roman numeral next to punctuation should be converted`() {
Assertions.assertEquals("5!", "V!".transformLine())
Assertions.assertEquals("hello 14 you?", "hello XIV you?".transformLine())
}

// Mixed with color codes
@Test
fun `Mixed with color codes should be converted`() {
Assertions.assertEquals("§c5!", "§cV!".transformLine())
Assertions.assertEquals("hello 2 is this 5 you?", "hello II is this V you?".transformLine())
}

// If invalid Roman numeral sequences are left unchanged
// Assuming "IIII" is invalid, it remains as is
@Test
fun `Invalid Roman numeral sequences are left unchanged`() {
Assertions.assertEquals("IIII", "IIII".transformLine())
}

// Check sequences with punctuation and color codes interspersed
@Test
fun `Sequences with punctuation and color codes interspersed should be converted`() {
Assertions.assertEquals("§d5 world", "§dV world".transformLine())
Assertions.assertEquals("hello 10 and then 1 more", "hello X and then I more".transformLine())
}

// Mixed complexity
@Test
fun `Mixed complexity should be converted`() {
Assertions.assertEquals("Today 2023 was great!", "Today MMXXIII was great!".transformLine())
}

fun String.transformLine(): String = ReplaceRomanNumerals.replaceRomanNumerals(this)
private fun String.transformLine(): String = ReplaceRomanNumerals.replaceRomanNumerals(this)
}

0 comments on commit a21f967

Please sign in to comment.