-
-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #596 from ricemery/anagram
Update anagram exercise to match latest test data. Refs #488
- Loading branch information
Showing
2 changed files
with
30 additions
and
22 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,85 @@ | ||
import org.scalatest.{Matchers, FunSuite} | ||
|
||
/** @version 1.2.0 */ | ||
/** @version 1.4.0 */ | ||
class AnagramTest extends FunSuite with Matchers { | ||
|
||
test("no matches") { | ||
Anagram.anagrams("diaper", List("hello", "world", "zombies", "pants")) should be( | ||
Anagram.findAnagrams("diaper", List("hello", "world", "zombies", "pants")) should be( | ||
List()) | ||
} | ||
|
||
test("detects two anagrams") { | ||
pending | ||
Anagram.anagrams("master", List("stream", "pigeon", "maters")) should be( | ||
Anagram.findAnagrams("master", List("stream", "pigeon", "maters")) should be( | ||
List("stream", "maters")) | ||
} | ||
|
||
test("does not detect anagram subsets") { | ||
pending | ||
Anagram.anagrams("good", List("dog", "goody")) should be(List()) | ||
Anagram.findAnagrams("good", List("dog", "goody")) should be(List()) | ||
} | ||
|
||
test("detects anagram") { | ||
pending | ||
Anagram.anagrams("listen", List("enlists", "google", "inlets", "banana")) should be( | ||
List("inlets")) | ||
Anagram.findAnagrams( | ||
"listen", | ||
List("enlists", "google", "inlets", "banana")) should be(List("inlets")) | ||
} | ||
|
||
test("detects three anagrams") { | ||
pending | ||
Anagram.anagrams("allergy", | ||
List("gallery", | ||
"ballerina", | ||
"regally", | ||
"clergy", | ||
"largely", | ||
"leading")) should be( | ||
Anagram.findAnagrams("allergy", | ||
List("gallery", | ||
"ballerina", | ||
"regally", | ||
"clergy", | ||
"largely", | ||
"leading")) should be( | ||
List("gallery", "regally", "largely")) | ||
} | ||
|
||
test("does not detect non-anagrams with identical checksum") { | ||
pending | ||
Anagram.anagrams("mass", List("last")) should be(List()) | ||
Anagram.findAnagrams("mass", List("last")) should be(List()) | ||
} | ||
|
||
test("detects anagrams case-insensitively") { | ||
pending | ||
Anagram.anagrams("Orchestra", List("cashregister", "Carthorse", "radishes")) should be( | ||
Anagram.findAnagrams( | ||
"Orchestra", | ||
List("cashregister", "Carthorse", "radishes")) should be( | ||
List("Carthorse")) | ||
} | ||
|
||
test("detects anagrams using case-insensitive subject") { | ||
pending | ||
Anagram.anagrams("Orchestra", List("cashregister", "carthorse", "radishes")) should be( | ||
Anagram.findAnagrams( | ||
"Orchestra", | ||
List("cashregister", "carthorse", "radishes")) should be( | ||
List("carthorse")) | ||
} | ||
|
||
test("detects anagrams using case-insensitive possible matches") { | ||
pending | ||
Anagram.anagrams("orchestra", List("cashregister", "Carthorse", "radishes")) should be( | ||
Anagram.findAnagrams( | ||
"orchestra", | ||
List("cashregister", "Carthorse", "radishes")) should be( | ||
List("Carthorse")) | ||
} | ||
|
||
test("does not detect a anagram if the original word is repeated") { | ||
pending | ||
Anagram.anagrams("go", List("go Go GO")) should be(List()) | ||
Anagram.findAnagrams("go", List("go Go GO")) should be(List()) | ||
} | ||
|
||
test("anagrams must use all letters exactly once") { | ||
pending | ||
Anagram.anagrams("tapper", List("patter")) should be(List()) | ||
Anagram.findAnagrams("tapper", List("patter")) should be(List()) | ||
} | ||
|
||
test("capital word is not own anagram") { | ||
test("words are not anagrams of themselves (case-insensitive)") { | ||
pending | ||
Anagram.anagrams("BANANA", List("Banana")) should be(List()) | ||
Anagram.findAnagrams("BANANA", List("BANANA", "Banana", "banana")) should be( | ||
List()) | ||
} | ||
} |