From 2ba57bf4b5aaf8490354683255f3fec30021edb4 Mon Sep 17 00:00:00 2001 From: Sander Ploegsma Date: Sun, 31 Mar 2024 07:49:45 +0200 Subject: [PATCH] anagram: Sync tests (#2762) [no important files changed] --- exercises/practice/anagram/.meta/config.json | 1 + exercises/practice/anagram/.meta/tests.toml | 6 ++ .../anagram/src/test/java/AnagramTest.java | 87 +++++++++++-------- 3 files changed, 59 insertions(+), 35 deletions(-) diff --git a/exercises/practice/anagram/.meta/config.json b/exercises/practice/anagram/.meta/config.json index 97be25071..1fae320a1 100644 --- a/exercises/practice/anagram/.meta/config.json +++ b/exercises/practice/anagram/.meta/config.json @@ -17,6 +17,7 @@ "muzimuzhi", "redshirt4", "rohit1104", + "sanderploegsma", "sjwarner-bp", "SleeplessByte", "Smarticles101", diff --git a/exercises/practice/anagram/.meta/tests.toml b/exercises/practice/anagram/.meta/tests.toml index 4f43811d2..4d9056270 100644 --- a/exercises/practice/anagram/.meta/tests.toml +++ b/exercises/practice/anagram/.meta/tests.toml @@ -78,3 +78,9 @@ 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" diff --git a/exercises/practice/anagram/src/test/java/AnagramTest.java b/exercises/practice/anagram/src/test/java/AnagramTest.java index e15a85369..e5434291a 100644 --- a/exercises/practice/anagram/src/test/java/AnagramTest.java +++ b/exercises/practice/anagram/src/test/java/AnagramTest.java @@ -1,11 +1,11 @@ -import static org.assertj.core.api.Assertions.assertThat; - import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.Collections; +import static org.assertj.core.api.Assertions.assertThat; + public class AnagramTest { @Test @@ -13,9 +13,9 @@ public void testNoMatches() { Anagram detector = new Anagram("diaper"); assertThat( - detector.match( - Arrays.asList("hello", "world", "zombies", "pants"))) - .isEmpty(); + detector.match( + Arrays.asList("hello", "world", "zombies", "pants"))) + .isEmpty(); } @Disabled("Remove to run test") @@ -24,7 +24,7 @@ public void testDetectsTwoAnagrams() { Anagram detector = new Anagram("solemn"); assertThat(detector.match(Arrays.asList("lemons", "cherry", "melons"))) - .containsExactlyInAnyOrder("lemons", "melons"); + .containsExactlyInAnyOrder("lemons", "melons"); } @Disabled("Remove to run test") @@ -41,9 +41,9 @@ public void testDetectLongerAnagram() { Anagram detector = new Anagram("listen"); assertThat( - detector.match( - Arrays.asList("enlists", "google", "inlets", "banana"))) - .containsExactlyInAnyOrder("inlets"); + detector.match( + Arrays.asList("enlists", "google", "inlets", "banana"))) + .containsExactlyInAnyOrder("inlets"); } @Disabled("Remove to run test") @@ -51,15 +51,15 @@ public void testDetectLongerAnagram() { public void testDetectMultipleAnagramsForLongerWord() { Anagram detector = new Anagram("allergy"); assertThat( - detector.match( - Arrays.asList( - "gallery", - "ballerina", - "regally", - "clergy", - "largely", - "leading"))) - .containsExactlyInAnyOrder("gallery", "regally", "largely"); + detector.match( + Arrays.asList( + "gallery", + "ballerina", + "regally", + "clergy", + "largely", + "leading"))) + .containsExactlyInAnyOrder("gallery", "regally", "largely"); } @Disabled("Remove to run test") @@ -68,7 +68,7 @@ public void testDetectsMultipleAnagramsWithDifferentCase() { Anagram detector = new Anagram("nose"); assertThat(detector.match(Arrays.asList("Eons", "ONES"))) - .containsExactlyInAnyOrder("Eons", "ONES"); + .containsExactlyInAnyOrder("Eons", "ONES"); } @Disabled("Remove to run test") @@ -77,7 +77,7 @@ public void testEliminateAnagramsWithSameChecksum() { Anagram detector = new Anagram("mass"); assertThat(detector.match(Collections.singletonList("last"))) - .isEmpty(); + .isEmpty(); } @Disabled("Remove to run test") @@ -86,9 +86,9 @@ public void testCaseInsensitiveWhenBothAnagramAndSubjectStartWithUpperCaseLetter Anagram detector = new Anagram("Orchestra"); assertThat( - detector.match( - Arrays.asList("cashregister", "Carthorse", "radishes"))) - .containsExactlyInAnyOrder("Carthorse"); + detector.match( + Arrays.asList("cashregister", "Carthorse", "radishes"))) + .containsExactlyInAnyOrder("Carthorse"); } @Disabled("Remove to run test") @@ -97,9 +97,9 @@ public void testCaseInsensitiveWhenSubjectStartsWithUpperCaseLetter() { Anagram detector = new Anagram("Orchestra"); assertThat( - detector.match( - Arrays.asList("cashregister", "carthorse", "radishes"))) - .containsExactlyInAnyOrder("carthorse"); + detector.match( + Arrays.asList("cashregister", "carthorse", "radishes"))) + .containsExactlyInAnyOrder("carthorse"); } @Disabled("Remove to run test") @@ -108,9 +108,9 @@ public void testCaseInsensitiveWhenAnagramStartsWithUpperCaseLetter() { Anagram detector = new Anagram("orchestra"); assertThat( - detector.match( - Arrays.asList("cashregister", "Carthorse", "radishes"))) - .containsExactlyInAnyOrder("Carthorse"); + detector.match( + Arrays.asList("cashregister", "Carthorse", "radishes"))) + .containsExactlyInAnyOrder("Carthorse"); } @Disabled("Remove to run test") @@ -119,7 +119,7 @@ public void testIdenticalWordRepeatedIsNotAnagram() { Anagram detector = new Anagram("go"); assertThat(detector.match(Collections.singletonList("goGoGO"))) - .isEmpty(); + .isEmpty(); } @Disabled("Remove to run test") @@ -128,7 +128,7 @@ public void testAnagramMustUseAllLettersExactlyOnce() { Anagram detector = new Anagram("tapper"); assertThat(detector.match(Collections.singletonList("patter"))) - .isEmpty(); + .isEmpty(); } @Disabled("Remove to run test") @@ -137,7 +137,7 @@ public void testWordsAreNotAnagramsOfThemselvesCaseInsensitive() { Anagram detector = new Anagram("BANANA"); assertThat(detector.match(Collections.singletonList("BANANA"))) - .isEmpty(); + .isEmpty(); } @Disabled("Remove to run test") @@ -146,7 +146,7 @@ public void testWordsAreNotAnagramsOfThemselvesEvenIfLetterCaseIsPartiallyDiffer Anagram detector = new Anagram("BANANA"); assertThat(detector.match(Collections.singletonList("Banana"))) - .isEmpty(); + .isEmpty(); } @Disabled("Remove to run test") @@ -155,7 +155,7 @@ public void testWordsAreNotAnagramsOfThemselvesEvenIfLetterCaseIsCompletelyDiffe Anagram detector = new Anagram("BANANA"); assertThat(detector.match(Collections.singletonList("banana"))) - .isEmpty(); + .isEmpty(); } @Disabled("Remove to run test") @@ -164,7 +164,24 @@ public void testWordsOtherThanThemselvesCanBeAnagrams() { Anagram detector = new Anagram("LISTEN"); assertThat(detector.match(Arrays.asList("LISTEN", "Silent"))) - .containsExactlyInAnyOrder("Silent"); + .containsExactlyInAnyOrder("Silent"); } + @Disabled("Remove to run test") + @Test + public void testHandlesCaseOfGreekLetters() { + Anagram detector = new Anagram("ΑΒΓ"); + + assertThat(detector.match(Arrays.asList("ΒΓΑ", "ΒΓΔ", "γβα", "αβγ"))) + .containsExactlyInAnyOrder("ΒΓΑ", "γβα"); + } + + @Disabled("Remove to run test") + @Test + public void testDifferentCharactersWithSameBytes() { + Anagram detector = new Anagram("a⬂"); + + assertThat(detector.match(Collections.singletonList("€a"))) + .isEmpty(); + } }