Skip to content

Commit

Permalink
Sync gigasecond test cases (#775) (#810)
Browse files Browse the repository at this point in the history
[no important files changed]
  • Loading branch information
ahans authored Feb 20, 2024
1 parent 83ad9b2 commit cdaf146
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 18 deletions.
17 changes: 14 additions & 3 deletions exercises/practice/gigasecond/.meta/tests.toml
Original file line number Diff line number Diff line change
@@ -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.

[92fbe71c-ea52-4fac-bd77-be38023cacf7]
description = "date only specification of time"
Expand All @@ -16,3 +23,7 @@ description = "full time specified"

[09d4e30e-728a-4b52-9005-be44a58d9eba]
description = "full time with day roll-over"

[fcec307c-7529-49ab-b0fe-20309197618a]
description = "does not mutate the input"
include = false
34 changes: 19 additions & 15 deletions exercises/practice/gigasecond/gigasecond_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,42 +14,46 @@

using namespace boost::posix_time;

TEST_CASE("test_1")
{
const ptime actual = gigasecond::advance(time_from_string("2011-04-25 00:00:00"));
TEST_CASE("date only specification of time",
"[92fbe71c-ea52-4fac-bd77-be38023cacf7]") {
const ptime actual =
gigasecond::advance(time_from_string("2011-04-25 00:00:00"));

const ptime expected(time_from_string("2043-01-01 01:46:40"));
REQUIRE(expected == actual);
}

#if defined(EXERCISM_RUN_ALL_TESTS)
TEST_CASE("test_2")
{
const auto actual = gigasecond::advance(time_from_string("1977-06-13 00:00:00"));
TEST_CASE("second test for date only specification of time",
"[6d86dd16-6f7a-47be-9e58-bb9fb2ae1433]") {
const auto actual =
gigasecond::advance(time_from_string("1977-06-13 00:00:00"));

const ptime expected(time_from_string("2009-02-19 01:46:40"));
REQUIRE(expected == actual);
}

TEST_CASE("test_3")
{
const auto actual = gigasecond::advance(time_from_string("1959-07-19 00:00:00"));
TEST_CASE("third test for date only specification of time",
"[77eb8502-2bca-4d92-89d9-7b39ace28dd5]") {
const auto actual =
gigasecond::advance(time_from_string("1959-07-19 00:00:00"));

const ptime expected(time_from_string("1991-03-27 01:46:40"));
REQUIRE(expected == actual);
}

TEST_CASE("test_4")
{
const auto actual = gigasecond::advance(time_from_string("2015-01-24 22:00:00"));
TEST_CASE("full time specified", "[c9d89a7d-06f8-4e28-a305-64f1b2abc693]") {
const auto actual =
gigasecond::advance(time_from_string("2015-01-24 22:00:00"));

const ptime expected(time_from_string("2046-10-02 23:46:40"));
REQUIRE(expected == actual);
}

TEST_CASE("test_5")
{
const auto actual = gigasecond::advance(time_from_string("2015-01-24 23:59:59"));
TEST_CASE("full time with day roll-over",
"[09d4e30e-728a-4b52-9005-be44a58d9eba]") {
const auto actual =
gigasecond::advance(time_from_string("2015-01-24 23:59:59"));

const ptime expected(time_from_string("2046-10-03 01:46:39"));
REQUIRE(expected == actual);
Expand Down

0 comments on commit cdaf146

Please sign in to comment.