diff --git a/exercises/practice/acronym/.docs/instructions.md b/exercises/practice/acronym/.docs/instructions.md index e0515b4d1..c62fc3e85 100644 --- a/exercises/practice/acronym/.docs/instructions.md +++ b/exercises/practice/acronym/.docs/instructions.md @@ -4,5 +4,14 @@ Convert a phrase to its acronym. Techies love their TLA (Three Letter Acronyms)! -Help generate some jargon by writing a program that converts a long name -like Portable Network Graphics to its acronym (PNG). +Help generate some jargon by writing a program that converts a long name like Portable Network Graphics to its acronym (PNG). + +Punctuation is handled as follows: hyphens are word separators (like whitespace); all other punctuation can be removed from the input. + +For example: + +|Input|Output| +|-|-| +|As Soon As Possible|ASAP| +|Liquid-crystal display|LCD| +|Thank George It's Friday!|TGIF| diff --git a/exercises/practice/acronym/.meta/test_template.tera b/exercises/practice/acronym/.meta/test_template.tera new file mode 100644 index 000000000..36437457f --- /dev/null +++ b/exercises/practice/acronym/.meta/test_template.tera @@ -0,0 +1,12 @@ +{% for test in cases %} +#[test] +{% if loop.index != 1 -%} +#[ignore] +{% endif -%} +fn {{ test.description | replace(from=" ", to="_") }}() { + let input = "{{ test.input.phrase }}"; + let output = acronym::abbreviate(input); + let expected = "{{ test.expected }}"; + assert_eq!(output, expected); +} +{% endfor -%} diff --git a/exercises/practice/acronym/.meta/tests.toml b/exercises/practice/acronym/.meta/tests.toml index 157cae14e..6e3277c68 100644 --- a/exercises/practice/acronym/.meta/tests.toml +++ b/exercises/practice/acronym/.meta/tests.toml @@ -1,6 +1,13 @@ -# 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. [1e22cceb-c5e4-4562-9afe-aef07ad1eaf4] description = "basic" diff --git a/exercises/practice/acronym/tests/acronym.rs b/exercises/practice/acronym/tests/acronym.rs index decf634f9..e90d943a1 100644 --- a/exercises/practice/acronym/tests/acronym.rs +++ b/exercises/practice/acronym/tests/acronym.rs @@ -1,84 +1,79 @@ #[test] -fn empty() { - assert_eq!(acronym::abbreviate(""), ""); -} - -#[test] -#[ignore] fn basic() { - assert_eq!(acronym::abbreviate("Portable Network Graphics"), "PNG"); + let input = "Portable Network Graphics"; + let output = acronym::abbreviate(input); + let expected = "PNG"; + assert_eq!(output, expected); } #[test] #[ignore] fn lowercase_words() { - assert_eq!(acronym::abbreviate("Ruby on Rails"), "ROR"); -} - -#[test] -#[ignore] -fn camelcase() { - assert_eq!(acronym::abbreviate("HyperText Markup Language"), "HTML"); + let input = "Ruby on Rails"; + let output = acronym::abbreviate(input); + let expected = "ROR"; + assert_eq!(output, expected); } #[test] #[ignore] fn punctuation() { - assert_eq!(acronym::abbreviate("First In, First Out"), "FIFO"); + let input = "First In, First Out"; + let output = acronym::abbreviate(input); + let expected = "FIFO"; + assert_eq!(output, expected); } #[test] #[ignore] fn all_caps_word() { - assert_eq!( - acronym::abbreviate("GNU Image Manipulation Program"), - "GIMP" - ); -} - -#[test] -#[ignore] -fn all_caps_word_with_punctuation() { - assert_eq!(acronym::abbreviate("PHP: Hypertext Preprocessor"), "PHP"); + let input = "GNU Image Manipulation Program"; + let output = acronym::abbreviate(input); + let expected = "GIMP"; + assert_eq!(output, expected); } #[test] #[ignore] fn punctuation_without_whitespace() { - assert_eq!( - acronym::abbreviate("Complementary metal-oxide semiconductor"), - "CMOS" - ); + let input = "Complementary metal-oxide semiconductor"; + let output = acronym::abbreviate(input); + let expected = "CMOS"; + assert_eq!(output, expected); } #[test] #[ignore] fn very_long_abbreviation() { - assert_eq!( - acronym::abbreviate( - "Rolling On The Floor Laughing So Hard That My Dogs Came Over And Licked Me" - ), - "ROTFLSHTMDCOALM" - ); + let input = "Rolling On The Floor Laughing So Hard That My Dogs Came Over And Licked Me"; + let output = acronym::abbreviate(input); + let expected = "ROTFLSHTMDCOALM"; + assert_eq!(output, expected); } #[test] #[ignore] fn consecutive_delimiters() { - assert_eq!( - acronym::abbreviate("Something - I made up from thin air"), - "SIMUFTA" - ); + let input = "Something - I made up from thin air"; + let output = acronym::abbreviate(input); + let expected = "SIMUFTA"; + assert_eq!(output, expected); } #[test] #[ignore] fn apostrophes() { - assert_eq!(acronym::abbreviate("Halley's Comet"), "HC"); + let input = "Halley's Comet"; + let output = acronym::abbreviate(input); + let expected = "HC"; + assert_eq!(output, expected); } #[test] #[ignore] fn underscore_emphasis() { - assert_eq!(acronym::abbreviate("The Road _Not_ Taken"), "TRNT"); + let input = "The Road _Not_ Taken"; + let output = acronym::abbreviate(input); + let expected = "TRNT"; + assert_eq!(output, expected); }