Fixed error in Palindrome.java and gave semantic names to functions (#3643)

* fixed error and changed functions names

fixed error at line 57 and gave semantic names to functions with comments

* renamed functions

renamed functions to match with original functions' names in the file

* Updated TestCases

Updated TestCases and changed a function name

* Removed main() and changed function name

Removed main() and changed the function name from isPalindromeStringBuilder to isPalindrome

* fixed typo

Co-authored-by: Debasish Biswas <debasishbsws.abc@gmail.com>
This commit is contained in:
Taranjeet Singh Kalsi
2022-10-28 00:17:16 +05:30
committed by GitHub
parent acf7a86b96
commit bd267bb7d8
2 changed files with 19 additions and 31 deletions

View File

@ -7,13 +7,20 @@ public class PalindromeTest {
@Test
public void palindrome() {
String input1 = "kayak";
String input2 = "kayaks";
Assertions.assertTrue(Palindrome.isPalindrome(input1));
Assertions.assertFalse(Palindrome.isPalindrome(input2));
Assertions.assertTrue(Palindrome.isPalindromeRecursion(input1));
Assertions.assertFalse(Palindrome.isPalindromeRecursion(input2));
Assertions.assertTrue(Palindrome.isPalindrome1(input1));
Assertions.assertFalse(Palindrome.isPalindrome1(input2));
String[] palindromes = { null, "", "aba", "123321", "kayak" };
for (String s : palindromes) {
Assertions.assertTrue(Palindrome.isPalindrome(s) &&
Palindrome.isPalindromeRecursion(s) &&
Palindrome.isPalindromeTwoPointer(s));
}
String[] notPalindromes = { "abb", "abc", "abc123", "kayaks" };
for (String s : notPalindromes) {
Assertions.assertFalse(Palindrome.isPalindrome(s) ||
Palindrome.isPalindromeRecursion(s) ||
Palindrome.isPalindromeTwoPointer(s));
}
}
}