Browse Source

[trac61] a bit more cleanup for tests. made it more robust for y2038 prob.

JINMEI Tatuya 14 years ago
parent
commit
bd8392ffd8
1 changed files with 6 additions and 4 deletions
  1. 6 4
      src/lib/dns/tests/dnssectime_unittest.cc

+ 6 - 4
src/lib/dns/tests/dnssectime_unittest.cc

@@ -107,14 +107,16 @@ testGetTime() {
 const uint64_t YEAR10K_EVE = 253402300799LL;
 const uint64_t YEAR10K_EVE = 253402300799LL;
 
 
 TEST_F(DNSSECTimeTest, toText) {
 TEST_F(DNSSECTimeTest, toText) {
+    // Check a basic case with the default (normal) gettimeFunction
+    // based on the "real current time".
+    // Note: this will fail after year 2078, but at that point we won't use
+    // this program anyway:-)
+    EXPECT_EQ("20100311233000", timeToText32(1268350200));
+
     // Set the current time to: Feb 18 09:04:14 UTC 2012 (an arbitrary choice
     // Set the current time to: Feb 18 09:04:14 UTC 2012 (an arbitrary choice
     // in the range of the first half of uint32 since epoch).
     // in the range of the first half of uint32 since epoch).
     dnssectime::detail::gettimeFunction = testGetTime<1329555854LL>;
     dnssectime::detail::gettimeFunction = testGetTime<1329555854LL>;
 
 
-    // Check some basic cases
-    EXPECT_EQ("19700101000000", timeToText32(0));
-    EXPECT_EQ("20100311233000", timeToText32(1268350200));
-
     // Test the "year 2038" problem.
     // Test the "year 2038" problem.
     // Check the result of toText() for "INT_MIN" in int32_t.  It's in the
     // Check the result of toText() for "INT_MIN" in int32_t.  It's in the
     // 68-year range from the faked current time, so the result should be
     // 68-year range from the faked current time, so the result should be