aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests/catchy
diff options
context:
space:
mode:
authorSimon Warta <[email protected]>2015-07-20 21:26:00 +0200
committerSimon Warta <[email protected]>2015-07-27 13:04:40 +0200
commit1f3ef881b103c4b8734691051f5de38f99c912af (patch)
tree1675410cd6276a60a398c690477bbb1089a75f31 /src/tests/catchy
parentbff6f93b9043926897001ffcf67030b0e6a0a254 (diff)
Improve calendar_point unit tests
Diffstat (limited to 'src/tests/catchy')
-rw-r--r--src/tests/catchy/test_utils.cpp41
1 files changed, 36 insertions, 5 deletions
diff --git a/src/tests/catchy/test_utils.cpp b/src/tests/catchy/test_utils.cpp
index ad4191e3c..702d82f9c 100644
--- a/src/tests/catchy/test_utils.cpp
+++ b/src/tests/catchy/test_utils.cpp
@@ -100,6 +100,7 @@ TEST_CASE("calendar_point constructor works", "[utils]")
TEST_CASE("calendar_point to stl timepoint and back", "[utils]")
{
+ SECTION("default test")
{
auto in = calendar_point(1988, 04, 23, 14, 37, 28);
auto out = calendar_value(in.to_std_timepoint());
@@ -111,7 +112,20 @@ TEST_CASE("calendar_point to stl timepoint and back", "[utils]")
CHECK(( out.seconds == 28 ));
}
- SECTION("latest possible time point")
+ // _mkgmtime on Windows does not work for dates before 1970
+ SECTION("first possible time point")
+ {
+ auto in = calendar_point(1970, 01, 01, 00, 00, 00);
+ auto out = calendar_value(in.to_std_timepoint());
+ CHECK(( out.year == 1970 ));
+ CHECK(( out.month == 01 ));
+ CHECK(( out.day == 01 ));
+ CHECK(( out.hour == 00 ));
+ CHECK(( out.minutes == 00 ));
+ CHECK(( out.seconds == 00 ));
+ }
+
+ SECTION("latest possible time point")
{
auto in = calendar_point(2037, 12, 31, 23, 59, 59);
auto out = calendar_value(in.to_std_timepoint());
@@ -123,13 +137,30 @@ TEST_CASE("calendar_point to stl timepoint and back", "[utils]")
CHECK(( out.seconds == 59 ));
}
- SECTION("year too early")
+ SECTION("year too early")
{
- auto in = calendar_point(1800, 01, 01, 0, 0, 0);
- CHECK_THROWS( in.to_std_timepoint() );
+ {
+ auto in = calendar_point(1800, 01, 01, 0, 0, 0);
+ CHECK_THROWS( in.to_std_timepoint() );
+ }
+
+ {
+ auto in = calendar_point(1899, 12, 31, 23, 59, 59);
+ CHECK_THROWS( in.to_std_timepoint() );
+ }
+
+ {
+ auto in = calendar_point(1969, 12, 31, 23, 59, 58); // time_t = -2
+ CHECK_THROWS( in.to_std_timepoint() );
+ }
+
+ {
+ auto in = calendar_point(1969, 12, 31, 23, 59, 59); // time_t = -1
+ CHECK_THROWS( in.to_std_timepoint() );
+ }
}
- SECTION("year too late")
+ SECTION("year too late")
{
auto in = calendar_point(2038, 01, 01, 0, 0, 0);
CHECK_THROWS( in.to_std_timepoint() );