Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 72 additions & 29 deletions exercises/practice/anagram/.meta/tests.toml
Original file line number Diff line number Diff line change
@@ -1,43 +1,86 @@
[canonical-tests]
# 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.

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

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

# does not detect anagram subsets
"a27558ee-9ba0-4552-96b1-ecf665b06556" = true
[03eb9bbe-8906-4ea0-84fa-ffe711b52c8b]
description = "detects two anagrams"
reimplements = "b3cca662-f50a-489e-ae10-ab8290a09bdc"

# detects anagram
"64cd4584-fc15-4781-b633-3d814c4941a4" = true
[a27558ee-9ba0-4552-96b1-ecf665b06556]
description = "does not detect anagram subsets"

# detects three anagrams
"99c91beb-838f-4ccd-b123-935139917283" = true
[64cd4584-fc15-4781-b633-3d814c4941a4]
description = "detects anagram"

# detects multiple anagrams with different case
"78487770-e258-4e1f-a646-8ece10950d90" = true
[99c91beb-838f-4ccd-b123-935139917283]
description = "detects three anagrams"

# does not detect non-anagrams with identical checksum
"1d0ab8aa-362f-49b7-9902-3d0c668d557b" = true
[78487770-e258-4e1f-a646-8ece10950d90]
description = "detects multiple anagrams with different case"

# detects anagrams case-insensitively
"9e632c0b-c0b1-4804-8cc1-e295dea6d8a8" = true
[1d0ab8aa-362f-49b7-9902-3d0c668d557b]
description = "does not detect non-anagrams with identical checksum"

# detects anagrams using case-insensitive subject
"b248e49f-0905-48d2-9c8d-bd02d8c3e392" = true
[9e632c0b-c0b1-4804-8cc1-e295dea6d8a8]
description = "detects anagrams case-insensitively"

# detects anagrams using case-insensitive possible matches
"f367325c-78ec-411c-be76-e79047f4bd54" = true
[b248e49f-0905-48d2-9c8d-bd02d8c3e392]
description = "detects anagrams using case-insensitive subject"

# does not detect an anagram if the original word is repeated
"7cc195ad-e3c7-44ee-9fd2-d3c344806a2c" = true
[f367325c-78ec-411c-be76-e79047f4bd54]
description = "detects anagrams using case-insensitive possible matches"

# anagrams must use all letters exactly once
"9878a1c9-d6ea-4235-ae51-3ea2befd6842" = true
[7cc195ad-e3c7-44ee-9fd2-d3c344806a2c]
description = "does not detect an anagram if the original word is repeated"
include = false

# words are not anagrams of themselves (case-insensitive)
"85757361-4535-45fd-ac0e-3810d40debc1" = true
[630abb71-a94e-4715-8395-179ec1df9f91]
description = "does not detect an anagram if the original word is repeated"
reimplements = "7cc195ad-e3c7-44ee-9fd2-d3c344806a2c"

# words other than themselves can be anagrams
"a0705568-628c-4b55-9798-82e4acde51ca" = true
[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"
40 changes: 34 additions & 6 deletions exercises/practice/anagram/src/test/kotlin/AnagramTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ class AnagramTest {
@Ignore
@Test
fun `detects two anagrams`() =
anagramsOf("master")
.searchedIn("stream", "pigeon", "maters")
.shouldBeOnly("maters", "stream")
anagramsOf("solemn")
.searchedIn("lemons", "cherry", "melons")
.shouldBeOnly("lemons", "melons")

@Ignore
@Test
Expand Down Expand Up @@ -79,7 +79,7 @@ class AnagramTest {
@Test
fun `does not detect an anagram if the original word is repeated`() =
anagramsOf("go")
.searchedIn("go Go GO")
.searchedIn("goGoGO")
.shouldBeEmpty()

@Ignore
Expand All @@ -91,17 +91,45 @@ class AnagramTest {

@Ignore
@Test
fun `words are not anagrams of themselves (case-insensitive)`() =
fun `words are not anagrams of themselves`() =
anagramsOf("BANANA")
.searchedIn("BANANA")
.shouldBeEmpty()

@Ignore
@Test
fun `words are not anagrams of themselves even if letter case is partially different`() =
anagramsOf("BANANA")
.searchedIn("Banana")
.shouldBeEmpty()

@Ignore
@Test
fun `words are not anagrams of themselves even if letter case is completely different`() =
anagramsOf("BANANA")
.searchedIn("banana")
.shouldBeEmpty()

@Ignore
@Test
fun `words other than themselves can be anagrams`() =
anagramsOf("LISTEN")
.searchedIn("Listen", "Silent", "LISTEN")
.searchedIn("LISTEN", "Silent")
.shouldBeOnly("Silent")

@Ignore
@Test
fun `handles case of greek letters`() =
anagramsOf("ΑΒΓ")
.searchedIn("ΒΓΑ", "ΒΓΔ", "γβα", "αβγ")
.shouldBeOnly("ΒΓΑ", "γβα")

@Ignore
@Test
fun `different characters may have the same bytes`() =
anagramsOf("a⬂")
.searchedIn("€a")
.shouldBeEmpty()
}

private fun anagramsOf(source: String) = Anagram(source)
Expand Down