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.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;

import static org.junit.jupiter.api.Assertions.*;

public class PalindromeTests {

    @ParameterizedTest
    @ValueSource(strings = {"aaaa", "AaAaaaA", "Radar", "My gym", "Don't nod", "No lemon, no melon"})
    void testIsPalindrome(String string) {
        assertTrue(StringUtils.isPalindrome(string));
    }

    @ParameterizedTest
    @ValueSource(strings = {"", "hello!", "horror", "Ill will", "((()))", "[))))]", "222222122222"})
    void 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 Java 17
class StringUtils {
public static boolean isPalindrome(String str) {
// your code here
return false;
}
}
___

Create a free account to access the full topic