From 77cf88a74ec8fce0d460613411df8a7cad871d3a Mon Sep 17 00:00:00 2001 From: Qinfan Wu Date: Fri, 15 Jul 2016 22:52:10 -0700 Subject: [PATCH] Fix FBStringTest build failure and hash computation for wchar Summary: Getting some build errors when doing `buck test folly/...`. This seems to be fixing it. folly/test/FBStringTest.cpp:1290:23: error: unknown type name 'basic_fbstring'; did you mean 'basic_fstream'? using u16fbstring = basic_fbstring; ^~~~~~~~~~~~~~ basic_fstream Also the test `testHashChar16` was failing because only part of the string is used when computing hash. Reviewed By: yfeldblum Differential Revision: D3575858 fbshipit-source-id: cdd5bdb9653d50beaf0ec82b659d31354b345441 --- folly/FBString.h | 12 ++++++------ folly/test/FBStringTest.cpp | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/folly/FBString.h b/folly/FBString.h index 9a50e299..b3ec8f43 100644 --- a/folly/FBString.h +++ b/folly/FBString.h @@ -2438,12 +2438,12 @@ _GLIBCXX_END_NAMESPACE_VERSION // Handle interaction with different C++ standard libraries, which // expect these types to be in different namespaces. -#define FOLLY_FBSTRING_HASH1(T) \ - template <> \ - struct hash< ::folly::basic_fbstring > { \ - size_t operator()(const ::folly::basic_fbstring& s) const { \ - return ::folly::hash::fnv32_buf(s.data(), s.size()); \ - } \ +#define FOLLY_FBSTRING_HASH1(T) \ + template <> \ + struct hash<::folly::basic_fbstring> { \ + size_t operator()(const ::folly::basic_fbstring& s) const { \ + return ::folly::hash::fnv32_buf(s.data(), s.size() * sizeof(T)); \ + } \ }; // The C++11 standard says that these four are defined diff --git a/folly/test/FBStringTest.cpp b/folly/test/FBStringTest.cpp index 8767b28f..56b6ef0c 100644 --- a/folly/test/FBStringTest.cpp +++ b/folly/test/FBStringTest.cpp @@ -1287,7 +1287,7 @@ TEST(FBString, testHash) { #if FOLLY_HAVE_WCHAR_SUPPORT TEST(FBString, testHashChar16) { - using u16fbstring = basic_fbstring; + using u16fbstring = folly::basic_fbstring; u16fbstring a; u16fbstring b; a.push_back(0); -- 2.34.1