Index: base/hash_unittest.cc |
diff --git a/base/hash_unittest.cc b/base/hash_unittest.cc |
index 03f9db2ca40d389ba967d584eae3cd39d7352fac..fc8a7519ee98008e439a7c944ec8137fca1759bf 100644 |
--- a/base/hash_unittest.cc |
+++ b/base/hash_unittest.cc |
@@ -25,6 +25,16 @@ TEST(HashTest, String) { |
str = "helmo world"; |
EXPECT_EQ(1006697176u, Hash(str)); |
+ // Insert a null byte. |
+ str = "hello world"; |
+ str[5] = '\0'; |
+ EXPECT_EQ(2319902537u, Hash(str)); |
+ |
+ // Test that the bytes after the null contribute to the hash. |
+ str = "hello worle"; |
+ str[5] = '\0'; |
+ EXPECT_EQ(553904462u, Hash(str)); |
+ |
// Extremely long string. |
// Also tests strings with high bit set, and null byte. |
std::vector<char> long_string_buffer; |