Fix copyright lines
[folly.git] / folly / hash / test / HashTest.cpp
index fe7a804291e382b7dfdad3a9a2468afc98f031be..422673de434c4a559bdd3b4804f6d11d0f8b7d11 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * 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.
@@ -217,6 +217,24 @@ TEST(Hash, integral_types) {
   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:
@@ -360,7 +378,7 @@ template <class T>
 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}));