Palindromes

Report a typo

Unsatisfied with palindrome checkers from stackoverflow.com, you decided to write your own implementation of this algorithm and apply the test-driven development approach to this process. First, you defined a set of rules for your checker. After that, you wrote tests to enforce these rules. It's about time to implement the checker itself.

import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.ValueSource

class PalindromeTests {
    val stringUtils = StringUtils()
    @ParameterizedTest
    @ValueSource(strings = ["aaaa", "AaAaaaA", "Radar", "My gym", "Don't nod", "No lemon, no melon"])
    fun testIsPalindrome(string: String?) {
        assertTrue(stringUtils.isPalindrome(string))
    }

    @ParameterizedTest
    @ValueSource(strings = ["", "hello!", "horror", "Ill will", "((()))", "[))))]", "222222122222"])
    fun testIsNotPalindrome(string: String?) {
        assertFalse(stringUtils.isPalindrome(string))
    }
}

Too bad, you have lost the piece of paper with the full list of rules, so no other cases will be tested.

Sample Input 1:

aaaa

Sample Output 1:

true

Sample Input 2:

Radar

Sample Output 2:

true

Sample Input 3:

hello!

Sample Output 3:

false
Write a program in Kotlin
class StringUtils {
fun isPalindrome(str: String?): Boolean {
// your code here
return false
}
}
___

Create a free account to access the full topic