/*
- * Copyright 2017 Facebook, Inc.
+ * Copyright 2017-present Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
EXPECT_EQ(24, hashes.size());
}
+TEST(Hash, float_types) {
+ folly::Hash hasher;
+
+ EXPECT_EQ(hasher(0.0f), hasher(-0.0f));
+ EXPECT_EQ(hasher(0.0), hasher(-0.0));
+
+ // Basically just confirms that things compile ok.
+ std::unordered_set<size_t> hashes;
+ hashes.insert(hasher(0.0f));
+ hashes.insert(hasher(0.1f));
+ hashes.insert(hasher(0.2));
+ hashes.insert(hasher(0.2f));
+ hashes.insert(hasher(-0.3));
+ hashes.insert(hasher(-0.3f));
+
+ EXPECT_EQ(6, hashes.size());
+}
+
// Not a full hasher since only handles one type
class TestHasher {
public:
size_t hash_vector(const std::vector<T>& v) {
return hash_range(v.begin(), v.end());
}
-}
+} // namespace
TEST(Hash, hash_range) {
EXPECT_EQ(hash_vector<int32_t>({1, 2}), hash_vector<int16_t>({1, 2}));