Browse Source

[master] Corrected nc_trans_unittest.cc build failure

Using EXPECT_EQ on class D2Dhcid failed under gtest 1.5
due to lack of "<<" operator.  Adding it solves this problem.
Thomas Markwalder 11 years ago
parent
commit
9273dca334

+ 5 - 0
src/lib/dhcp_ddns/ncr_msg.cc

@@ -111,6 +111,11 @@ D2Dhcid::fromDUID(const isc::dhcp::DUID& duid,
     bytes_.insert(bytes_.end(), secure.begin(), secure.end());
 }
 
+std::ostream&
+operator<<(std::ostream& os, const D2Dhcid& dhcid) {
+    os << dhcid.toStr();
+    return (os);
+}
 
 /**************************** NameChangeRequest ******************************/
 

+ 3 - 0
src/lib/dhcp_ddns/ncr_msg.h

@@ -139,6 +139,9 @@ private:
     std::vector<uint8_t> bytes_;
 };
 
+std::ostream&
+operator<<(std::ostream& os, const D2Dhcid& dhcid);
+
 class NameChangeRequest;
 /// @brief Defines a pointer to a NameChangeRequest.
 typedef boost::shared_ptr<NameChangeRequest> NameChangeRequestPtr;

+ 8 - 0
src/lib/dhcp_ddns/tests/ncr_unittests.cc

@@ -387,6 +387,14 @@ TEST(NameChangeRequestTest, dhcidFromMaxDUID) {
     EXPECT_EQ(dhcid_ref, dhcid.toStr());
 }
 
+// test operator<< on D2Dhcid
+TEST(NameChangeRequestTest, leftShiftOperation) {
+    const D2Dhcid dhcid("010203040A7F8E3D");
+
+    ostringstream oss;
+    oss << dhcid;
+    EXPECT_EQ(dhcid.toStr(), oss.str());
+}
 
 /// @brief Verifies the fundamentals of converting from and to JSON.
 /// It verifies that: