Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isogram: sync #1941

Merged
merged 1 commit into from
Jul 10, 2024
Merged
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
13 changes: 13 additions & 0 deletions exercises/practice/isogram/.meta/test_template.tera
Original file line number Diff line number Diff line change
@@ -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 -%}
43 changes: 40 additions & 3 deletions exercises/practice/isogram/.meta/tests.toml
Original file line number Diff line number Diff line change
@@ -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"
79 changes: 44 additions & 35 deletions exercises/practice/isogram/tests/isogram.rs
Original file line number Diff line number Diff line change
@@ -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"));
}