Skip to content

Instantly share code, notes, and snippets.

@kangeugine
Created August 25, 2017 04:28
Show Gist options
  • Save kangeugine/b8e272faffd982d74ac3fa6befcedee8 to your computer and use it in GitHub Desktop.
Save kangeugine/b8e272faffd982d74ac3fa6befcedee8 to your computer and use it in GitHub Desktop.
Unit Testing Example Palindrome
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