]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[1955] Corrections to timestamp unit tests in dhcp::PktN.
authorMarcin Siodelski <marcin@isc.org>
Mon, 11 Jun 2012 11:30:36 +0000 (13:30 +0200)
committerMarcin Siodelski <marcin@isc.org>
Mon, 11 Jun 2012 11:30:36 +0000 (13:30 +0200)
src/lib/dhcp/tests/pkt4_unittest.cc
src/lib/dhcp/tests/pkt6_unittest.cc

index 1ac8477337ebe77d9ff33d90fc3040fc5b4547f2..e443b658153f19e20fa471239bb4a578cebd4ced 100644 (file)
@@ -599,7 +599,10 @@ TEST(Pkt4Test, metaFields) {
 }
 
 TEST(Pkt4Test, Timestamp) {
-    Pkt4* pkt = new Pkt4(DHCPOFFER, 1234);
+    scoped_ptr<Pkt4> pkt(new Pkt4(DHCPOFFER, 1234));
+
+    // Just after construction timestamp is invalid
+    ASSERT_TRUE(pkt->getTimestamp().is_not_a_date_time());
 
     // Update packet time.
     pkt->updateTimestamp();
@@ -619,8 +622,6 @@ TEST(Pkt4Test, Timestamp) {
 
     // Duration should be positive or zero.
     EXPECT_TRUE(ts_period.length().total_microseconds() >= 0);
-
-    delete pkt;
 }
 
 
index fdc9733bb2bc0aeb2348084bfadbfc25b070d9e7..d6ca9b106f294ca00a4397bd6208f24f25664cda 100644 (file)
@@ -206,7 +206,11 @@ TEST_F(Pkt6Test, addGetDelOptions) {
 }
 
 TEST_F(Pkt6Test, Timestamp) {
-    Pkt6* pkt = new Pkt6(DHCPV6_SOLICIT, 0x020304);
+    boost::scoped_ptr<Pkt6> pkt(new Pkt6(DHCPV6_SOLICIT, 0x020304));
+
+    // Just after construction timestamp is invalid
+    ASSERT_TRUE(pkt->getTimestamp().is_not_a_date_time());
+
     // Update packet time.
     pkt->updateTimestamp();
 
@@ -225,8 +229,6 @@ TEST_F(Pkt6Test, Timestamp) {
 
     // Duration should be positive or zero.
     EXPECT_TRUE(ts_period.length().total_microseconds() >= 0);
-
-    delete pkt;
 }
 
 }