diff options
author | Gil <mcg@google.com> | 2018-06-01 13:42:47 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-01 13:42:47 -0700 |
commit | bb546e19885ae084823e0315e93564a44c0a8257 (patch) | |
tree | d755ae6087bae52da506fd7f9c5570d182ee85d5 /Firestore/core/test/firebase/firestore/util/hashing_test.cc | |
parent | 8b703e3b04f9b3784a93fe3fa579a1d8f07e981e (diff) |
Fix Firestore compilation under Xcode < 9.2 (#1367)
* Don't rely on specialization failure to determine when std::hash is unavailable.
Instead manually declare the conditions under which std::hash should be
defined.
* Fix detection of Objective-C classes in Xcode < 9.2
std::is_base_of<NSObject, NSString>{} is false there so the overloads
defined for Objective-C types weren't getting enabled.
* Add explicit tests for StringFormat using Objective-C objects
* Add explicit tests for HasStdHash
Diffstat (limited to 'Firestore/core/test/firebase/firestore/util/hashing_test.cc')
-rw-r--r-- | Firestore/core/test/firebase/firestore/util/hashing_test.cc | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Firestore/core/test/firebase/firestore/util/hashing_test.cc b/Firestore/core/test/firebase/firestore/util/hashing_test.cc index e5d9ff8..2c5c2f7 100644 --- a/Firestore/core/test/firebase/firestore/util/hashing_test.cc +++ b/Firestore/core/test/firebase/firestore/util/hashing_test.cc @@ -16,6 +16,9 @@ #include "Firestore/core/src/firebase/firestore/util/hashing.h" +#include <map> +#include <string> + #include "absl/strings/string_view.h" #include "gtest/gtest.h" @@ -29,6 +32,21 @@ struct HasHashMember { } }; +TEST(HashingTest, HasStdHash) { + EXPECT_TRUE(impl::has_std_hash<float>::value); + EXPECT_TRUE(impl::has_std_hash<double>::value); + EXPECT_TRUE(impl::has_std_hash<int>::value); + EXPECT_TRUE(impl::has_std_hash<int64_t>::value); + EXPECT_TRUE(impl::has_std_hash<std::string>::value); + EXPECT_TRUE(impl::has_std_hash<void*>::value); + EXPECT_TRUE(impl::has_std_hash<const char*>::value); + + struct Foo {}; + EXPECT_FALSE(impl::has_std_hash<Foo>::value); + EXPECT_FALSE(impl::has_std_hash<absl::string_view>::value); + EXPECT_FALSE((impl::has_std_hash<std::map<std::string, std::string>>::value)); +} + TEST(HashingTest, Int) { ASSERT_EQ(std::hash<int>{}(0), Hash(0)); } |