Skip to content

Commit a7c03e1

Browse files
authored
Sync acronym with problem-specifications (#548)
* Rectify tests.toml for acronym This removes unimplemented test cases from the test.toml for the acronym exercise. * Remove extraneous test in acronym This deletes a test that doesn't have an equivalent spec in the canonical-data of problem-specifications. * Normalize test descriptions in acronym This updates the test descriptions to match those in the canonical-data in problem-specifications. * Sync acronym with problem-specifications This brings in changes to the instructions, adds several tests, and normalizes the config.json file for the exercise. * Attempt to fix failing test I haven't gotten C++ working locally yet; leaning on CI.
1 parent 4f60551 commit a7c03e1

File tree

5 files changed

+60
-17
lines changed

5 files changed

+60
-17
lines changed

exercises/practice/acronym/.docs/instructions.md

+11-2
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,14 @@ Convert a phrase to its acronym.
44

55
Techies love their TLA (Three Letter Acronyms)!
66

7-
Help generate some jargon by writing a program that converts a long name
8-
like Portable Network Graphics to its acronym (PNG).
7+
Help generate some jargon by writing a program that converts a long name like Portable Network Graphics to its acronym (PNG).
8+
9+
Punctuation is handled as follows: hyphens are word separators (like whitespace); all other punctuation can be removed from the input.
10+
11+
For example:
12+
13+
|Input|Output|
14+
|-|-|
15+
|As Soon As Possible|ASAP|
16+
|Liquid-crystal display|LCD|
17+
|Thank George It's Friday!|TGIF|

exercises/practice/acronym/.meta/config.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
2-
"blurb": "Convert a long phrase to its acronym",
32
"authors": [
43
"chgraef"
54
],
65
"contributors": [
76
"elyashiv",
87
"KevinWMatthews",
9-
"patricksjackson"
8+
"patricksjackson",
9+
"kytrinyx"
1010
],
1111
"files": {
1212
"solution": [
@@ -21,6 +21,7 @@
2121
".meta/example.h"
2222
]
2323
},
24+
"blurb": "Convert a long phrase to its acronym.",
2425
"source": "Julien Vanier",
2526
"source_url": "https://github.com/monkbroc"
2627
}

exercises/practice/acronym/.meta/example.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace acronym {
77

88
string acronym(string const &input_str) {
99
string acronym_str;
10-
string delimiters = " :-,";
10+
string delimiters = " :-,_";
1111
enum DelimiterState { NOT_FOUND, FOUND };
1212
DelimiterState delimiter_state = FOUND;
1313
for (char c : input_str) {

exercises/practice/acronym/.meta/tests.toml

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1-
# This is an auto-generated file. Regular comments will be removed when this
2-
# file is regenerated. Regenerating will not touch any manually added keys,
3-
# so comments can be added in a "comment" key.
1+
# This is an auto-generated file.
2+
#
3+
# Regenerating this file via `configlet sync` will:
4+
# - Recreate every `description` key/value pair
5+
# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications
6+
# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion)
7+
# - Preserve any other key/value pair
8+
#
9+
# As user-added comments (using the # character) will be removed when this file
10+
# is regenerated, comments can be added via a `comment` key.
411

512
[1e22cceb-c5e4-4562-9afe-aef07ad1eaf4]
613
description = "basic"

exercises/practice/acronym/acronym_test.cpp

+35-9
Original file line numberDiff line numberDiff line change
@@ -35,31 +35,57 @@ TEST_CASE("punctuation")
3535
REQUIRE(expected == actual);
3636
}
3737

38-
TEST_CASE("all_caps_words")
38+
TEST_CASE("all_caps_word")
3939
{
40-
const string actual = acronym::acronym("PHP: Hypertext Preprocessor");
40+
const string actual = acronym::acronym("GNU Image Manipulation Program");
4141

42-
const string expected{"PHP"};
42+
const string expected{"GIMP"};
4343

4444
REQUIRE(expected == actual);
4545
}
4646

47-
TEST_CASE("non_acronym_all_caps_word")
47+
TEST_CASE("punctuation_without_whitespace")
4848
{
49-
const string actual = acronym::acronym("GNU Image Manipulation Program");
49+
const string actual = acronym::acronym("Complementary metal-oxide semiconductor");
5050

51-
const string expected{"GIMP"};
51+
const string expected{"CMOS"};
5252

5353
REQUIRE(expected == actual);
5454
}
5555

56-
TEST_CASE("hyphenated")
56+
TEST_CASE("very_long_abbreviation")
5757
{
58-
const string actual = acronym::acronym("Complementary metal-oxide semiconductor");
58+
const string actual = acronym::acronym("Rolling On The Floor Laughing So Hard That My Dogs Came Over And Licked Me");
5959

60-
const string expected{"CMOS"};
60+
const string expected{"ROTFLSHTMDCOALM"};
6161

6262
REQUIRE(expected == actual);
6363
}
6464

65+
TEST_CASE("consecutive_delimiters")
66+
{
67+
const string actual = acronym::acronym("Something - I made up from thin air");
68+
69+
const string expected{"SIMUFTA"};
70+
71+
REQUIRE(expected == actual);
72+
}
73+
74+
TEST_CASE("apostrophes")
75+
{
76+
const string actual = acronym::acronym("Halley's Comet");
77+
78+
const string expected{"HC"};
79+
80+
REQUIRE(expected == actual);
81+
}
82+
83+
TEST_CASE("underscore_emphasis")
84+
{
85+
const string actual = acronym::acronym("The Road _Not_ Taken");
86+
87+
const string expected{"TRNT"};
88+
89+
REQUIRE(expected == actual);
90+
}
6591
#endif

0 commit comments

Comments
 (0)