Index: base/containers/hash_tables_unittest.cc |
diff --git a/base/containers/hash_tables_unittest.cc b/base/containers/hash_tables_unittest.cc |
index 65724ecae224d67c991a685fbf3459df4ee1c5ab..60fbeaabc099c7cd967ac5c6c6409160fa0413cf 100644 |
--- a/base/containers/hash_tables_unittest.cc |
+++ b/base/containers/hash_tables_unittest.cc |
@@ -4,6 +4,8 @@ |
#include "base/containers/hash_tables.h" |
+#include <string> |
+ |
#include "base/basictypes.h" |
#include "testing/gtest/include/gtest/gtest.h" |
@@ -50,4 +52,16 @@ TEST_F(HashPairTest, IntegerPairs) { |
(GG_INT64_C(1) << 60) + GG_INT64_C(78931732321)); |
} |
+// Verify that base::hash_set<const char*> compares by pointer value, not as C |
+// strings. |
+TEST(HashTableTest, CharPointers) { |
+ std::string str1("hello"); |
+ std::string str2("hello"); |
+ base::hash_set<const char*> set; |
+ |
+ set.insert(str1.c_str()); |
+ EXPECT_EQ(1u, set.count(str1.c_str())); |
+ EXPECT_EQ(0u, set.count(str2.c_str())); |
+} |
+ |
} // namespace |