Skip to content

Commit 8c494a4

Browse files
Elahi-csElahi Concha
andauthored
tests: update say exercise (#903)
* tests: update say exercise * Call in_english instead of say, fix clang formatting * Reformat error test cases --------- Co-authored-by: Elahi Concha <[email protected]>
1 parent 9f2e2e7 commit 8c494a4

File tree

2 files changed

+77
-54
lines changed

2 files changed

+77
-54
lines changed

exercises/practice/say/.meta/tests.toml

Lines changed: 22 additions & 3 deletions
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
[5d22a120-ba0c-428c-bd25-8682235d83e8]
613
description = "zero"
@@ -17,12 +24,24 @@ description = "twenty"
1724
[d78601eb-4a84-4bfa-bf0e-665aeb8abe94]
1825
description = "twenty-two"
1926

27+
[f010d4ca-12c9-44e9-803a-27789841adb1]
28+
description = "thirty"
29+
30+
[738ce12d-ee5c-4dfb-ad26-534753a98327]
31+
description = "ninety-nine"
32+
2033
[e417d452-129e-4056-bd5b-6eb1df334dce]
2134
description = "one hundred"
2235

2336
[d6924f30-80ba-4597-acf6-ea3f16269da8]
2437
description = "one hundred twenty-three"
2538

39+
[2f061132-54bc-4fd4-b5df-0a3b778959b9]
40+
description = "two hundred"
41+
42+
[feed6627-5387-4d38-9692-87c0dbc55c33]
43+
description = "nine hundred ninety-nine"
44+
2645
[3d83da89-a372-46d3-b10d-de0c792432b3]
2746
description = "one thousand"
2847

exercises/practice/say/say_test.cpp

Lines changed: 55 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -5,93 +5,97 @@
55
#include "test/catch.hpp"
66
#endif
77

8-
TEST_CASE("zero")
9-
{
10-
REQUIRE("zero" == say::in_english(0ULL));
8+
/*
9+
An 'error' object is used as expected value to indicate that the
10+
input value is out of the range described in the exercise.
11+
*/
12+
13+
TEST_CASE("zero", "[5d22a120-ba0c-428c-bd25-8682235d83e8]") {
14+
REQUIRE("zero" == say::in_english(0));
1115
}
1216

1317
#if defined(EXERCISM_RUN_ALL_TESTS)
14-
TEST_CASE("one")
15-
{
16-
REQUIRE("one" == say::in_english(1ULL));
18+
19+
TEST_CASE("one", "[9b5eed77-dbf6-439d-b920-3f7eb58928f6]") {
20+
REQUIRE("one" == say::in_english(1));
21+
}
22+
23+
TEST_CASE("fourteen", "[7c499be1-612e-4096-a5e1-43b2f719406d]") {
24+
REQUIRE("fourteen" == say::in_english(14));
1725
}
1826

19-
TEST_CASE("fourteen")
20-
{
21-
REQUIRE("fourteen" == say::in_english(14ULL));
27+
TEST_CASE("twenty", "[f541dd8e-f070-4329-92b4-b7ce2fcf06b4]") {
28+
REQUIRE("twenty" == say::in_english(20));
2229
}
2330

24-
TEST_CASE("twenty")
25-
{
26-
REQUIRE("twenty" == say::in_english(20ULL));
31+
TEST_CASE("twenty-two", "[d78601eb-4a84-4bfa-bf0e-665aeb8abe94]") {
32+
REQUIRE("twenty-two" == say::in_english(22));
2733
}
2834

29-
TEST_CASE("twenty_two")
30-
{
31-
REQUIRE("twenty-two" == say::in_english(22ULL));
35+
TEST_CASE("thirty", "[f010d4ca-12c9-44e9-803a-27789841adb1]") {
36+
REQUIRE("thirty" == say::in_english(30));
3237
}
3338

34-
TEST_CASE("sixty_nine")
35-
{
36-
REQUIRE("sixty-nine" == say::in_english(69ULL));
39+
TEST_CASE("ninety-nine", "[738ce12d-ee5c-4dfb-ad26-534753a98327]") {
40+
REQUIRE("ninety-nine" == say::in_english(99));
3741
}
3842

39-
TEST_CASE("one_hundred")
40-
{
41-
REQUIRE("one hundred" == say::in_english(100ULL));
43+
TEST_CASE("one hundred", "[e417d452-129e-4056-bd5b-6eb1df334dce]") {
44+
REQUIRE("one hundred" == say::in_english(100));
4245
}
4346

44-
TEST_CASE("one_hundred_twenty_three")
45-
{
46-
REQUIRE("one hundred twenty-three" == say::in_english(123ULL));
47+
TEST_CASE("one hundred twenty-three",
48+
"[d6924f30-80ba-4597-acf6-ea3f16269da8]") {
49+
REQUIRE("one hundred twenty-three" == say::in_english(123));
4750
}
4851

49-
TEST_CASE("one_thousand")
50-
{
51-
REQUIRE("one thousand" == say::in_english(1000ULL));
52+
TEST_CASE("two hundred", "[2f061132-54bc-4fd4-b5df-0a3b778959b9]") {
53+
REQUIRE("two hundred" == say::in_english(200));
5254
}
5355

54-
TEST_CASE("one_thousand_two_hundred_thirty_four")
55-
{
56-
REQUIRE("one thousand two hundred thirty-four" == say::in_english(1234ULL));
56+
TEST_CASE("nine hundred ninety-nine",
57+
"[feed6627-5387-4d38-9692-87c0dbc55c33]") {
58+
REQUIRE("nine hundred ninety-nine" == say::in_english(999));
5759
}
5860

59-
TEST_CASE("one_million")
60-
{
61-
REQUIRE("one million" == say::in_english(1000ULL*1000ULL));
61+
TEST_CASE("one thousand", "[3d83da89-a372-46d3-b10d-de0c792432b3]") {
62+
REQUIRE("one thousand" == say::in_english(1000));
6263
}
6364

64-
TEST_CASE("one_million_two")
65-
{
66-
REQUIRE("one million two" == say::in_english(1000ULL*1000ULL + 2ULL));
65+
TEST_CASE("one thousand two hundred thirty-four",
66+
"[865af898-1d5b-495f-8ff0-2f06d3c73709]") {
67+
REQUIRE("one thousand two hundred thirty-four" == say::in_english(1234));
6768
}
6869

69-
TEST_CASE("one_million_two_thousand_three_hundred_forty_five")
70-
{
71-
REQUIRE("one million two thousand three hundred forty-five" == say::in_english(1002345ULL));
70+
TEST_CASE("one million", "[b6a3f442-266e-47a3-835d-7f8a35f6cf7f]") {
71+
REQUIRE("one million" == say::in_english(1000000));
7272
}
7373

74-
TEST_CASE("one_billion")
75-
{
76-
REQUIRE("one billion" == say::in_english(1000ULL*1000ULL*1000ULL));
74+
TEST_CASE("one million two thousand three hundred forty-five",
75+
"[2cea9303-e77e-4212-b8ff-c39f1978fc70]") {
76+
REQUIRE("one million two thousand three hundred forty-five" ==
77+
say::in_english(1002345));
7778
}
7879

79-
TEST_CASE("a_really_big_number")
80-
{
80+
TEST_CASE("one billion", "[3e240eeb-f564-4b80-9421-db123f66a38f]") {
81+
REQUIRE("one billion" == say::in_english(1000000000));
82+
}
83+
84+
TEST_CASE("a big number", "[9a43fed1-c875-4710-8286-5065d73b8a9e]") {
8185
REQUIRE(
8286
"nine hundred eighty-seven billion six hundred fifty-four million "
8387
"three hundred twenty-one thousand one hundred twenty-three" ==
84-
say::in_english(987654321123ULL));
88+
say::in_english(987654321123));
8589
}
8690

87-
TEST_CASE("raises_an_error_below_zero")
88-
{
91+
TEST_CASE("numbers below zero are out of range",
92+
"[49a6a17b-084e-423e-994d-a87c0ecc05ef]") {
8993
REQUIRE_THROWS_AS(say::in_english(-1), std::domain_error);
9094
}
9195

92-
TEST_CASE("raises_an_error_for_one_trillion")
93-
{
94-
REQUIRE_THROWS_AS(say::in_english(1000ULL * 1000ULL * 1000ULL * 1000ULL),
95-
std::domain_error);
96+
TEST_CASE("numbers above 999,999,999,999 are out of range",
97+
"[4d6492eb-5853-4d16-9d34-b0f61b261fd9]") {
98+
REQUIRE_THROWS_AS(say::in_english(1000000000000), std::domain_error);
9699
}
100+
97101
#endif

0 commit comments

Comments
 (0)