Browse Source

[1955] Corrections to timestamp unit tests in dhcp::PktN.

Marcin Siodelski 13 years ago
parent
commit
0235da8162
2 changed files with 9 additions and 6 deletions
  1. 4 3
      src/lib/dhcp/tests/pkt4_unittest.cc
  2. 5 3
      src/lib/dhcp/tests/pkt6_unittest.cc

+ 4 - 3
src/lib/dhcp/tests/pkt4_unittest.cc

@@ -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;
 }
 
 

+ 5 - 3
src/lib/dhcp/tests/pkt6_unittest.cc

@@ -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;
 }
 
 }