|
5 | 5 | #include "test/catch.hpp"
|
6 | 6 | #endif
|
7 | 7 |
|
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)); |
11 | 15 | }
|
12 | 16 |
|
13 | 17 | #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)); |
17 | 25 | }
|
18 | 26 |
|
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)); |
22 | 29 | }
|
23 | 30 |
|
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)); |
27 | 33 | }
|
28 | 34 |
|
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)); |
32 | 37 | }
|
33 | 38 |
|
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)); |
37 | 41 | }
|
38 | 42 |
|
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)); |
42 | 45 | }
|
43 | 46 |
|
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)); |
47 | 50 | }
|
48 | 51 |
|
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)); |
52 | 54 | }
|
53 | 55 |
|
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)); |
57 | 59 | }
|
58 | 60 |
|
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)); |
62 | 63 | }
|
63 | 64 |
|
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)); |
67 | 68 | }
|
68 | 69 |
|
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)); |
72 | 72 | }
|
73 | 73 |
|
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)); |
77 | 78 | }
|
78 | 79 |
|
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]") { |
81 | 85 | REQUIRE(
|
82 | 86 | "nine hundred eighty-seven billion six hundred fifty-four million "
|
83 | 87 | "three hundred twenty-one thousand one hundred twenty-three" ==
|
84 |
| - say::in_english(987654321123ULL)); |
| 88 | + say::in_english(987654321123)); |
85 | 89 | }
|
86 | 90 |
|
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]") { |
89 | 93 | REQUIRE_THROWS_AS(say::in_english(-1), std::domain_error);
|
90 | 94 | }
|
91 | 95 |
|
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); |
96 | 99 | }
|
| 100 | + |
97 | 101 | #endif
|
0 commit comments