Browse Source

[master] removed the typeo conversion operator from IOAddress to char*.
its counter intuitive behavior and surprising results rarely justify
the introduction, and, in fact, it caused a regression:
http://git.bind10.isc.org/~tester/builder/BIND10/20111007175000-Solaris10-sparc-Sunstudio/logs/unittests.out
Apparently the reason why this was introduced is to assist the comparison
tests used in a dhcp6 test. To work this around I replaced the test code
using toText(). The right solution is to introduce operator<< for IOAddress,
which will satisfy gtest (we already have operator== so EXPECT_EQ should
work otherwise).

JINMEI Tatuya 13 years ago
parent
commit
56bd0746ae

+ 1 - 1
src/bin/dhcp6/tests/iface_mgr_unittest.cc

@@ -250,7 +250,7 @@ TEST_F(IfaceMgrTest, DISABLED_sendReceive) {
     EXPECT_EQ(0, memcmp(&sendPkt.data_[0], &rcvPkt->data_[0],
                         rcvPkt->data_len_) );
 
-    EXPECT_EQ(sendPkt.remote_addr_, rcvPkt->remote_addr_);
+    EXPECT_EQ(sendPkt.remote_addr_.toText(), rcvPkt->remote_addr_.toText());
     EXPECT_EQ(rcvPkt->remote_port_, 10546);
 
     delete rcvPkt;

+ 0 - 5
src/lib/asiolink/io_address.h

@@ -74,11 +74,6 @@ public:
     /// \return A string representation of the address.
     std::string toText() const;
 
-    /// \brief Convert the address to a C-style null-terminated string.
-    ///
-    /// \return A string representation of the address.
-    operator const char*() const { return toText().c_str(); }
-
     /// \brief Returns const reference to the underlying address object.
     ///
     /// This is useful, when access to interface offerted by

+ 0 - 1
src/lib/asiolink/tests/io_address_unittest.cc

@@ -25,7 +25,6 @@ using namespace isc::asiolink;
 TEST(IOAddressTest, fromText) {
     IOAddress io_address_v4("192.0.2.1");
     EXPECT_EQ("192.0.2.1", io_address_v4.toText());
-    EXPECT_EQ(0, strcmp("192.0.2.1", (const char *)io_address_v4));
 
     IOAddress io_address_v6("2001:db8::1234");
     EXPECT_EQ("2001:db8::1234", io_address_v6.toText());