]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
Add conversion to c-style strings to let Google Test build.
authorShane Kerr <shane@isc.org>
Mon, 12 Sep 2011 12:19:17 +0000 (14:19 +0200)
committerShane Kerr <shane@isc.org>
Mon, 12 Sep 2011 12:19:17 +0000 (14:19 +0200)
src/lib/asiolink/io_address.h
src/lib/asiolink/tests/io_address_unittest.cc

index 1b488fa9c89d138f0eb4446ef38c8ad939273039..1a42da710fa725ad2024001909b0cb635344d087 100644 (file)
@@ -74,6 +74,11 @@ 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
index 18b181e8b6efa4c91d012a4bc55a52116f185dba..b2a0dccb4e703cac90cb427cc34c48ccc07a911e 100644 (file)
 #include <asiolink/io_error.h>
 #include <asiolink/io_address.h>
 
+#include <cstring>
+
 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());