Skip to content

Commit

Permalink
anagram: Sync tests (#644)
Browse files Browse the repository at this point in the history
  • Loading branch information
tasxatzial authored Jun 10, 2024
1 parent c943bda commit 8977040
Show file tree
Hide file tree
Showing 2 changed files with 125 additions and 29 deletions.
47 changes: 44 additions & 3 deletions exercises/practice/anagram/.meta/tests.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
# This is an auto-generated file. Regular comments will be removed when this
# file is regenerated. Regenerating will not touch any manually added keys,
# so comments can be added in a "comment" key.
# This is an auto-generated file.
#
# Regenerating this file via `configlet sync` will:
# - Recreate every `description` key/value pair
# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications
# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion)
# - Preserve any other key/value pair
#
# As user-added comments (using the # character) will be removed when this file
# is regenerated, comments can be added via a `comment` key.

[dd40c4d2-3c8b-44e5-992a-f42b393ec373]
description = "no matches"

[b3cca662-f50a-489e-ae10-ab8290a09bdc]
description = "detects two anagrams"
include = false

[03eb9bbe-8906-4ea0-84fa-ffe711b52c8b]
description = "detects two anagrams"
reimplements = "b3cca662-f50a-489e-ae10-ab8290a09bdc"

[a27558ee-9ba0-4552-96b1-ecf665b06556]
description = "does not detect anagram subsets"
Expand Down Expand Up @@ -34,12 +46,41 @@ description = "detects anagrams using case-insensitive possible matches"

[7cc195ad-e3c7-44ee-9fd2-d3c344806a2c]
description = "does not detect an anagram if the original word is repeated"
include = false

[630abb71-a94e-4715-8395-179ec1df9f91]
description = "does not detect an anagram if the original word is repeated"
reimplements = "7cc195ad-e3c7-44ee-9fd2-d3c344806a2c"

[9878a1c9-d6ea-4235-ae51-3ea2befd6842]
description = "anagrams must use all letters exactly once"

[85757361-4535-45fd-ac0e-3810d40debc1]
description = "words are not anagrams of themselves (case-insensitive)"
include = false

[68934ed0-010b-4ef9-857a-20c9012d1ebf]
description = "words are not anagrams of themselves"
reimplements = "85757361-4535-45fd-ac0e-3810d40debc1"

[589384f3-4c8a-4e7d-9edc-51c3e5f0c90e]
description = "words are not anagrams of themselves even if letter case is partially different"
reimplements = "85757361-4535-45fd-ac0e-3810d40debc1"

[ba53e423-7e02-41ee-9ae2-71f91e6d18e6]
description = "words are not anagrams of themselves even if letter case is completely different"
reimplements = "85757361-4535-45fd-ac0e-3810d40debc1"

[a0705568-628c-4b55-9798-82e4acde51ca]
description = "words other than themselves can be anagrams"
include = false

[33d3f67e-fbb9-49d3-a90e-0beb00861da7]
description = "words other than themselves can be anagrams"
reimplements = "a0705568-628c-4b55-9798-82e4acde51ca"

[a6854f66-eec1-4afd-a137-62ef2870c051]
description = "handles case of greek letters"

[fd3509e5-e3ba-409d-ac3d-a9ac84d13296]
description = "different characters may have the same bytes"
107 changes: 81 additions & 26 deletions exercises/practice/anagram/test/anagram_test.clj
Original file line number Diff line number Diff line change
@@ -1,38 +1,93 @@
(ns anagram-test
(:require [clojure.test :refer [deftest is]]
(:require [clojure.test :refer [deftest testing is]]
anagram))

(deftest no-matches
(is (= []
(anagram/anagrams-for "diaper" ["hello" "world" "zombies" "pants"]))))
(testing "No matches"
(is (= []
(anagram/anagrams-for "diaper" ["hello" "world" "zombies" "pants"])))))

(deftest detect-simple-anagram
(is (= ["tan"] (anagram/anagrams-for "ant" ["tan" "stand" "at"]))))
(deftest detects-two-anagrams
(testing "Detects two anagrams"
(is (= ["lemons", "melons"]
(anagram/anagrams-for "solemn" ["lemons", "cherry", "melons"])))))

(deftest does-not-confuse-different-duplicates
(is (= [] (anagram/anagrams-for "galea" ["eagle"]))))
(deftest does-not-detect-anagram-subsets
(testing "Does not detect anagram subsets"
(is (= []
(anagram/anagrams-for "good" ["dog", "goody"])))))

(deftest eliminate-anagram-subsets
(is (= [] (anagram/anagrams-for "good" ["dog" "goody"]))))
(deftest detects-anagram
(testing "Detects anagram"
(is (= ["inlets"]
(anagram/anagrams-for "listen" ["enlists", "google", "inlets", "banana"])))))

(deftest detect-anagram
(is (= ["inlets"]
(let [coll ["enlists" "google" "inlets" "banana"]]
(anagram/anagrams-for "listen" coll)))))
(deftest detects-three-anagrams
(testing "Detects three anagrams"
(is (= ["gallery", "regally", "largely"]
(anagram/anagrams-for "allergy" ["gallery", "ballerina", "regally", "clergy", "largely", "leading"])))))

(deftest multiple-anagrams
(is (= ["gallery" "regally" "largely"]
(let [coll ["gallery" "ballerina" "regally"
"clergy" "largely" "leading"]]
(anagram/anagrams-for "allergy" coll)))))
(deftest detects-multiple-anagrams-with-different-case
(testing "Detects multiple anagrams with different case"
(is (= ["Eons", "ONES"]
(anagram/anagrams-for "nose" ["Eons", "ONES"])))))

(deftest case-insensitive-anagrams
(is (= ["Carthorse"]
(let [coll ["cashregister" "Carthorse" "radishes"]]
(anagram/anagrams-for "Orchestra" coll)))))
(deftest does-not-detect-non-anagrams-with-identical-checksum
(testing "Does not detect non-anagrams with identical checksum"
(is (= []
(anagram/anagrams-for "mass" ["last"])))))

(deftest word-is-not-own-anagram
(is (= [] (anagram/anagrams-for "banana" ["banana"]))))
(deftest detects-anagrams-case-insensitively
(testing "Detects anagrams case-insensitively"
(is (= ["Carthorse"]
(anagram/anagrams-for "Orchestra" ["cashregister", "Carthorse", "radishes"])))))

(deftest capital-word-is-not-own-anagram
(is (= [] (anagram/anagrams-for "BANANA" ["banana"]))))
(deftest detects-anagrams-using-case-insensitive-subject
(testing "Detects anagrams using case-insensitive subject"
(is (= ["carthorse"]
(anagram/anagrams-for "Orchestra" ["cashregister", "carthorse", "radishes"])))))

(deftest detects-anagrams-using-case-insensitive-possible-matches
(testing "Detects anagrams using case-insensitive possible matches"
(is (= ["Carthorse"]
(anagram/anagrams-for "orchestra" ["cashregister", "Carthorse", "radishes"])))))

(deftest does-not-detect-anagram-if-original-word-is-repeated
(testing "Does not detect an anagram if the original word is repeated"
(is (= []
(anagram/anagrams-for "go" ["goGoGO"])))))

(deftest anagrams-must-use-all-letters-exactly-once
(testing "Anagrams must use all letters exactly once"
(is (= []
(anagram/anagrams-for "tapper" ["patter"])))))

(deftest words-are-not-anagrams-of-themselves
(testing "Words are not anagrams of themselves"
(is (= []
(anagram/anagrams-for "BANANA" ["BANANA"])))))

(deftest words-are-not-anagrams-of-themselves-even-if-letter-case-is-partially-different
(testing "Words are not anagrams of themselves even if letter case is partially different"
(is (= []
(anagram/anagrams-for "BANANA" ["Banana"])))))

(deftest words-are-not-anagrams-of-themselves-even-if-letter-case-is-completely-different
(testing "Words are not anagrams of themselves even if letter case is completely different"
(is (= []
(anagram/anagrams-for "BANANA" ["banana"])))))

(deftest words-other-than-themselves-can-be-anagrams
(testing "Words other than themselves can be anagrams"
(is (= ["Silent"]
(anagram/anagrams-for "LISTEN" ["LISTEN", "Silent"])))))

(deftest handles-greek-letters
(testing "Handles case of greek letters"
(is (= ["ΒΓΑ", "γβα"]
(anagram/anagrams-for "ΑΒΓ" ["ΒΓΑ", "ΒΓΔ", "γβα", "αβγ"])))))

(deftest different-characters-may-have-same-bytes
(testing "Different characters may have the same bytes"
(is (= []
(anagram/anagrams-for "a⬂" ["€a"])))))

0 comments on commit 8977040

Please sign in to comment.