Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Verified Commit b61f6505 authored by Fahim M. Choudhury's avatar Fahim M. Choudhury
Browse files

refactor: add more test cases

parent 66bced40
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@ object CategoryStringFormatter {
            "unknown" -> "Unknown"
            else ->
                input.replace("_", " ").split(" ").joinToString(" ") { word ->
                    if (word.lowercase() == "and") word
                    if (word.lowercase() == "and") word.lowercase(Locale.getDefault())
                    else {
                        word.replaceFirstChar {
                            if (it.isLowerCase()) it.titlecase(Locale.getDefault())
+19 −3
Original line number Diff line number Diff line
@@ -33,9 +33,17 @@ class CategoryStringFormatterTest {
    }

    @Test
    fun testFormatString_withMultipleWords() {
        val input = "mental_health_and_fitness"
        val expected = "Mental Health and Fitness"
    fun testFormatString_withSpaces() {
        val input = "health and fitness"
        val expected = "Health and Fitness"
        val result = CategoryStringFormatter.format(input)
        assertEquals(expected, result)
    }

    @Test
    fun testFormatString_withAllWordsCapitalized() {
        val input = "Health And Fitness"
        val expected = "Health and Fitness"
        val result = CategoryStringFormatter.format(input)
        assertEquals(expected, result)
    }
@@ -65,6 +73,14 @@ class CategoryStringFormatterTest {
        assertEquals(expected, result)
    }

    @Test
    fun testFormatString_withOnlyCapitalizedAnd() {
        val input = "And"
        val expected = "and"
        val result = CategoryStringFormatter.format(input)
        assertEquals(expected, result)
    }

    @Test
    fun testFormatString_withEmptyString() {
        val input = ""