Created
August 18, 2013 21:43
-
-
Save paranoidminotaur/6264152 to your computer and use it in GitHub Desktop.
anagram_test.rb
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
require 'minitest/autorun' | |
require_relative 'anagram' | |
class AnagramTest < MiniTest::Unit::TestCase | |
def test_no_matches | |
detector = Anagram.new('diaper') | |
assert_equal [], detector.match(%w(hello world zombies pants)) | |
end | |
def test_detect_simple_anagram | |
skip | |
detector = Anagram.new('ant') | |
anagrams = detector.match(['tan', 'stand', 'at']) | |
assert_equal ['tan'], anagrams | |
end | |
def test_detect_multiple_anagrams | |
skip | |
detector = Anagram.new('master') | |
anagrams = detector.match(['stream', 'pigeon', 'maters']) | |
assert_equal ['maters', 'stream'], anagrams.sort | |
end | |
def test_does_not_confuse_different_duplicates | |
skip | |
detector = Anagram.new('galea') | |
assert_equal [], detector.match(['eagle']) | |
end | |
def test_identical_word_is_not_anagram | |
skip | |
detector = Anagram.new('corn') | |
anagrams = detector.match %w(corn dark Corn rank CORN park) | |
assert_equal [], anagrams | |
end | |
def test_eliminate_anagrams_with_same_checksum | |
skip | |
detector = Anagram.new('mass') | |
assert_equal [], detector.match(['last']) | |
end | |
def test_eliminate_anagram_subsets | |
skip | |
detector = Anagram.new('good') | |
assert_equal [], detector.match(['dog', 'goody']) | |
end | |
def test_detect_anagram | |
skip | |
detector = Anagram.new('listen') | |
anagrams = detector.match %w(enlists google inlets banana) | |
assert_equal ['inlets'], anagrams | |
end | |
def test_multiple_anagrams | |
skip | |
detector = Anagram.new('allergy') | |
anagrams = detector.match %w(gallery ballerina regally clergy largely leading) | |
assert_equal ['gallery', 'largely', 'regally'], anagrams.sort | |
end | |
def test_anagrams_are_case_insensitive | |
skip | |
detector = Anagram.new('Orchestra') | |
anagrams = detector.match %w(cashregister Carthorse radishes) | |
assert_equal ['Carthorse'], anagrams | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment