aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests
diff options
context:
space:
mode:
authorSimon Warta <[email protected]>2015-07-16 10:40:12 +0200
committerSimon Warta <[email protected]>2015-07-16 15:19:22 +0200
commite9ef1088bced02c0ed10a460dc0fbc296b999a07 (patch)
tree6edebd24be2a611fddd94a9391c21595af484791 /src/tests
parent9bca04a5999060f098221615ab4ce5f89ea67c8a (diff)
Fix time range issue for 32 bit platforms
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/catchy/test_utils.cpp69
-rw-r--r--src/tests/unit_x509.cpp4
2 files changed, 48 insertions, 25 deletions
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() );
+ }
}
diff --git a/src/tests/unit_x509.cpp b/src/tests/unit_x509.cpp
index 95890b9e9..677ccedd3 100644
--- a/src/tests/unit_x509.cpp
+++ b/src/tests/unit_x509.cpp
@@ -172,11 +172,11 @@ size_t test_x509()
/* Sign the requests to create the certs */
X509_Certificate user1_cert =
ca.sign_request(user1_req, rng,
- from_date(2008, 01, 01), from_date(2100, 01, 01));
+ from_date(2008, 01, 01), from_date(2033, 01, 01));
X509_Certificate user2_cert = ca.sign_request(user2_req, rng,
from_date(2008, 01, 01),
- from_date(2100, 01, 01));
+ from_date(2033, 01, 01));
X509_CRL crl1 = ca.new_crl(rng);
/* Verify the certs */