Fixed Issue #4 - Palindrome isNo

This commit is contained in:
Dmitry
2022-01-30 18:49:14 +07:00
parent d17a097cbc
commit 0e9ae5079f
7 changed files with 11 additions and 5 deletions

View File

@ -19,6 +19,6 @@ class Palindrome(private val text: String) {
*
* @return returns true if the string is not a palindrome
*/
fun isNot() = text != text.reversed()
fun isNot() = !isYes()
}

View File

@ -7,14 +7,20 @@ internal class PalindromeTest {
@Test
fun test_is_palindrome() {
val text = "tenet"
assertEquals(Palindrome(text).isYes(), true)
val text1 = "tenet"
assertEquals(Palindrome(text1).isYes(), true)
val text2 = "friend"
assertEquals(Palindrome(text2).isYes(), false)
}
@Test
fun test_is_not_palindrome() {
val text = "white"
assertEquals(Palindrome(text).isNot(), true)
val text1 = "white"
assertEquals(Palindrome(text1).isNot(), true)
val text2 = "tenet"
assertEquals(Palindrome(text2).isNot(), false)
}
}