From ec1cb4c056410025f7fff1ebd999b6378080d264 Mon Sep 17 00:00:00 2001 From: Christopher Dykes Date: Mon, 31 Oct 2016 12:00:28 -0700 Subject: [PATCH] Access the individual words of an IPv6 address correctly in IPAddressTest on Windows Summary: Winsock defines the internals of `in6_addr` in its own way, so we have to account for that. Reviewed By: jsedgwick Differential Revision: D4099453 fbshipit-source-id: c0ebb4e2017f61bed7d5d63058161ef3f16f9a65 --- folly/test/IPAddressTest.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/folly/test/IPAddressTest.cpp b/folly/test/IPAddressTest.cpp index 9fc746d7..93f2aa1c 100644 --- a/folly/test/IPAddressTest.cpp +++ b/folly/test/IPAddressTest.cpp @@ -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)); -- 2.34.1