From e9ef1088bced02c0ed10a460dc0fbc296b999a07 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Thu, 16 Jul 2015 10:40:12 +0200 Subject: Fix time range issue for 32 bit platforms --- src/tests/catchy/test_utils.cpp | 69 +++++++++++++++++++++++++++-------------- 1 file changed, 46 insertions(+), 23 deletions(-) (limited to 'src/tests/catchy') diff --git a/src/tests/catchy/test_utils.cpp b/src/tests/catchy/test_utils.cpp index 41eef3e45..ad4191e3c 100644 --- a/src/tests/catchy/test_utils.cpp +++ b/src/tests/catchy/test_utils.cpp @@ -57,29 +57,45 @@ TEST_CASE("round_up invalid input", "[utils]") TEST_CASE("calendar_point constructor works", "[utils]") { - auto point1 = calendar_point(1988, 04, 23, 14, 37, 28); - CHECK(( point1.year == 1988 )); - CHECK(( point1.month == 4 )); - CHECK(( point1.day == 23 )); - CHECK(( point1.hour == 14 )); - CHECK(( point1.minutes == 37 )); - CHECK(( point1.seconds == 28 )); - - auto point2 = calendar_point(1800, 01, 01, 0, 0, 0); - CHECK(( point2.year == 1800 )); - CHECK(( point2.month == 1 )); - CHECK(( point2.day == 1 )); - CHECK(( point2.hour == 0 )); - CHECK(( point2.minutes == 0 )); - CHECK(( point2.seconds == 0 )); - - auto point3 = calendar_point(2037, 12, 31, 24, 59, 59); - CHECK(( point3.year == 2037 )); - CHECK(( point3.month == 12 )); - CHECK(( point3.day == 31 )); - CHECK(( point3.hour == 24 )); - CHECK(( point3.minutes == 59 )); - CHECK(( point3.seconds == 59 )); + { + auto point1 = calendar_point(1988, 04, 23, 14, 37, 28); + CHECK(( point1.year == 1988 )); + CHECK(( point1.month == 4 )); + CHECK(( point1.day == 23 )); + CHECK(( point1.hour == 14 )); + CHECK(( point1.minutes == 37 )); + CHECK(( point1.seconds == 28 )); + } + + { + auto point2 = calendar_point(1800, 01, 01, 0, 0, 0); + CHECK(( point2.year == 1800 )); + CHECK(( point2.month == 1 )); + CHECK(( point2.day == 1 )); + CHECK(( point2.hour == 0 )); + CHECK(( point2.minutes == 0 )); + CHECK(( point2.seconds == 0 )); + } + + { + auto point = calendar_point(2037, 12, 31, 24, 59, 59); + CHECK(( point.year == 2037 )); + CHECK(( point.month == 12 )); + CHECK(( point.day == 31 )); + CHECK(( point.hour == 24 )); + CHECK(( point.minutes == 59 )); + CHECK(( point.seconds == 59 )); + } + + { + auto point = calendar_point(2100, 5, 1, 0, 0, 0); + CHECK(( point.year == 2100 )); + CHECK(( point.month == 5 )); + CHECK(( point.day == 1 )); + CHECK(( point.hour == 0 )); + CHECK(( point.minutes == 0 )); + CHECK(( point.seconds == 0 )); + } } TEST_CASE("calendar_point to stl timepoint and back", "[utils]") @@ -95,6 +111,7 @@ TEST_CASE("calendar_point to stl timepoint and back", "[utils]") CHECK(( out.seconds == 28 )); } + SECTION("latest possible time point") { auto in = calendar_point(2037, 12, 31, 23, 59, 59); auto out = calendar_value(in.to_std_timepoint()); @@ -111,4 +128,10 @@ TEST_CASE("calendar_point to stl timepoint and back", "[utils]") auto in = calendar_point(1800, 01, 01, 0, 0, 0); CHECK_THROWS( in.to_std_timepoint() ); } + + SECTION("year too late") + { + auto in = calendar_point(2038, 01, 01, 0, 0, 0); + CHECK_THROWS( in.to_std_timepoint() ); + } } -- cgit v1.2.3