Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Unified Diff: base/hash_unittest.cc

Issue 182253007: base::Hash: Minor improvements to documentation and testing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: s/Add/Insert/. Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/hash.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « base/hash.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698