From b0469292f81775da8b5e5a8a123d52f79b3817a5 Mon Sep 17 00:00:00 2001 From: Alexis Hope Date: Mon, 3 Apr 2023 08:08:35 +1000 Subject: [PATCH] test: clean up redundant tests --- exercises/practice/anagram/test_anagram.R | 77 +++++------------------ 1 file changed, 14 insertions(+), 63 deletions(-) diff --git a/exercises/practice/anagram/test_anagram.R b/exercises/practice/anagram/test_anagram.R index f10a1a0f..72a4d883 100644 --- a/exercises/practice/anagram/test_anagram.R +++ b/exercises/practice/anagram/test_anagram.R @@ -10,25 +10,26 @@ test_that("no matches", { c()) }) -test_that("detects simple anagram", { - subject <- "ant" - candidates <- c("tan", "stand", "at") +test_that("detects anagram", { + subject <- "listen" + candidates <- c("enlists", "google", "inlets", "banana") expect_equal(anagram(subject, candidates), - c("tan")) + c("inlets")) }) -test_that("does not detect false positives", { - subject <- "galea" - candidates <- c("eagle") +test_that("detects multiple anagrams", { + subject <- "allergy" + candidates <- + c("gallery", "ballerina", "regally", "clergy", "largely", "leading") expect_equal(anagram(subject, candidates), - c()) + c("gallery", "regally", "largely")) }) -test_that("detects multiple anagrams", { - subject <- "master" - candidates <- c("stream", "pigeon", "maters") +test_that("character overlap is disregarded", { + subject <- "galea" + candidates <- c("eagle") expect_equal(anagram(subject, candidates), - c("stream", "maters")) + c()) }) test_that("does not detect anagram subsets", { @@ -38,21 +39,6 @@ test_that("does not detect anagram subsets", { c()) }) -test_that("detects anagram", { - subject <- "listen" - candidates <- c("enlists", "google", "inlets", "banana") - expect_equal(anagram(subject, candidates), - c("inlets")) -}) - -test_that("detects multiple anagrams", { - subject <- "allergy" - candidates <- - c("gallery", "ballerina", "regally", "clergy", "largely", "leading") - expect_equal(anagram(subject, candidates), - c("gallery", "regally", "largely")) -}) - test_that("does not detect indentical words", { subject <- "corn" candidates <- c("corn", "dark", "Corn", "rank", "CORN", "cron", "park") @@ -67,20 +53,6 @@ test_that("does not detect non-anagrams with identical checksum", { c()) }) -test_that("detects anagrams case-insensitively", { - subject <- "Orchestra" - candidates <- c("cashregister", "Carthorse", "radishes") - expect_equal(anagram(subject, candidates), - c("Carthorse")) -}) - -test_that("detects anagrams using case-insensitive subject", { - subject <- "Orchestra" - candidates <- c("cashregister", "carthorse", "radishes") - expect_equal(anagram(subject, candidates), - c("carthorse")) -}) - test_that("detects anagrams using case-insensitve possible matches", { subject <- "orchestra" candidates <- c("cashregister", "Carthorse", "radishes") @@ -95,7 +67,7 @@ test_that("does not detect a word as its own anagram", { c()) }) -test_that("does not detect a anagram if the original word is repeated", { +test_that("does not detect an anagram if the original word is repeated", { subject <- "go" candidates <- c("go Go GO") expect_equal(anagram(subject, candidates), @@ -109,25 +81,4 @@ test_that("anagrams must use all letters exactly once", { c()) }) -test_that("eliminates anagrams with the same checksum", { - subject <- "mass" - candidates <- c("last") - expect_equal(anagram(subject, candidates), - c()) -}) - -test_that("capital word is not own anagram", { - subject <- "BANANA" - candidates <- c("Banana") - expect_equal(anagram(subject, candidates), - c()) -}) - -test_that("anagrams must use all letters exactly once", { - subject <- "patter" - candidates <- c("tapper") - expect_equal(anagram(subject, candidates), - c()) -}) - message("All tests passed for exercise: anagram")