Last active
August 29, 2015 14:15
-
-
Save aellispierce/5f9badce12902cb57a68 to your computer and use it in GitHub Desktop.
Palindrome Puzzle
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 palindrome?(word) | |
if word.downcase == word.downcase.reverse | |
result = true | |
else | |
result = false | |
end | |
result | |
end | |
class StringPalindromePuzzle < MiniTest::Test | |
def test_words | |
assert palindrome?("tacocat") | |
assert palindrome?("anna") | |
assert palindrome?("racecar") | |
end | |
def test_bad_words | |
refute palindrome?("ruby") | |
refute palindrome?("cowboy") | |
refute palindrome?("Ruby") | |
refute palindrome?("Cowboy") | |
end | |
def test_capitalization | |
assert palindrome?("Tacocat") | |
assert palindrome?("Anna") | |
assert palindrome?("RacEcAr") | |
end | |
def test_sentences | |
assert palindrome?("Stressed desserts") | |
assert palindrome?("Stop on no pots") | |
refute palindrome?("The quick brown fox") | |
end | |
def test_spaces | |
assert palindrome?("Mad as Adam") | |
assert palindrome?("Sums are not set as a test on Erasmus") | |
refute palindrome?("Where the heck did you get these sentences?") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment