net/addr/ip: Add basic IP comparison and hash ops
Change-Id: I79ab9c225ff031da7df0c788078f2a8e5c486990
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/test/meson.build b/test/meson.build
index c4e8a4d..e55b18c 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -6,6 +6,7 @@
'hash': [stdplus_dep, gtest_main_dep],
'hash/array': [stdplus_dep, gtest_main_dep],
'hash/tuple': [stdplus_dep, gtest_main_dep],
+ 'net/addr/ip': [stdplus_dep, gtest_main_dep],
'numeric/endian': [stdplus_dep, gtest_main_dep],
'pinned': [stdplus_dep, gtest_main_dep],
'raw': [stdplus_dep, gmock_dep, gtest_main_dep],
diff --git a/test/net/addr/ip.cpp b/test/net/addr/ip.cpp
new file mode 100644
index 0000000..2745626
--- /dev/null
+++ b/test/net/addr/ip.cpp
@@ -0,0 +1,26 @@
+#include <stdplus/net/addr/ip.hpp>
+#include <stdplus/numeric/endian.hpp>
+
+#include <gtest/gtest.h>
+
+namespace stdplus
+{
+
+TEST(EqualOperator, In4Addr)
+{
+ EXPECT_EQ((In4Addr{255, 0, 255, 0}), (in_addr{hton(0xff00ff00)}));
+ EXPECT_EQ((in_addr{}), (In4Addr{}));
+ EXPECT_NE((In4Addr{1}), (In4Addr{in_addr{}}));
+ std::hash<In4Addr>{}(In4Addr{});
+}
+
+TEST(EqualOperator, In6Addr)
+{
+ EXPECT_EQ((In6Addr{0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff}),
+ (in6_addr{0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff}));
+ EXPECT_EQ((in6_addr{}), (In6Addr{}));
+ EXPECT_NE((In6Addr{1}), (In6Addr{in6_addr{}}));
+ std::hash<In6Addr>{}(In6Addr{});
+}
+
+} // namespace stdplus