Access the individual words of an IPv6 address correctly in IPAddressTest on Windows
[folly.git] / folly / test / IPAddressTest.cpp
index 9fc746d7aedffe63f90b3dba9b1d7627935c45a5..93f2aa1c3964ba2ff0ec3cdad94c4204f6032982 100644 (file)
@@ -891,7 +891,12 @@ TEST(IPAddress, InvalidBBitAccess) {
 TEST(IPAddress, StringFormat) {
   in6_addr a6;
   for (int i = 0; i < 8; ++i) {
-    a6.s6_addr16[i] = htons(0x0123 + ((i%4) * 0x4444));
+    auto t = htons(0x0123 + ((i % 4) * 0x4444));
+#ifdef _WIN32
+    a6.u.Word[i] = t;
+#else
+    a6.s6_addr16[i] = t;
+#endif
   }
   EXPECT_EQ("0123:4567:89ab:cdef:0123:4567:89ab:cdef",
             detail::fastIpv6ToString(a6));