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

Unified Diff: Source/wtf/StringHasherTest.cpp

Issue 328453003: Refactor to remove unnecessary code from the string hashing functions (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix the unit tests Created 6 years, 6 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 | « Source/wtf/StringHasher.h ('k') | Source/wtf/text/AtomicString.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/wtf/StringHasherTest.cpp
diff --git a/Source/wtf/StringHasherTest.cpp b/Source/wtf/StringHasherTest.cpp
index 7ac443b6f1c41f7566d37e407481e37ee25d7659..f7557b6c6f6ec3aee8a5bb7515df7f4312a7178b 100644
--- a/Source/wtf/StringHasherTest.cpp
+++ b/Source/wtf/StringHasherTest.cpp
@@ -122,10 +122,6 @@ TEST(StringHasherTest, StringHasher_addCharacters)
EXPECT_EQ(emptyStringHash, hasher.hash());
EXPECT_EQ(emptyStringHash & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
hasher = StringHasher();
- hasher.addCharacters(nullLChars);
- EXPECT_EQ(emptyStringHash, hasher.hash());
- EXPECT_EQ(emptyStringHash & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
- hasher = StringHasher();
hasher.addCharacters(static_cast<UChar*>(0), 0);
EXPECT_EQ(emptyStringHash, hasher.hash());
EXPECT_EQ(emptyStringHash & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
@@ -133,10 +129,6 @@ TEST(StringHasherTest, StringHasher_addCharacters)
hasher.addCharacters(nullUChars, 0);
EXPECT_EQ(emptyStringHash, hasher.hash());
EXPECT_EQ(emptyStringHash & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
- hasher = StringHasher();
- hasher.addCharacters(nullUChars);
- EXPECT_EQ(emptyStringHash, hasher.hash());
- EXPECT_EQ(emptyStringHash & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
// Hashing one character.
hasher = StringHasher();
@@ -154,25 +146,13 @@ TEST(StringHasherTest, StringHasher_addCharacters)
EXPECT_EQ(testAHash5, hasher.hash());
EXPECT_EQ(testAHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
hasher = StringHasher();
- hasher.addCharacters(testALChars);
- EXPECT_EQ(testAHash5, hasher.hash());
- EXPECT_EQ(testAHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
- hasher = StringHasher();
hasher.addCharacters(testAUChars, 5);
EXPECT_EQ(testAHash5, hasher.hash());
EXPECT_EQ(testAHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
hasher = StringHasher();
- hasher.addCharacters(testAUChars);
- EXPECT_EQ(testAHash5, hasher.hash());
- EXPECT_EQ(testAHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
- hasher = StringHasher();
hasher.addCharacters(testBUChars, 5);
EXPECT_EQ(testBHash5, hasher.hash());
EXPECT_EQ(testBHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
- hasher = StringHasher();
- hasher.addCharacters(testBUChars);
- EXPECT_EQ(testBHash5, hasher.hash());
- EXPECT_EQ(testBHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
// Hashing five characters, in groups of two, then the last one.
hasher = StringHasher();
@@ -188,7 +168,7 @@ TEST(StringHasherTest, StringHasher_addCharacters)
hasher = StringHasher();
hasher.addCharacters(testALChars, 2);
hasher.addCharacters(testALChars + 2, 2);
- hasher.addCharacters(testALChars + 4);
+ hasher.addCharacters(testALChars + 4, 1);
EXPECT_EQ(testAHash5, hasher.hash());
EXPECT_EQ(testAHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
hasher = StringHasher();
@@ -204,7 +184,7 @@ TEST(StringHasherTest, StringHasher_addCharacters)
hasher = StringHasher();
hasher.addCharacters(testAUChars, 2);
hasher.addCharacters(testAUChars + 2, 2);
- hasher.addCharacters(testAUChars + 4);
+ hasher.addCharacters(testAUChars + 4, 1);
EXPECT_EQ(testAHash5, hasher.hash());
EXPECT_EQ(testAHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
hasher = StringHasher();
@@ -220,7 +200,7 @@ TEST(StringHasherTest, StringHasher_addCharacters)
hasher = StringHasher();
hasher.addCharacters(testBUChars, 2);
hasher.addCharacters(testBUChars + 2, 2);
- hasher.addCharacters(testBUChars + 4);
+ hasher.addCharacters(testBUChars + 4, 1);
EXPECT_EQ(testBHash5, hasher.hash());
EXPECT_EQ(testBHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
@@ -236,7 +216,7 @@ TEST(StringHasherTest, StringHasher_addCharacters)
hasher.addCharacters(testALChars, 3);
EXPECT_EQ(testAHash3, hasher.hash());
EXPECT_EQ(testAHash3 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
- hasher.addCharacters(testALChars + 3);
+ hasher.addCharacters(testALChars + 3, 2);
EXPECT_EQ(testAHash5, hasher.hash());
EXPECT_EQ(testAHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
hasher = StringHasher();
@@ -262,7 +242,7 @@ TEST(StringHasherTest, StringHasher_addCharacters)
EXPECT_EQ(testBHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
hasher = StringHasher();
hasher.addCharacters(testBUChars, 3);
- hasher.addCharacters(testBUChars + 3);
+ hasher.addCharacters(testBUChars + 3, 2);
EXPECT_EQ(testBHash5, hasher.hash());
EXPECT_EQ(testBHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
}
@@ -288,10 +268,6 @@ TEST(StringHasherTest, StringHasher_addCharactersAssumingAligned)
hasher.addCharactersAssumingAligned(nullUChars, 0);
EXPECT_EQ(emptyStringHash, hasher.hash());
EXPECT_EQ(emptyStringHash & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
- hasher = StringHasher();
- hasher.addCharactersAssumingAligned(nullUChars);
- EXPECT_EQ(emptyStringHash, hasher.hash());
- EXPECT_EQ(emptyStringHash & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
// Hashing one character.
hasher = StringHasher();
@@ -309,25 +285,13 @@ TEST(StringHasherTest, StringHasher_addCharactersAssumingAligned)
EXPECT_EQ(testAHash5, hasher.hash());
EXPECT_EQ(testAHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
hasher = StringHasher();
- hasher.addCharactersAssumingAligned(testALChars);
- EXPECT_EQ(testAHash5, hasher.hash());
- EXPECT_EQ(testAHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
- hasher = StringHasher();
hasher.addCharactersAssumingAligned(testAUChars, 5);
EXPECT_EQ(testAHash5, hasher.hash());
EXPECT_EQ(testAHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
hasher = StringHasher();
- hasher.addCharactersAssumingAligned(testAUChars);
- EXPECT_EQ(testAHash5, hasher.hash());
- EXPECT_EQ(testAHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
- hasher = StringHasher();
hasher.addCharactersAssumingAligned(testBUChars, 5);
EXPECT_EQ(testBHash5, hasher.hash());
EXPECT_EQ(testBHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
- hasher = StringHasher();
- hasher.addCharactersAssumingAligned(testBUChars);
- EXPECT_EQ(testBHash5, hasher.hash());
- EXPECT_EQ(testBHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
// Hashing five characters, in groups of two, then the last one.
hasher = StringHasher();
@@ -343,7 +307,7 @@ TEST(StringHasherTest, StringHasher_addCharactersAssumingAligned)
hasher = StringHasher();
hasher.addCharactersAssumingAligned(testALChars, 2);
hasher.addCharactersAssumingAligned(testALChars + 2, 2);
- hasher.addCharactersAssumingAligned(testALChars + 4);
+ hasher.addCharactersAssumingAligned(testALChars + 4, 1);
EXPECT_EQ(testAHash5, hasher.hash());
EXPECT_EQ(testAHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
hasher = StringHasher();
@@ -359,7 +323,7 @@ TEST(StringHasherTest, StringHasher_addCharactersAssumingAligned)
hasher = StringHasher();
hasher.addCharactersAssumingAligned(testAUChars, 2);
hasher.addCharactersAssumingAligned(testAUChars + 2, 2);
- hasher.addCharactersAssumingAligned(testAUChars + 4);
+ hasher.addCharactersAssumingAligned(testAUChars + 4, 1);
EXPECT_EQ(testAHash5, hasher.hash());
EXPECT_EQ(testAHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
hasher = StringHasher();
@@ -375,7 +339,7 @@ TEST(StringHasherTest, StringHasher_addCharactersAssumingAligned)
hasher = StringHasher();
hasher.addCharactersAssumingAligned(testBUChars, 2);
hasher.addCharactersAssumingAligned(testBUChars + 2, 2);
- hasher.addCharactersAssumingAligned(testBUChars + 4);
+ hasher.addCharactersAssumingAligned(testBUChars + 4, 1);
EXPECT_EQ(testBHash5, hasher.hash());
EXPECT_EQ(testBHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
@@ -391,7 +355,7 @@ TEST(StringHasherTest, StringHasher_addCharactersAssumingAligned)
hasher.addCharactersAssumingAligned(testBUChars[2], testBUChars[3]);
EXPECT_EQ(testBHash4, hasher.hash());
EXPECT_EQ(testBHash4 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
- hasher.addCharactersAssumingAligned(testBUChars + 4);
+ hasher.addCharactersAssumingAligned(testBUChars + 4, 1);
EXPECT_EQ(testBHash5, hasher.hash());
EXPECT_EQ(testBHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
}
« no previous file with comments | « Source/wtf/StringHasher.h ('k') | Source/wtf/text/AtomicString.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698