Commit 77cf88a7 authored by Qinfan Wu's avatar Qinfan Wu Committed by Facebook Github Bot 6

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<char16_t>;
                        ^~~~~~~~~~~~~~
                        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
parent 6871c5cc
...@@ -2438,12 +2438,12 @@ _GLIBCXX_END_NAMESPACE_VERSION ...@@ -2438,12 +2438,12 @@ _GLIBCXX_END_NAMESPACE_VERSION
// Handle interaction with different C++ standard libraries, which // Handle interaction with different C++ standard libraries, which
// expect these types to be in different namespaces. // expect these types to be in different namespaces.
#define FOLLY_FBSTRING_HASH1(T) \ #define FOLLY_FBSTRING_HASH1(T) \
template <> \ template <> \
struct hash< ::folly::basic_fbstring<T> > { \ struct hash<::folly::basic_fbstring<T>> { \
size_t operator()(const ::folly::basic_fbstring<T>& s) const { \ size_t operator()(const ::folly::basic_fbstring<T>& s) const { \
return ::folly::hash::fnv32_buf(s.data(), s.size()); \ return ::folly::hash::fnv32_buf(s.data(), s.size() * sizeof(T)); \
} \ } \
}; };
// The C++11 standard says that these four are defined // The C++11 standard says that these four are defined
......
...@@ -1287,7 +1287,7 @@ TEST(FBString, testHash) { ...@@ -1287,7 +1287,7 @@ TEST(FBString, testHash) {
#if FOLLY_HAVE_WCHAR_SUPPORT #if FOLLY_HAVE_WCHAR_SUPPORT
TEST(FBString, testHashChar16) { TEST(FBString, testHashChar16) {
using u16fbstring = basic_fbstring<char16_t>; using u16fbstring = folly::basic_fbstring<char16_t>;
u16fbstring a; u16fbstring a;
u16fbstring b; u16fbstring b;
a.push_back(0); a.push_back(0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment