From 1598b2f1c04863022fdf24da2b474086def3235f Mon Sep 17 00:00:00 2001 From: Elahi Concha Date: Sun, 22 Sep 2024 19:49:17 +0200 Subject: [PATCH 1/3] tests: update say exercise --- exercises/practice/say/.meta/tests.toml | 25 +++++- exercises/practice/say/say_test.cpp | 105 +++++++++++------------- 2 files changed, 72 insertions(+), 58 deletions(-) diff --git a/exercises/practice/say/.meta/tests.toml b/exercises/practice/say/.meta/tests.toml index df50fd17..a5532e9e 100644 --- a/exercises/practice/say/.meta/tests.toml +++ b/exercises/practice/say/.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. [5d22a120-ba0c-428c-bd25-8682235d83e8] description = "zero" @@ -17,12 +24,24 @@ description = "twenty" [d78601eb-4a84-4bfa-bf0e-665aeb8abe94] description = "twenty-two" +[f010d4ca-12c9-44e9-803a-27789841adb1] +description = "thirty" + +[738ce12d-ee5c-4dfb-ad26-534753a98327] +description = "ninety-nine" + [e417d452-129e-4056-bd5b-6eb1df334dce] description = "one hundred" [d6924f30-80ba-4597-acf6-ea3f16269da8] description = "one hundred twenty-three" +[2f061132-54bc-4fd4-b5df-0a3b778959b9] +description = "two hundred" + +[feed6627-5387-4d38-9692-87c0dbc55c33] +description = "nine hundred ninety-nine" + [3d83da89-a372-46d3-b10d-de0c792432b3] description = "one thousand" diff --git a/exercises/practice/say/say_test.cpp b/exercises/practice/say/say_test.cpp index e4005d03..70aa421c 100644 --- a/exercises/practice/say/say_test.cpp +++ b/exercises/practice/say/say_test.cpp @@ -5,93 +5,88 @@ #include "test/catch.hpp" #endif -TEST_CASE("zero") -{ - REQUIRE("zero" == say::in_english(0ULL)); + +/* +An 'error' object is used as expected value to indicate that the +input value is out of the range described in the exercise. +*/ + +TEST_CASE("zero", "[5d22a120-ba0c-428c-bd25-8682235d83e8]") { + REQUIRE("zero" == say::say(0)); } #if defined(EXERCISM_RUN_ALL_TESTS) -TEST_CASE("one") -{ - REQUIRE("one" == say::in_english(1ULL)); + +TEST_CASE("one", "[9b5eed77-dbf6-439d-b920-3f7eb58928f6]") { + REQUIRE("one" == say::say(1)); +} + +TEST_CASE("fourteen", "[7c499be1-612e-4096-a5e1-43b2f719406d]") { + REQUIRE("fourteen" == say::say(14)); +} + +TEST_CASE("twenty", "[f541dd8e-f070-4329-92b4-b7ce2fcf06b4]") { + REQUIRE("twenty" == say::say(20)); } -TEST_CASE("fourteen") -{ - REQUIRE("fourteen" == say::in_english(14ULL)); +TEST_CASE("twenty-two", "[d78601eb-4a84-4bfa-bf0e-665aeb8abe94]") { + REQUIRE("twenty-two" == say::say(22)); } -TEST_CASE("twenty") -{ - REQUIRE("twenty" == say::in_english(20ULL)); +TEST_CASE("thirty", "[f010d4ca-12c9-44e9-803a-27789841adb1]") { + REQUIRE("thirty" == say::say(30)); } -TEST_CASE("twenty_two") -{ - REQUIRE("twenty-two" == say::in_english(22ULL)); +TEST_CASE("ninety-nine", "[738ce12d-ee5c-4dfb-ad26-534753a98327]") { + REQUIRE("ninety-nine" == say::say(99)); } -TEST_CASE("sixty_nine") -{ - REQUIRE("sixty-nine" == say::in_english(69ULL)); +TEST_CASE("one hundred", "[e417d452-129e-4056-bd5b-6eb1df334dce]") { + REQUIRE("one hundred" == say::say(100)); } -TEST_CASE("one_hundred") -{ - REQUIRE("one hundred" == say::in_english(100ULL)); +TEST_CASE("one hundred twenty-three", "[d6924f30-80ba-4597-acf6-ea3f16269da8]") { + REQUIRE("one hundred twenty-three" == say::say(123)); } -TEST_CASE("one_hundred_twenty_three") -{ - REQUIRE("one hundred twenty-three" == say::in_english(123ULL)); +TEST_CASE("two hundred", "[2f061132-54bc-4fd4-b5df-0a3b778959b9]") { + REQUIRE("two hundred" == say::say(200)); } -TEST_CASE("one_thousand") -{ - REQUIRE("one thousand" == say::in_english(1000ULL)); +TEST_CASE("nine hundred ninety-nine", "[feed6627-5387-4d38-9692-87c0dbc55c33]") { + REQUIRE("nine hundred ninety-nine" == say::say(999)); } -TEST_CASE("one_thousand_two_hundred_thirty_four") -{ - REQUIRE("one thousand two hundred thirty-four" == say::in_english(1234ULL)); +TEST_CASE("one thousand", "[3d83da89-a372-46d3-b10d-de0c792432b3]") { + REQUIRE("one thousand" == say::say(1000)); } -TEST_CASE("one_million") -{ - REQUIRE("one million" == say::in_english(1000ULL*1000ULL)); +TEST_CASE("one thousand two hundred thirty-four", "[865af898-1d5b-495f-8ff0-2f06d3c73709]") { + REQUIRE("one thousand two hundred thirty-four" == say::say(1234)); } -TEST_CASE("one_million_two") -{ - REQUIRE("one million two" == say::in_english(1000ULL*1000ULL + 2ULL)); +TEST_CASE("one million", "[b6a3f442-266e-47a3-835d-7f8a35f6cf7f]") { + REQUIRE("one million" == say::say(1000000)); } -TEST_CASE("one_million_two_thousand_three_hundred_forty_five") -{ - REQUIRE("one million two thousand three hundred forty-five" == say::in_english(1002345ULL)); +TEST_CASE("one million two thousand three hundred forty-five", "[2cea9303-e77e-4212-b8ff-c39f1978fc70]") { + REQUIRE("one million two thousand three hundred forty-five" == say::say(1002345)); } -TEST_CASE("one_billion") -{ - REQUIRE("one billion" == say::in_english(1000ULL*1000ULL*1000ULL)); +TEST_CASE("one billion", "[3e240eeb-f564-4b80-9421-db123f66a38f]") { + REQUIRE("one billion" == say::say(1000000000)); } -TEST_CASE("a_really_big_number") -{ - REQUIRE( - "nine hundred eighty-seven billion six hundred fifty-four million " - "three hundred twenty-one thousand one hundred twenty-three" == - say::in_english(987654321123ULL)); +TEST_CASE("a big number", "[9a43fed1-c875-4710-8286-5065d73b8a9e]") { + REQUIRE("nine hundred eighty-seven billion six hundred fifty-four million three hundred twenty-one thousand one hundred twenty-three" == say::say(987654321123)); } -TEST_CASE("raises_an_error_below_zero") -{ - REQUIRE_THROWS_AS(say::in_english(-1), std::domain_error); +TEST_CASE("numbers below zero are out of range", "[49a6a17b-084e-423e-994d-a87c0ecc05ef]") { + REQUIRE("{'error': 'input out of range'}" == say::say(-1)); } -TEST_CASE("raises_an_error_for_one_trillion") -{ - REQUIRE_THROWS_AS(say::in_english(1000ULL * 1000ULL * 1000ULL * 1000ULL), - std::domain_error); +TEST_CASE("numbers above 999,999,999,999 are out of range", "[4d6492eb-5853-4d16-9d34-b0f61b261fd9]") { + REQUIRE("{'error': 'input out of range'}" == say::say(1000000000000)); } + #endif From 55b757731dac4d3accc50709f815dd782790e972 Mon Sep 17 00:00:00 2001 From: Elahi Concha Date: Mon, 23 Sep 2024 13:31:50 +0200 Subject: [PATCH 2/3] Call in_english instead of say, fix clang formatting --- exercises/practice/say/say_test.cpp | 62 +++++++++++++++++------------ 1 file changed, 36 insertions(+), 26 deletions(-) diff --git a/exercises/practice/say/say_test.cpp b/exercises/practice/say/say_test.cpp index 70aa421c..37e4faf9 100644 --- a/exercises/practice/say/say_test.cpp +++ b/exercises/practice/say/say_test.cpp @@ -5,88 +5,98 @@ #include "test/catch.hpp" #endif - /* An 'error' object is used as expected value to indicate that the input value is out of the range described in the exercise. */ TEST_CASE("zero", "[5d22a120-ba0c-428c-bd25-8682235d83e8]") { - REQUIRE("zero" == say::say(0)); + REQUIRE("zero" == say::in_english(0)); } #if defined(EXERCISM_RUN_ALL_TESTS) TEST_CASE("one", "[9b5eed77-dbf6-439d-b920-3f7eb58928f6]") { - REQUIRE("one" == say::say(1)); + REQUIRE("one" == say::in_english(1)); } TEST_CASE("fourteen", "[7c499be1-612e-4096-a5e1-43b2f719406d]") { - REQUIRE("fourteen" == say::say(14)); + REQUIRE("fourteen" == say::in_english(14)); } TEST_CASE("twenty", "[f541dd8e-f070-4329-92b4-b7ce2fcf06b4]") { - REQUIRE("twenty" == say::say(20)); + REQUIRE("twenty" == say::in_english(20)); } TEST_CASE("twenty-two", "[d78601eb-4a84-4bfa-bf0e-665aeb8abe94]") { - REQUIRE("twenty-two" == say::say(22)); + REQUIRE("twenty-two" == say::in_english(22)); } TEST_CASE("thirty", "[f010d4ca-12c9-44e9-803a-27789841adb1]") { - REQUIRE("thirty" == say::say(30)); + REQUIRE("thirty" == say::in_english(30)); } TEST_CASE("ninety-nine", "[738ce12d-ee5c-4dfb-ad26-534753a98327]") { - REQUIRE("ninety-nine" == say::say(99)); + REQUIRE("ninety-nine" == say::in_english(99)); } TEST_CASE("one hundred", "[e417d452-129e-4056-bd5b-6eb1df334dce]") { - REQUIRE("one hundred" == say::say(100)); + REQUIRE("one hundred" == say::in_english(100)); } -TEST_CASE("one hundred twenty-three", "[d6924f30-80ba-4597-acf6-ea3f16269da8]") { - REQUIRE("one hundred twenty-three" == say::say(123)); +TEST_CASE("one hundred twenty-three", + "[d6924f30-80ba-4597-acf6-ea3f16269da8]") { + REQUIRE("one hundred twenty-three" == say::in_english(123)); } TEST_CASE("two hundred", "[2f061132-54bc-4fd4-b5df-0a3b778959b9]") { - REQUIRE("two hundred" == say::say(200)); + REQUIRE("two hundred" == say::in_english(200)); } -TEST_CASE("nine hundred ninety-nine", "[feed6627-5387-4d38-9692-87c0dbc55c33]") { - REQUIRE("nine hundred ninety-nine" == say::say(999)); +TEST_CASE("nine hundred ninety-nine", + "[feed6627-5387-4d38-9692-87c0dbc55c33]") { + REQUIRE("nine hundred ninety-nine" == say::in_english(999)); } TEST_CASE("one thousand", "[3d83da89-a372-46d3-b10d-de0c792432b3]") { - REQUIRE("one thousand" == say::say(1000)); + REQUIRE("one thousand" == say::in_english(1000)); } -TEST_CASE("one thousand two hundred thirty-four", "[865af898-1d5b-495f-8ff0-2f06d3c73709]") { - REQUIRE("one thousand two hundred thirty-four" == say::say(1234)); +TEST_CASE("one thousand two hundred thirty-four", + "[865af898-1d5b-495f-8ff0-2f06d3c73709]") { + REQUIRE("one thousand two hundred thirty-four" == say::in_english(1234)); } TEST_CASE("one million", "[b6a3f442-266e-47a3-835d-7f8a35f6cf7f]") { - REQUIRE("one million" == say::say(1000000)); + REQUIRE("one million" == say::in_english(1000000)); } -TEST_CASE("one million two thousand three hundred forty-five", "[2cea9303-e77e-4212-b8ff-c39f1978fc70]") { - REQUIRE("one million two thousand three hundred forty-five" == say::say(1002345)); +TEST_CASE("one million two thousand three hundred forty-five", + "[2cea9303-e77e-4212-b8ff-c39f1978fc70]") { + REQUIRE("one million two thousand three hundred forty-five" == + say::in_english(1002345)); } TEST_CASE("one billion", "[3e240eeb-f564-4b80-9421-db123f66a38f]") { - REQUIRE("one billion" == say::say(1000000000)); + REQUIRE("one billion" == say::in_english(1000000000)); } TEST_CASE("a big number", "[9a43fed1-c875-4710-8286-5065d73b8a9e]") { - REQUIRE("nine hundred eighty-seven billion six hundred fifty-four million three hundred twenty-one thousand one hundred twenty-three" == say::say(987654321123)); + REQUIRE( + "nine hundred eighty-seven billion six hundred fifty-four million " + "three hundred twenty-one thousand one hundred twenty-three" == + say::in_english(987654321123)); } -TEST_CASE("numbers below zero are out of range", "[49a6a17b-084e-423e-994d-a87c0ecc05ef]") { - REQUIRE("{'error': 'input out of range'}" == say::say(-1)); +TEST_CASE("numbers below zero are out of range", + "[49a6a17b-084e-423e-994d-a87c0ecc05ef]") { + REQUIRE("{'error': 'input out of range'}" == say::in_english(-1)); } -TEST_CASE("numbers above 999,999,999,999 are out of range", "[4d6492eb-5853-4d16-9d34-b0f61b261fd9]") { - REQUIRE("{'error': 'input out of range'}" == say::say(1000000000000)); +TEST_CASE("numbers above 999,999,999,999 are out of range", + "[4d6492eb-5853-4d16-9d34-b0f61b261fd9]") { + REQUIRE("{'error': 'input out of range'}" == + say::in_english(1000000000000)); } #endif From 46326f4c4bef35252e3378ce508b9318e942bde7 Mon Sep 17 00:00:00 2001 From: Elahi Concha Date: Tue, 8 Oct 2024 12:13:41 +0200 Subject: [PATCH 3/3] Reformat error test cases --- exercises/practice/say/say_test.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/exercises/practice/say/say_test.cpp b/exercises/practice/say/say_test.cpp index 37e4faf9..3148b934 100644 --- a/exercises/practice/say/say_test.cpp +++ b/exercises/practice/say/say_test.cpp @@ -90,13 +90,12 @@ TEST_CASE("a big number", "[9a43fed1-c875-4710-8286-5065d73b8a9e]") { TEST_CASE("numbers below zero are out of range", "[49a6a17b-084e-423e-994d-a87c0ecc05ef]") { - REQUIRE("{'error': 'input out of range'}" == say::in_english(-1)); + REQUIRE_THROWS_AS(say::in_english(-1), std::domain_error); } TEST_CASE("numbers above 999,999,999,999 are out of range", "[4d6492eb-5853-4d16-9d34-b0f61b261fd9]") { - REQUIRE("{'error': 'input out of range'}" == - say::in_english(1000000000000)); + REQUIRE_THROWS_AS(say::in_english(1000000000000), std::domain_error); } #endif