Created
August 25, 2017 04:28
-
-
Save kangeugine/b8e272faffd982d74ac3fa6befcedee8 to your computer and use it in GitHub Desktop.
Unit Testing Example Palindrome
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def is_palindrome(sequence): | |
return sequence == sequence[::-1] | |
# test when sequence IS palindrome | |
def test_true(): | |
seq = 'bob' | |
assert is_palindrome(seq) == True | |
def test_true_list(): | |
seq = [1, 0, 1] | |
assert is_palindrome(seq) == True | |
# test when sequence IS NOT palindrome | |
def test_false(): | |
seq = 'eugine' | |
assert is_palindrome(seq) == False | |
def test_false_list(): | |
seq = [1, 0, 2] | |
assert is_palindrome(seq) == False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment