diff --git a/exercises/practice/isogram/.meta/test_template.tera b/exercises/practice/isogram/.meta/test_template.tera new file mode 100644 index 000000000..51bd452ba --- /dev/null +++ b/exercises/practice/isogram/.meta/test_template.tera @@ -0,0 +1,13 @@ +use isogram::*; + +{% for test in cases %} +#[test] +#[ignore] +fn {{ test.description | snake_case }}() { + {% if test.expected %} + assert!(check({{ test.input.phrase | json_encode() }})); + {% else %} + assert!(!check({{ test.input.phrase | json_encode() }})); + {% endif %} +} +{% endfor -%} diff --git a/exercises/practice/isogram/.meta/tests.toml b/exercises/practice/isogram/.meta/tests.toml index cf1f7ea7d..ba04c6645 100644 --- a/exercises/practice/isogram/.meta/tests.toml +++ b/exercises/practice/isogram/.meta/tests.toml @@ -1,15 +1,52 @@ -# 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. [a0e97d2d-669e-47c7-8134-518a1e2c4555] description = "empty string" +[9a001b50-f194-4143-bc29-2af5ec1ef652] +description = "isogram with only lower case characters" + +[8ddb0ca3-276e-4f8b-89da-d95d5bae78a4] +description = "word with one duplicated character" + +[6450b333-cbc2-4b24-a723-0b459b34fe18] +description = "word with one duplicated character from the end of the alphabet" + [a15ff557-dd04-4764-99e7-02cc1a385863] description = "longest reported english isogram" +[f1a7f6c7-a42f-4915-91d7-35b2ea11c92e] +description = "word with duplicated character in mixed case" + +[14a4f3c1-3b47-4695-b645-53d328298942] +description = "word with duplicated character in mixed case, lowercase first" + +[423b850c-7090-4a8a-b057-97f1cadd7c42] +description = "hypothetical isogrammic word with hyphen" + +[93dbeaa0-3c5a-45c2-8b25-428b8eacd4f2] +description = "hypothetical word with duplicated character following hyphen" + [36b30e5c-173f-49c6-a515-93a3e825553f] description = "isogram with duplicated hyphen" +[cdabafa0-c9f4-4c1f-b142-689c6ee17d93] +description = "made-up name that is an isogram" + [5fc61048-d74e-48fd-bc34-abfc21552d4d] description = "duplicated character in the middle" + +[310ac53d-8932-47bc-bbb4-b2b94f25a83e] +description = "same first and last characters" + +[0d0b8644-0a1e-4a31-a432-2b3ee270d847] +description = "word with duplicated character and with two hyphens" diff --git a/exercises/practice/isogram/tests/isogram.rs b/exercises/practice/isogram/tests/isogram.rs index b0c6a2d21..29ee0e0b3 100644 --- a/exercises/practice/isogram/tests/isogram.rs +++ b/exercises/practice/isogram/tests/isogram.rs @@ -1,75 +1,84 @@ -use isogram::check; +use isogram::*; #[test] fn empty_string() { - assert!(check(""), "An empty string should be an isogram.") + assert!(check("")); } #[test] #[ignore] -fn only_lower_case_characters() { - assert!(check("isogram"), "\"isogram\" should be an isogram.") +fn isogram_with_only_lower_case_characters() { + assert!(check("isogram")); } #[test] #[ignore] -fn one_duplicated_character() { - assert!( - !check("eleven"), - "\"eleven\" has more than one \'e\', therefore it is no isogram." - ) +fn word_with_one_duplicated_character() { + assert!(!check("eleven")); +} + +#[test] +#[ignore] +fn word_with_one_duplicated_character_from_the_end_of_the_alphabet() { + assert!(!check("zzyzx")); } #[test] #[ignore] fn longest_reported_english_isogram() { - assert!( - check("subdermatoglyphic"), - "\"subdermatoglyphic\" should be an isogram." - ) + assert!(check("subdermatoglyphic")); +} + +#[test] +#[ignore] +fn word_with_duplicated_character_in_mixed_case() { + assert!(!check("Alphabet")); +} + +#[test] +#[ignore] +fn word_with_duplicated_character_in_mixed_case_lowercase_first() { + assert!(!check("alphAbet")); } #[test] #[ignore] -fn one_duplicated_character_mixed_case() { - assert!( - !check("Alphabet"), - "\"Alphabet\" has more than one \'a\', therefore it is no isogram." - ) +fn hypothetical_isogrammic_word_with_hyphen() { + assert!(check("thumbscrew-japingly")); } #[test] #[ignore] -fn hypothetical_isogramic_word_with_hyphen() { - assert!( - check("thumbscrew-japingly"), - "\"thumbscrew-japingly\" should be an isogram." - ) +fn hypothetical_word_with_duplicated_character_following_hyphen() { + assert!(!check("thumbscrew-jappingly")); } #[test] #[ignore] fn isogram_with_duplicated_hyphen() { - assert!( - check("six-year-old"), - "\"six-year-old\" should be an isogram." - ) + assert!(check("six-year-old")); } #[test] #[ignore] fn made_up_name_that_is_an_isogram() { - assert!( - check("Emily Jung Schwartzkopf"), - "\"Emily Jung Schwartzkopf\" should be an isogram." - ) + assert!(check("Emily Jung Schwartzkopf")); } #[test] #[ignore] fn duplicated_character_in_the_middle() { - assert!( - !check("accentor"), - "\"accentor\" has more than one \'c\', therefore it is no isogram." - ) + assert!(!check("accentor")); +} + +#[test] +#[ignore] +fn same_first_and_last_characters() { + assert!(!check("angola")); +} + +#[test] +#[ignore] +fn word_with_duplicated_character_and_with_two_hyphens() { + assert!(!check("up-to-date")); }