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

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: Added a comment that this algorithm is also in Blink. 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..afbd7973407ee8bd62b6525a409c4379549ee357 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));
+ // Add a null byte.
Noel Gordon 2014/03/05 04:47:01 nit: maybe s/Add/Insert/ ?
Matt Giuca 2014/03/05 04:49:17 Done.
+ 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