Skip to content

Commit

Permalink
add: verbose testing
Browse files Browse the repository at this point in the history
- rna-transcription
- scrabble-score
- reverse-string
- isogram
- anagram
  • Loading branch information
yctai1994 committed Jan 14, 2024
1 parent e08adf4 commit a9a235f
Show file tree
Hide file tree
Showing 5 changed files with 244 additions and 235 deletions.
158 changes: 80 additions & 78 deletions exercises/practice/anagram/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,82 +2,84 @@ using Test

include("anagram.jl")

@testset "no matches" begin
@test detect_anagrams("diaper", ["hello", "world", "zombies", "pants"]) == []
end

@testset "detects simple anagram" begin
@test detect_anagrams("ant", ["tan", "stand", "at"]) == ["tan"]
end

@testset "does not detect false positives" begin
@test detect_anagrams("galea", ["eagle"]) == []
end

@testset "detects two anagrams" begin
@test detect_anagrams("master", ["stream", "pigeon", "maters"]) == ["stream", "maters"]
end

@testset "does not detect anagram subsets" begin
@test detect_anagrams("good", ["dog", "goody"]) == []
end

@testset "detects anagram" begin
@test detect_anagrams("listen", ["enlists", "google", "inlets", "banana"]) == ["inlets"]
end

@testset "detects three anagrams" begin
@test detect_anagrams("allergy", ["gallery", "ballerina", "regally", "clergy", "largely", "leading"]) == ["gallery", "regally", "largely"]
end

@testset "detects multiple anagrams with different case" begin
@test detect_anagrams("nose", ["Eons", "ONES"]) == ["Eons", "ONES"]
end

@testset "does not detect identical words" begin
@test detect_anagrams("corn", ["corn", "dark", "Corn", "rank", "CORN", "cron", "park"]) == ["cron"]
end

@testset "does not detect non-anagrams with identical checksum" begin
@test detect_anagrams("mass", ["last"]) == []
end

@testset "detects anagrams case-insensitively" begin
@test detect_anagrams("Orchestra", ["cashregister", "Carthorse", "radishes"]) == ["Carthorse"]
end

@testset "detects anagrams using case-insensitive subject" begin
@test detect_anagrams("Orchestra", ["cashregister", "carthorse", "radishes"]) == ["carthorse"]
end

@testset "detects anagrams using case-insensitive possible matches" begin
@test detect_anagrams("orchestra", ["cashregister", "Carthorse", "radishes"]) == ["Carthorse"]
end

@testset "does not detect an anagram if the original word is repeated" begin
@test detect_anagrams("go", ["go Go GO"]) == []
end

@testset "does not detect a word as its own anagram" begin
@test detect_anagrams("banana", ["Banana"]) == []
end

@testset "does not detect a anagram if the original word is repeated" begin
@test detect_anagrams("go", ["go Go GO"]) == []
end

@testset "anagrams must use all letters exactly once" begin
@test detect_anagrams("tapper", ["patter"]) == []
end

@testset "words are not anagrams of themselves (case-insensitive)" begin
@test detect_anagrams("BANANA", ["BANANA", "Banana", "banana"]) == []
end

@testset "words other than themselves can be anagrams" begin
@test detect_anagrams("LISTEN", ["Listen", "Silent", "LISTEN"]) == ["Silent"]
end

@testset "capital word is not own anagram" begin
@test detect_anagrams("BANANA", ["Banana"]) == []
@testset verbose = true "Anagram" begin
@testset "no matches" begin
@test detect_anagrams("diaper", ["hello", "world", "zombies", "pants"]) == String[]
end

@testset "detects simple anagram" begin
@test detect_anagrams("ant", ["tan", "stand", "at"]) == ["tan"]
end

@testset "does not detect false positives" begin
@test detect_anagrams("galea", ["eagle"]) == String[]
end

@testset "detects two anagrams" begin
@test detect_anagrams("master", ["stream", "pigeon", "maters"]) == ["stream", "maters"]
end

@testset "does not detect anagram subsets" begin
@test detect_anagrams("good", ["dog", "goody"]) == String[]
end

@testset "detects anagram" begin
@test detect_anagrams("listen", ["enlists", "google", "inlets", "banana"]) == ["inlets"]
end

@testset "detects three anagrams" begin
@test detect_anagrams("allergy", ["gallery", "ballerina", "regally", "clergy", "largely", "leading"]) == ["gallery", "regally", "largely"]
end

@testset "detects multiple anagrams with different case" begin
@test detect_anagrams("nose", ["Eons", "ONES"]) == ["Eons", "ONES"]
end

@testset "does not detect identical words" begin
@test detect_anagrams("corn", ["corn", "dark", "Corn", "rank", "CORN", "cron", "park"]) == ["cron"]
end

@testset "does not detect non-anagrams with identical checksum" begin
@test detect_anagrams("mass", ["last"]) == String[]
end

@testset "detects anagrams case-insensitively" begin
@test detect_anagrams("Orchestra", ["cashregister", "Carthorse", "radishes"]) == ["Carthorse"]
end

@testset "detects anagrams using case-insensitive subject" begin
@test detect_anagrams("Orchestra", ["cashregister", "carthorse", "radishes"]) == ["carthorse"]
end

@testset "detects anagrams using case-insensitive possible matches" begin
@test detect_anagrams("orchestra", ["cashregister", "Carthorse", "radishes"]) == ["Carthorse"]
end

@testset "does not detect an anagram if the original word is repeated" begin
@test detect_anagrams("go", ["go Go GO"]) == String[]
end

@testset "does not detect a word as its own anagram" begin
@test detect_anagrams("banana", ["Banana"]) == String[]
end

@testset "does not detect a anagram if the original word is repeated" begin
@test detect_anagrams("go", ["go Go GO"]) == String[]
end

@testset "anagrams must use all letters exactly once" begin
@test detect_anagrams("tapper", ["patter"]) == String[]
end

@testset "words are not anagrams of themselves (case-insensitive)" begin
@test detect_anagrams("BANANA", ["BANANA", "Banana", "banana"]) == String[]
end

@testset "words other than themselves can be anagrams" begin
@test detect_anagrams("LISTEN", ["Listen", "Silent", "LISTEN"]) == ["Silent"]
end

@testset "capital word is not own anagram" begin
@test detect_anagrams("BANANA", ["Banana"]) == String[]
end
end
110 changes: 56 additions & 54 deletions exercises/practice/isogram/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,58 +2,60 @@ using Test

include("isogram.jl")

@testset "empty string" begin
@test isisogram("")
end

@testset "isogram with only lower case characters" begin
@test isisogram("isogram")
end

@testset "word with one duplicated character" begin
@test !isisogram("eleven")
end

@testset "longest reported english isogram" begin
@test isisogram("subdermatoglyphic")
end

@testset "word with duplicated character in mixed case" begin
@test !isisogram("Alphabet")
end

@testset "hypothetical isogrammic word with hyphen" begin
@test isisogram("thumbscrew-japingly")
end

@testset "isogram with duplicated non letter character" begin
@test isisogram("Hjelmqvist-Gryb-Zock-Pfund-Wax")
end

@testset "made-up name that is an isogram" begin
@test isisogram("Emily Jung Schwartzkopf")
end

@testset "word with one duplicated character from the end of the alphabet" begin
@test !isisogram("zzyzx")
end

@testset "word with duplicated character in mixed case, lowercase first" begin
@test !isisogram("alphAbet")
end

@testset "hypothetical word with duplicated character following hyphen" begin
@test !isisogram("thumbscrew-jappingly")
end

@testset "isogram with duplicated hyphen" begin
@test isisogram("six-year-old")
end

@testset "duplicated character in the middle" begin
@test !isisogram("accentor")
end

@testset "same first and last characters" begin
@test !isisogram("angola")
@testset verbose = true "Isogram" begin
@testset "empty string" begin
@test isisogram("")
end

@testset "isogram with only lower case characters" begin
@test isisogram("isogram")
end

@testset "word with one duplicated character" begin
@test !isisogram("eleven")
end

@testset "longest reported english isogram" begin
@test isisogram("subdermatoglyphic")
end

@testset "word with duplicated character in mixed case" begin
@test !isisogram("Alphabet")
end

@testset "hypothetical isogrammic word with hyphen" begin
@test isisogram("thumbscrew-japingly")
end

@testset "isogram with duplicated non letter character" begin
@test isisogram("Hjelmqvist-Gryb-Zock-Pfund-Wax")
end

@testset "made-up name that is an isogram" begin
@test isisogram("Emily Jung Schwartzkopf")
end

@testset "word with one duplicated character from the end of the alphabet" begin
@test !isisogram("zzyzx")
end

@testset "word with duplicated character in mixed case, lowercase first" begin
@test !isisogram("alphAbet")
end

@testset "hypothetical word with duplicated character following hyphen" begin
@test !isisogram("thumbscrew-jappingly")
end

@testset "isogram with duplicated hyphen" begin
@test isisogram("six-year-old")
end

@testset "duplicated character in the middle" begin
@test !isisogram("accentor")
end

@testset "same first and last characters" begin
@test !isisogram("angola")
end
end
59 changes: 30 additions & 29 deletions exercises/practice/reverse-string/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,43 @@ using Test

include("reverse-string.jl")

@testset verbose = true "Reverse String" begin
@testset "an empty string" begin
@test myreverse("") == ""
end

@testset "an empty string" begin
@test myreverse("") == ""
end

@testset "a word" begin
@test myreverse("robot") == "tobor"
end
@testset "a word" begin
@test myreverse("robot") == "tobor"
end

@testset "a capitalized word" begin
@test myreverse("Ramen") == "nemaR"
end
@testset "a capitalized word" begin
@test myreverse("Ramen") == "nemaR"
end

@testset "a sentence with punctuation" begin
@test myreverse("I'm hungry!") == "!yrgnuh m'I"
end
@testset "a sentence with punctuation" begin
@test myreverse("I'm hungry!") == "!yrgnuh m'I"
end

@testset "a palindrome" begin
@test myreverse("racecar") == "racecar"
end
@testset "a palindrome" begin
@test myreverse("racecar") == "racecar"
end

@testset "an even-sized word" begin
@test myreverse("drawer") == "reward"
end
@testset "an even-sized word" begin
@test myreverse("drawer") == "reward"
end

@testset "reversing a string twice" begin
@test myreverse(myreverse("gift")) == "gift"
end
@testset "reversing a string twice" begin
@test myreverse(myreverse("gift")) == "gift"
end

@testset "emoji" begin
@test myreverse("hi 🐱") == "🐱 ih"
end
@testset "emoji" begin
@test myreverse("hi 🐱") == "🐱 ih"
end

if @isdefined(TEST_GRAPHEMES)
@eval @testset "graphemes" begin
@test myreverse("as⃝df̅") == "f̅ds⃝a"
@test myreverse("hi 👋🏾") == "👋🏾 ih"
if @isdefined(TEST_GRAPHEMES)
@eval @testset "graphemes" begin
@test myreverse("as⃝df̅") == "f̅ds⃝a"
@test myreverse("hi 👋🏾") == "👋🏾 ih"
end
end
end
Loading

0 comments on commit a9a235f

Please sign in to comment.