Fakultas Ilmu Komputer UI

Skip to content
Snippets Groups Projects

isPalindrome() Test JUnit5

  • Clone with SSH
  • Clone with HTTPS
  • Embed
  • Share
    The snippet can be accessed without any authentication.
    Authored by Ahmad Izzudin Alifyandra
    PalindromeTest.java 582 B
    import org.junit.jupiter.api.*;
    
    class PalindromeTest {
    
        @Test
        void testWithEmptyString() {
            String testStr = "";
            assertThat(isPalindrome(testStr)).isTrue();
        }
    
        @Test
        void testWithOneChar() {
            String testStr = "a";
            assertThat(isPalindrome(testStr)).isTrue();
        }
    
        @Test
        void testWithCharsTrue() {
            String testStr = "aba";
            assertThat(isPalindrome(testStr)).isTrue();
        }
    
        @Test
        void testWithCharsFalse() {
            String testStr = "abc";
            assertThat(isPalindrome(testStr)).isFalse();
        }
    }
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Please register or to comment