| Index: third_party/WebKit/Source/wtf/StringHasherTest.cpp
|
| diff --git a/third_party/WebKit/Source/wtf/StringHasherTest.cpp b/third_party/WebKit/Source/wtf/StringHasherTest.cpp
|
| index 7e6dad5d0a71431658cdbd7b71330a05bbd76aab..abf958a01ae3cbb311e94557ecf1ea9d098127da 100644
|
| --- a/third_party/WebKit/Source/wtf/StringHasherTest.cpp
|
| +++ b/third_party/WebKit/Source/wtf/StringHasherTest.cpp
|
| @@ -31,15 +31,15 @@ namespace WTF {
|
|
|
| namespace {
|
|
|
| -const LChar nullLChars[2] = { 0, 0 };
|
| -const UChar nullUChars[2] = { 0, 0 };
|
| +const LChar nullLChars[2] = {0, 0};
|
| +const UChar nullUChars[2] = {0, 0};
|
|
|
| const unsigned emptyStringHash = 0x4EC889EU;
|
| const unsigned singleNullCharacterHash = 0x3D3ABF44U;
|
|
|
| -const LChar testALChars[6] = { 0x41, 0x95, 0xFF, 0x50, 0x01, 0 };
|
| -const UChar testAUChars[6] = { 0x41, 0x95, 0xFF, 0x50, 0x01, 0 };
|
| -const UChar testBUChars[6] = { 0x41, 0x95, 0xFFFF, 0x1080, 0x01, 0 };
|
| +const LChar testALChars[6] = {0x41, 0x95, 0xFF, 0x50, 0x01, 0};
|
| +const UChar testAUChars[6] = {0x41, 0x95, 0xFF, 0x50, 0x01, 0};
|
| +const UChar testBUChars[6] = {0x41, 0x95, 0xFFFF, 0x1080, 0x01, 0};
|
|
|
| const unsigned testAHash1 = 0xEA32B004;
|
| const unsigned testAHash2 = 0x93F0F71E;
|
| @@ -53,360 +53,375 @@ const unsigned testBHash3 = 0x59EB1B2C;
|
| const unsigned testBHash4 = 0xA7BCCC0A;
|
| const unsigned testBHash5 = 0x79201649;
|
|
|
| -} // anonymous namespace
|
| +} // anonymous namespace
|
|
|
| -TEST(StringHasherTest, StringHasher)
|
| -{
|
| - StringHasher hasher;
|
| +TEST(StringHasherTest, StringHasher) {
|
| + StringHasher hasher;
|
|
|
| - // The initial state of the hasher.
|
| - EXPECT_EQ(emptyStringHash, hasher.hash());
|
| - EXPECT_EQ(emptyStringHash & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| + // The initial state of the hasher.
|
| + EXPECT_EQ(emptyStringHash, hasher.hash());
|
| + EXPECT_EQ(emptyStringHash & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| }
|
|
|
| -TEST(StringHasherTest, StringHasher_addCharacter)
|
| -{
|
| - StringHasher hasher;
|
| -
|
| - // Hashing a single character.
|
| - hasher = StringHasher();
|
| - hasher.addCharacter(0);
|
| - EXPECT_EQ(singleNullCharacterHash, hasher.hash());
|
| - EXPECT_EQ(singleNullCharacterHash & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| -
|
| - // Hashing five characters, checking the intermediate state after each is added.
|
| - hasher = StringHasher();
|
| - hasher.addCharacter(testAUChars[0]);
|
| - EXPECT_EQ(testAHash1, hasher.hash());
|
| - EXPECT_EQ(testAHash1 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| - hasher.addCharacter(testAUChars[1]);
|
| - EXPECT_EQ(testAHash2, hasher.hash());
|
| - EXPECT_EQ(testAHash2 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| - hasher.addCharacter(testAUChars[2]);
|
| - EXPECT_EQ(testAHash3, hasher.hash());
|
| - EXPECT_EQ(testAHash3 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| - hasher.addCharacter(testAUChars[3]);
|
| - EXPECT_EQ(testAHash4, hasher.hash());
|
| - EXPECT_EQ(testAHash4 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| - hasher.addCharacter(testAUChars[4]);
|
| - EXPECT_EQ(testAHash5, hasher.hash());
|
| - EXPECT_EQ(testAHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| -
|
| - // Hashing a second set of five characters, including non-Latin-1 characters.
|
| - hasher = StringHasher();
|
| - hasher.addCharacter(testBUChars[0]);
|
| - EXPECT_EQ(testBHash1, hasher.hash());
|
| - EXPECT_EQ(testBHash1 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| - hasher.addCharacter(testBUChars[1]);
|
| - EXPECT_EQ(testBHash2, hasher.hash());
|
| - EXPECT_EQ(testBHash2 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| - hasher.addCharacter(testBUChars[2]);
|
| - EXPECT_EQ(testBHash3, hasher.hash());
|
| - EXPECT_EQ(testBHash3 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| - hasher.addCharacter(testBUChars[3]);
|
| - EXPECT_EQ(testBHash4, hasher.hash());
|
| - EXPECT_EQ(testBHash4 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| - hasher.addCharacter(testBUChars[4]);
|
| - EXPECT_EQ(testBHash5, hasher.hash());
|
| - EXPECT_EQ(testBHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| +TEST(StringHasherTest, StringHasher_addCharacter) {
|
| + StringHasher hasher;
|
| +
|
| + // Hashing a single character.
|
| + hasher = StringHasher();
|
| + hasher.addCharacter(0);
|
| + EXPECT_EQ(singleNullCharacterHash, hasher.hash());
|
| + EXPECT_EQ(singleNullCharacterHash & 0xFFFFFF,
|
| + hasher.hashWithTop8BitsMasked());
|
| +
|
| + // Hashing five characters, checking the intermediate state after each is added.
|
| + hasher = StringHasher();
|
| + hasher.addCharacter(testAUChars[0]);
|
| + EXPECT_EQ(testAHash1, hasher.hash());
|
| + EXPECT_EQ(testAHash1 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| + hasher.addCharacter(testAUChars[1]);
|
| + EXPECT_EQ(testAHash2, hasher.hash());
|
| + EXPECT_EQ(testAHash2 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| + hasher.addCharacter(testAUChars[2]);
|
| + EXPECT_EQ(testAHash3, hasher.hash());
|
| + EXPECT_EQ(testAHash3 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| + hasher.addCharacter(testAUChars[3]);
|
| + EXPECT_EQ(testAHash4, hasher.hash());
|
| + EXPECT_EQ(testAHash4 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| + hasher.addCharacter(testAUChars[4]);
|
| + EXPECT_EQ(testAHash5, hasher.hash());
|
| + EXPECT_EQ(testAHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| +
|
| + // Hashing a second set of five characters, including non-Latin-1 characters.
|
| + hasher = StringHasher();
|
| + hasher.addCharacter(testBUChars[0]);
|
| + EXPECT_EQ(testBHash1, hasher.hash());
|
| + EXPECT_EQ(testBHash1 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| + hasher.addCharacter(testBUChars[1]);
|
| + EXPECT_EQ(testBHash2, hasher.hash());
|
| + EXPECT_EQ(testBHash2 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| + hasher.addCharacter(testBUChars[2]);
|
| + EXPECT_EQ(testBHash3, hasher.hash());
|
| + EXPECT_EQ(testBHash3 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| + hasher.addCharacter(testBUChars[3]);
|
| + EXPECT_EQ(testBHash4, hasher.hash());
|
| + EXPECT_EQ(testBHash4 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| + hasher.addCharacter(testBUChars[4]);
|
| + EXPECT_EQ(testBHash5, hasher.hash());
|
| + EXPECT_EQ(testBHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| }
|
|
|
| -TEST(StringHasherTest, StringHasher_addCharacters)
|
| -{
|
| - StringHasher hasher;
|
| -
|
| - // Hashing zero characters.
|
| - hasher = StringHasher();
|
| - hasher.addCharacters(static_cast<LChar*>(0), 0);
|
| - EXPECT_EQ(emptyStringHash, hasher.hash());
|
| - EXPECT_EQ(emptyStringHash & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| - hasher = StringHasher();
|
| - hasher.addCharacters(nullLChars, 0);
|
| - 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());
|
| - hasher = StringHasher();
|
| - hasher.addCharacters(nullUChars, 0);
|
| - EXPECT_EQ(emptyStringHash, hasher.hash());
|
| - EXPECT_EQ(emptyStringHash & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| -
|
| - // Hashing one character.
|
| - hasher = StringHasher();
|
| - hasher.addCharacters(nullLChars, 1);
|
| - EXPECT_EQ(singleNullCharacterHash, hasher.hash());
|
| - EXPECT_EQ(singleNullCharacterHash & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| - hasher = StringHasher();
|
| - hasher.addCharacters(nullUChars, 1);
|
| - EXPECT_EQ(singleNullCharacterHash, hasher.hash());
|
| - EXPECT_EQ(singleNullCharacterHash & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| -
|
| - // Hashing five characters, all at once.
|
| - hasher = StringHasher();
|
| - hasher.addCharacters(testALChars, 5);
|
| - 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(testBUChars, 5);
|
| - EXPECT_EQ(testBHash5, hasher.hash());
|
| - EXPECT_EQ(testBHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| -
|
| - // Hashing five characters, in groups of two, then the last one.
|
| - hasher = StringHasher();
|
| - hasher.addCharacters(testALChars, 2);
|
| - EXPECT_EQ(testAHash2, hasher.hash());
|
| - EXPECT_EQ(testAHash2 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| - hasher.addCharacters(testALChars + 2, 2);
|
| - EXPECT_EQ(testAHash4, hasher.hash());
|
| - EXPECT_EQ(testAHash4 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| - hasher.addCharacters(testALChars + 4, 1);
|
| - EXPECT_EQ(testAHash5, hasher.hash());
|
| - EXPECT_EQ(testAHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| - hasher = StringHasher();
|
| - hasher.addCharacters(testALChars, 2);
|
| - hasher.addCharacters(testALChars + 2, 2);
|
| - hasher.addCharacters(testALChars + 4, 1);
|
| - EXPECT_EQ(testAHash5, hasher.hash());
|
| - EXPECT_EQ(testAHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| - hasher = StringHasher();
|
| - hasher.addCharacters(testAUChars, 2);
|
| - EXPECT_EQ(testAHash2, hasher.hash());
|
| - EXPECT_EQ(testAHash2 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| - hasher.addCharacters(testAUChars + 2, 2);
|
| - EXPECT_EQ(testAHash4, hasher.hash());
|
| - EXPECT_EQ(testAHash4 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| - hasher.addCharacters(testAUChars + 4, 1);
|
| - EXPECT_EQ(testAHash5, hasher.hash());
|
| - EXPECT_EQ(testAHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| - hasher = StringHasher();
|
| - hasher.addCharacters(testAUChars, 2);
|
| - hasher.addCharacters(testAUChars + 2, 2);
|
| - hasher.addCharacters(testAUChars + 4, 1);
|
| - EXPECT_EQ(testAHash5, hasher.hash());
|
| - EXPECT_EQ(testAHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| - hasher = StringHasher();
|
| - hasher.addCharacters(testBUChars, 2);
|
| - EXPECT_EQ(testBHash2, hasher.hash());
|
| - EXPECT_EQ(testBHash2 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| - hasher.addCharacters(testBUChars + 2, 2);
|
| - EXPECT_EQ(testBHash4, hasher.hash());
|
| - EXPECT_EQ(testBHash4 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| - hasher.addCharacters(testBUChars + 4, 1);
|
| - EXPECT_EQ(testBHash5, hasher.hash());
|
| - EXPECT_EQ(testBHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| - hasher = StringHasher();
|
| - hasher.addCharacters(testBUChars, 2);
|
| - hasher.addCharacters(testBUChars + 2, 2);
|
| - hasher.addCharacters(testBUChars + 4, 1);
|
| - EXPECT_EQ(testBHash5, hasher.hash());
|
| - EXPECT_EQ(testBHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| -
|
| - // Hashing five characters, the first three, then the last two.
|
| - hasher = StringHasher();
|
| - hasher.addCharacters(testALChars, 3);
|
| - EXPECT_EQ(testAHash3, hasher.hash());
|
| - EXPECT_EQ(testAHash3 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| - hasher.addCharacters(testALChars + 3, 2);
|
| - EXPECT_EQ(testAHash5, hasher.hash());
|
| - EXPECT_EQ(testAHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| - hasher = StringHasher();
|
| - hasher.addCharacters(testALChars, 3);
|
| - EXPECT_EQ(testAHash3, hasher.hash());
|
| - EXPECT_EQ(testAHash3 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| - hasher.addCharacters(testALChars + 3, 2);
|
| - EXPECT_EQ(testAHash5, hasher.hash());
|
| - EXPECT_EQ(testAHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| - hasher = StringHasher();
|
| - hasher.addCharacters(testAUChars, 3);
|
| - EXPECT_EQ(testAHash3, hasher.hash());
|
| - EXPECT_EQ(testAHash3 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| - hasher.addCharacters(testAUChars + 3, 2);
|
| - EXPECT_EQ(testAHash5, hasher.hash());
|
| - EXPECT_EQ(testAHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| - hasher = StringHasher();
|
| - hasher.addCharacters(testAUChars, 3);
|
| - EXPECT_EQ(testAHash3, hasher.hash());
|
| - EXPECT_EQ(testAHash3 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| - hasher.addCharacters(testAUChars + 3, 2);
|
| - EXPECT_EQ(testAHash5, hasher.hash());
|
| - EXPECT_EQ(testAHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| - hasher = StringHasher();
|
| - hasher.addCharacters(testBUChars, 3);
|
| - EXPECT_EQ(testBHash3, hasher.hash());
|
| - EXPECT_EQ(testBHash3 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| - hasher.addCharacters(testBUChars + 3, 2);
|
| - EXPECT_EQ(testBHash5, hasher.hash());
|
| - EXPECT_EQ(testBHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| - hasher = StringHasher();
|
| - hasher.addCharacters(testBUChars, 3);
|
| - hasher.addCharacters(testBUChars + 3, 2);
|
| - EXPECT_EQ(testBHash5, hasher.hash());
|
| - EXPECT_EQ(testBHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| +TEST(StringHasherTest, StringHasher_addCharacters) {
|
| + StringHasher hasher;
|
| +
|
| + // Hashing zero characters.
|
| + hasher = StringHasher();
|
| + hasher.addCharacters(static_cast<LChar*>(0), 0);
|
| + EXPECT_EQ(emptyStringHash, hasher.hash());
|
| + EXPECT_EQ(emptyStringHash & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| + hasher = StringHasher();
|
| + hasher.addCharacters(nullLChars, 0);
|
| + 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());
|
| + hasher = StringHasher();
|
| + hasher.addCharacters(nullUChars, 0);
|
| + EXPECT_EQ(emptyStringHash, hasher.hash());
|
| + EXPECT_EQ(emptyStringHash & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| +
|
| + // Hashing one character.
|
| + hasher = StringHasher();
|
| + hasher.addCharacters(nullLChars, 1);
|
| + EXPECT_EQ(singleNullCharacterHash, hasher.hash());
|
| + EXPECT_EQ(singleNullCharacterHash & 0xFFFFFF,
|
| + hasher.hashWithTop8BitsMasked());
|
| + hasher = StringHasher();
|
| + hasher.addCharacters(nullUChars, 1);
|
| + EXPECT_EQ(singleNullCharacterHash, hasher.hash());
|
| + EXPECT_EQ(singleNullCharacterHash & 0xFFFFFF,
|
| + hasher.hashWithTop8BitsMasked());
|
| +
|
| + // Hashing five characters, all at once.
|
| + hasher = StringHasher();
|
| + hasher.addCharacters(testALChars, 5);
|
| + 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(testBUChars, 5);
|
| + EXPECT_EQ(testBHash5, hasher.hash());
|
| + EXPECT_EQ(testBHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| +
|
| + // Hashing five characters, in groups of two, then the last one.
|
| + hasher = StringHasher();
|
| + hasher.addCharacters(testALChars, 2);
|
| + EXPECT_EQ(testAHash2, hasher.hash());
|
| + EXPECT_EQ(testAHash2 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| + hasher.addCharacters(testALChars + 2, 2);
|
| + EXPECT_EQ(testAHash4, hasher.hash());
|
| + EXPECT_EQ(testAHash4 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| + hasher.addCharacters(testALChars + 4, 1);
|
| + EXPECT_EQ(testAHash5, hasher.hash());
|
| + EXPECT_EQ(testAHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| + hasher = StringHasher();
|
| + hasher.addCharacters(testALChars, 2);
|
| + hasher.addCharacters(testALChars + 2, 2);
|
| + hasher.addCharacters(testALChars + 4, 1);
|
| + EXPECT_EQ(testAHash5, hasher.hash());
|
| + EXPECT_EQ(testAHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| + hasher = StringHasher();
|
| + hasher.addCharacters(testAUChars, 2);
|
| + EXPECT_EQ(testAHash2, hasher.hash());
|
| + EXPECT_EQ(testAHash2 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| + hasher.addCharacters(testAUChars + 2, 2);
|
| + EXPECT_EQ(testAHash4, hasher.hash());
|
| + EXPECT_EQ(testAHash4 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| + hasher.addCharacters(testAUChars + 4, 1);
|
| + EXPECT_EQ(testAHash5, hasher.hash());
|
| + EXPECT_EQ(testAHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| + hasher = StringHasher();
|
| + hasher.addCharacters(testAUChars, 2);
|
| + hasher.addCharacters(testAUChars + 2, 2);
|
| + hasher.addCharacters(testAUChars + 4, 1);
|
| + EXPECT_EQ(testAHash5, hasher.hash());
|
| + EXPECT_EQ(testAHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| + hasher = StringHasher();
|
| + hasher.addCharacters(testBUChars, 2);
|
| + EXPECT_EQ(testBHash2, hasher.hash());
|
| + EXPECT_EQ(testBHash2 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| + hasher.addCharacters(testBUChars + 2, 2);
|
| + EXPECT_EQ(testBHash4, hasher.hash());
|
| + EXPECT_EQ(testBHash4 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| + hasher.addCharacters(testBUChars + 4, 1);
|
| + EXPECT_EQ(testBHash5, hasher.hash());
|
| + EXPECT_EQ(testBHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| + hasher = StringHasher();
|
| + hasher.addCharacters(testBUChars, 2);
|
| + hasher.addCharacters(testBUChars + 2, 2);
|
| + hasher.addCharacters(testBUChars + 4, 1);
|
| + EXPECT_EQ(testBHash5, hasher.hash());
|
| + EXPECT_EQ(testBHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| +
|
| + // Hashing five characters, the first three, then the last two.
|
| + hasher = StringHasher();
|
| + hasher.addCharacters(testALChars, 3);
|
| + EXPECT_EQ(testAHash3, hasher.hash());
|
| + EXPECT_EQ(testAHash3 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| + hasher.addCharacters(testALChars + 3, 2);
|
| + EXPECT_EQ(testAHash5, hasher.hash());
|
| + EXPECT_EQ(testAHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| + hasher = StringHasher();
|
| + hasher.addCharacters(testALChars, 3);
|
| + EXPECT_EQ(testAHash3, hasher.hash());
|
| + EXPECT_EQ(testAHash3 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| + hasher.addCharacters(testALChars + 3, 2);
|
| + EXPECT_EQ(testAHash5, hasher.hash());
|
| + EXPECT_EQ(testAHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| + hasher = StringHasher();
|
| + hasher.addCharacters(testAUChars, 3);
|
| + EXPECT_EQ(testAHash3, hasher.hash());
|
| + EXPECT_EQ(testAHash3 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| + hasher.addCharacters(testAUChars + 3, 2);
|
| + EXPECT_EQ(testAHash5, hasher.hash());
|
| + EXPECT_EQ(testAHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| + hasher = StringHasher();
|
| + hasher.addCharacters(testAUChars, 3);
|
| + EXPECT_EQ(testAHash3, hasher.hash());
|
| + EXPECT_EQ(testAHash3 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| + hasher.addCharacters(testAUChars + 3, 2);
|
| + EXPECT_EQ(testAHash5, hasher.hash());
|
| + EXPECT_EQ(testAHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| + hasher = StringHasher();
|
| + hasher.addCharacters(testBUChars, 3);
|
| + EXPECT_EQ(testBHash3, hasher.hash());
|
| + EXPECT_EQ(testBHash3 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| + hasher.addCharacters(testBUChars + 3, 2);
|
| + EXPECT_EQ(testBHash5, hasher.hash());
|
| + EXPECT_EQ(testBHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| + hasher = StringHasher();
|
| + hasher.addCharacters(testBUChars, 3);
|
| + hasher.addCharacters(testBUChars + 3, 2);
|
| + EXPECT_EQ(testBHash5, hasher.hash());
|
| + EXPECT_EQ(testBHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| }
|
|
|
| -TEST(StringHasherTest, StringHasher_addCharactersAssumingAligned)
|
| -{
|
| - StringHasher hasher;
|
| -
|
| - // Hashing zero characters.
|
| - hasher = StringHasher();
|
| - hasher.addCharactersAssumingAligned(static_cast<LChar*>(0), 0);
|
| - EXPECT_EQ(emptyStringHash, hasher.hash());
|
| - EXPECT_EQ(emptyStringHash & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| - hasher = StringHasher();
|
| - hasher.addCharactersAssumingAligned(nullLChars, 0);
|
| - EXPECT_EQ(emptyStringHash, hasher.hash());
|
| - EXPECT_EQ(emptyStringHash & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| - hasher = StringHasher();
|
| - hasher.addCharactersAssumingAligned(static_cast<UChar*>(0), 0);
|
| - EXPECT_EQ(emptyStringHash, hasher.hash());
|
| - EXPECT_EQ(emptyStringHash & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| - hasher = StringHasher();
|
| - hasher.addCharactersAssumingAligned(nullUChars, 0);
|
| - EXPECT_EQ(emptyStringHash, hasher.hash());
|
| - EXPECT_EQ(emptyStringHash & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| -
|
| - // Hashing one character.
|
| - hasher = StringHasher();
|
| - hasher.addCharactersAssumingAligned(nullLChars, 1);
|
| - EXPECT_EQ(singleNullCharacterHash, hasher.hash());
|
| - EXPECT_EQ(singleNullCharacterHash & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| - hasher = StringHasher();
|
| - hasher.addCharactersAssumingAligned(nullUChars, 1);
|
| - EXPECT_EQ(singleNullCharacterHash, hasher.hash());
|
| - EXPECT_EQ(singleNullCharacterHash & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| -
|
| - // Hashing five characters, all at once.
|
| - hasher = StringHasher();
|
| - hasher.addCharactersAssumingAligned(testALChars, 5);
|
| - 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(testBUChars, 5);
|
| - EXPECT_EQ(testBHash5, hasher.hash());
|
| - EXPECT_EQ(testBHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| -
|
| - // Hashing five characters, in groups of two, then the last one.
|
| - hasher = StringHasher();
|
| - hasher.addCharactersAssumingAligned(testALChars, 2);
|
| - EXPECT_EQ(testAHash2, hasher.hash());
|
| - EXPECT_EQ(testAHash2 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| - hasher.addCharactersAssumingAligned(testALChars + 2, 2);
|
| - EXPECT_EQ(testAHash4, hasher.hash());
|
| - EXPECT_EQ(testAHash4 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| - hasher.addCharactersAssumingAligned(testALChars + 4, 1);
|
| - EXPECT_EQ(testAHash5, hasher.hash());
|
| - EXPECT_EQ(testAHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| - hasher = StringHasher();
|
| - hasher.addCharactersAssumingAligned(testALChars, 2);
|
| - hasher.addCharactersAssumingAligned(testALChars + 2, 2);
|
| - hasher.addCharactersAssumingAligned(testALChars + 4, 1);
|
| - EXPECT_EQ(testAHash5, hasher.hash());
|
| - EXPECT_EQ(testAHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| - hasher = StringHasher();
|
| - hasher.addCharactersAssumingAligned(testAUChars, 2);
|
| - EXPECT_EQ(testAHash2, hasher.hash());
|
| - EXPECT_EQ(testAHash2 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| - hasher.addCharactersAssumingAligned(testAUChars + 2, 2);
|
| - EXPECT_EQ(testAHash4, hasher.hash());
|
| - EXPECT_EQ(testAHash4 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| - hasher.addCharactersAssumingAligned(testAUChars + 4, 1);
|
| - EXPECT_EQ(testAHash5, hasher.hash());
|
| - EXPECT_EQ(testAHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| - hasher = StringHasher();
|
| - hasher.addCharactersAssumingAligned(testAUChars, 2);
|
| - hasher.addCharactersAssumingAligned(testAUChars + 2, 2);
|
| - hasher.addCharactersAssumingAligned(testAUChars + 4, 1);
|
| - EXPECT_EQ(testAHash5, hasher.hash());
|
| - EXPECT_EQ(testAHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| - hasher = StringHasher();
|
| - hasher.addCharactersAssumingAligned(testBUChars, 2);
|
| - EXPECT_EQ(testBHash2, hasher.hash());
|
| - EXPECT_EQ(testBHash2 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| - hasher.addCharactersAssumingAligned(testBUChars + 2, 2);
|
| - EXPECT_EQ(testBHash4, hasher.hash());
|
| - EXPECT_EQ(testBHash4 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| - hasher.addCharactersAssumingAligned(testBUChars + 4, 1);
|
| - EXPECT_EQ(testBHash5, hasher.hash());
|
| - EXPECT_EQ(testBHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| - hasher = StringHasher();
|
| - hasher.addCharactersAssumingAligned(testBUChars, 2);
|
| - hasher.addCharactersAssumingAligned(testBUChars + 2, 2);
|
| - hasher.addCharactersAssumingAligned(testBUChars + 4, 1);
|
| - EXPECT_EQ(testBHash5, hasher.hash());
|
| - EXPECT_EQ(testBHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| -
|
| - // Hashing five characters, first two characters one at a time,
|
| - // then two more, then the last one.
|
| - hasher = StringHasher();
|
| - hasher.addCharacter(testBUChars[0]);
|
| - EXPECT_EQ(testBHash1, hasher.hash());
|
| - EXPECT_EQ(testBHash1 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| - hasher.addCharacter(testBUChars[1]);
|
| - EXPECT_EQ(testBHash2, hasher.hash());
|
| - EXPECT_EQ(testBHash2 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| - hasher.addCharactersAssumingAligned(testBUChars[2], testBUChars[3]);
|
| - EXPECT_EQ(testBHash4, hasher.hash());
|
| - EXPECT_EQ(testBHash4 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| - hasher.addCharactersAssumingAligned(testBUChars + 4, 1);
|
| - EXPECT_EQ(testBHash5, hasher.hash());
|
| - EXPECT_EQ(testBHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| +TEST(StringHasherTest, StringHasher_addCharactersAssumingAligned) {
|
| + StringHasher hasher;
|
| +
|
| + // Hashing zero characters.
|
| + hasher = StringHasher();
|
| + hasher.addCharactersAssumingAligned(static_cast<LChar*>(0), 0);
|
| + EXPECT_EQ(emptyStringHash, hasher.hash());
|
| + EXPECT_EQ(emptyStringHash & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| + hasher = StringHasher();
|
| + hasher.addCharactersAssumingAligned(nullLChars, 0);
|
| + EXPECT_EQ(emptyStringHash, hasher.hash());
|
| + EXPECT_EQ(emptyStringHash & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| + hasher = StringHasher();
|
| + hasher.addCharactersAssumingAligned(static_cast<UChar*>(0), 0);
|
| + EXPECT_EQ(emptyStringHash, hasher.hash());
|
| + EXPECT_EQ(emptyStringHash & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| + hasher = StringHasher();
|
| + hasher.addCharactersAssumingAligned(nullUChars, 0);
|
| + EXPECT_EQ(emptyStringHash, hasher.hash());
|
| + EXPECT_EQ(emptyStringHash & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| +
|
| + // Hashing one character.
|
| + hasher = StringHasher();
|
| + hasher.addCharactersAssumingAligned(nullLChars, 1);
|
| + EXPECT_EQ(singleNullCharacterHash, hasher.hash());
|
| + EXPECT_EQ(singleNullCharacterHash & 0xFFFFFF,
|
| + hasher.hashWithTop8BitsMasked());
|
| + hasher = StringHasher();
|
| + hasher.addCharactersAssumingAligned(nullUChars, 1);
|
| + EXPECT_EQ(singleNullCharacterHash, hasher.hash());
|
| + EXPECT_EQ(singleNullCharacterHash & 0xFFFFFF,
|
| + hasher.hashWithTop8BitsMasked());
|
| +
|
| + // Hashing five characters, all at once.
|
| + hasher = StringHasher();
|
| + hasher.addCharactersAssumingAligned(testALChars, 5);
|
| + 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(testBUChars, 5);
|
| + EXPECT_EQ(testBHash5, hasher.hash());
|
| + EXPECT_EQ(testBHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| +
|
| + // Hashing five characters, in groups of two, then the last one.
|
| + hasher = StringHasher();
|
| + hasher.addCharactersAssumingAligned(testALChars, 2);
|
| + EXPECT_EQ(testAHash2, hasher.hash());
|
| + EXPECT_EQ(testAHash2 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| + hasher.addCharactersAssumingAligned(testALChars + 2, 2);
|
| + EXPECT_EQ(testAHash4, hasher.hash());
|
| + EXPECT_EQ(testAHash4 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| + hasher.addCharactersAssumingAligned(testALChars + 4, 1);
|
| + EXPECT_EQ(testAHash5, hasher.hash());
|
| + EXPECT_EQ(testAHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| + hasher = StringHasher();
|
| + hasher.addCharactersAssumingAligned(testALChars, 2);
|
| + hasher.addCharactersAssumingAligned(testALChars + 2, 2);
|
| + hasher.addCharactersAssumingAligned(testALChars + 4, 1);
|
| + EXPECT_EQ(testAHash5, hasher.hash());
|
| + EXPECT_EQ(testAHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| + hasher = StringHasher();
|
| + hasher.addCharactersAssumingAligned(testAUChars, 2);
|
| + EXPECT_EQ(testAHash2, hasher.hash());
|
| + EXPECT_EQ(testAHash2 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| + hasher.addCharactersAssumingAligned(testAUChars + 2, 2);
|
| + EXPECT_EQ(testAHash4, hasher.hash());
|
| + EXPECT_EQ(testAHash4 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| + hasher.addCharactersAssumingAligned(testAUChars + 4, 1);
|
| + EXPECT_EQ(testAHash5, hasher.hash());
|
| + EXPECT_EQ(testAHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| + hasher = StringHasher();
|
| + hasher.addCharactersAssumingAligned(testAUChars, 2);
|
| + hasher.addCharactersAssumingAligned(testAUChars + 2, 2);
|
| + hasher.addCharactersAssumingAligned(testAUChars + 4, 1);
|
| + EXPECT_EQ(testAHash5, hasher.hash());
|
| + EXPECT_EQ(testAHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| + hasher = StringHasher();
|
| + hasher.addCharactersAssumingAligned(testBUChars, 2);
|
| + EXPECT_EQ(testBHash2, hasher.hash());
|
| + EXPECT_EQ(testBHash2 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| + hasher.addCharactersAssumingAligned(testBUChars + 2, 2);
|
| + EXPECT_EQ(testBHash4, hasher.hash());
|
| + EXPECT_EQ(testBHash4 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| + hasher.addCharactersAssumingAligned(testBUChars + 4, 1);
|
| + EXPECT_EQ(testBHash5, hasher.hash());
|
| + EXPECT_EQ(testBHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| + hasher = StringHasher();
|
| + hasher.addCharactersAssumingAligned(testBUChars, 2);
|
| + hasher.addCharactersAssumingAligned(testBUChars + 2, 2);
|
| + hasher.addCharactersAssumingAligned(testBUChars + 4, 1);
|
| + EXPECT_EQ(testBHash5, hasher.hash());
|
| + EXPECT_EQ(testBHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| +
|
| + // Hashing five characters, first two characters one at a time,
|
| + // then two more, then the last one.
|
| + hasher = StringHasher();
|
| + hasher.addCharacter(testBUChars[0]);
|
| + EXPECT_EQ(testBHash1, hasher.hash());
|
| + EXPECT_EQ(testBHash1 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| + hasher.addCharacter(testBUChars[1]);
|
| + EXPECT_EQ(testBHash2, hasher.hash());
|
| + EXPECT_EQ(testBHash2 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| + hasher.addCharactersAssumingAligned(testBUChars[2], testBUChars[3]);
|
| + EXPECT_EQ(testBHash4, hasher.hash());
|
| + EXPECT_EQ(testBHash4 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| + hasher.addCharactersAssumingAligned(testBUChars + 4, 1);
|
| + EXPECT_EQ(testBHash5, hasher.hash());
|
| + EXPECT_EQ(testBHash5 & 0xFFFFFF, hasher.hashWithTop8BitsMasked());
|
| }
|
|
|
| -TEST(StringHasherTest, StringHasher_computeHash)
|
| -{
|
| - EXPECT_EQ(emptyStringHash, StringHasher::computeHash(static_cast<LChar*>(0), 0));
|
| - EXPECT_EQ(emptyStringHash, StringHasher::computeHash(nullLChars, 0));
|
| - EXPECT_EQ(emptyStringHash, StringHasher::computeHash(static_cast<UChar*>(0), 0));
|
| - EXPECT_EQ(emptyStringHash, StringHasher::computeHash(nullUChars, 0));
|
| +TEST(StringHasherTest, StringHasher_computeHash) {
|
| + EXPECT_EQ(emptyStringHash,
|
| + StringHasher::computeHash(static_cast<LChar*>(0), 0));
|
| + EXPECT_EQ(emptyStringHash, StringHasher::computeHash(nullLChars, 0));
|
| + EXPECT_EQ(emptyStringHash,
|
| + StringHasher::computeHash(static_cast<UChar*>(0), 0));
|
| + EXPECT_EQ(emptyStringHash, StringHasher::computeHash(nullUChars, 0));
|
|
|
| - EXPECT_EQ(singleNullCharacterHash, StringHasher::computeHash(nullLChars, 1));
|
| - EXPECT_EQ(singleNullCharacterHash, StringHasher::computeHash(nullUChars, 1));
|
| + EXPECT_EQ(singleNullCharacterHash, StringHasher::computeHash(nullLChars, 1));
|
| + EXPECT_EQ(singleNullCharacterHash, StringHasher::computeHash(nullUChars, 1));
|
|
|
| - EXPECT_EQ(testAHash5, StringHasher::computeHash(testALChars, 5));
|
| - EXPECT_EQ(testAHash5, StringHasher::computeHash(testAUChars, 5));
|
| - EXPECT_EQ(testBHash5, StringHasher::computeHash(testBUChars, 5));
|
| + EXPECT_EQ(testAHash5, StringHasher::computeHash(testALChars, 5));
|
| + EXPECT_EQ(testAHash5, StringHasher::computeHash(testAUChars, 5));
|
| + EXPECT_EQ(testBHash5, StringHasher::computeHash(testBUChars, 5));
|
| }
|
|
|
| -TEST(StringHasherTest, StringHasher_computeHashAndMaskTop8Bits)
|
| -{
|
| - EXPECT_EQ(emptyStringHash & 0xFFFFFF, StringHasher::computeHashAndMaskTop8Bits(static_cast<LChar*>(0), 0));
|
| - EXPECT_EQ(emptyStringHash & 0xFFFFFF, StringHasher::computeHashAndMaskTop8Bits(nullLChars, 0));
|
| - EXPECT_EQ(emptyStringHash & 0xFFFFFF, StringHasher::computeHashAndMaskTop8Bits(static_cast<UChar*>(0), 0));
|
| - EXPECT_EQ(emptyStringHash & 0xFFFFFF, StringHasher::computeHashAndMaskTop8Bits(nullUChars, 0));
|
| -
|
| - EXPECT_EQ(singleNullCharacterHash & 0xFFFFFF, StringHasher::computeHashAndMaskTop8Bits(nullLChars, 1));
|
| - EXPECT_EQ(singleNullCharacterHash & 0xFFFFFF, StringHasher::computeHashAndMaskTop8Bits(nullUChars, 1));
|
| -
|
| - EXPECT_EQ(testAHash5 & 0xFFFFFF, StringHasher::computeHashAndMaskTop8Bits(testALChars, 5));
|
| - EXPECT_EQ(testAHash5 & 0xFFFFFF, StringHasher::computeHashAndMaskTop8Bits(testAUChars, 5));
|
| - EXPECT_EQ(testBHash5 & 0xFFFFFF, StringHasher::computeHashAndMaskTop8Bits(testBUChars, 5));
|
| +TEST(StringHasherTest, StringHasher_computeHashAndMaskTop8Bits) {
|
| + EXPECT_EQ(
|
| + emptyStringHash & 0xFFFFFF,
|
| + StringHasher::computeHashAndMaskTop8Bits(static_cast<LChar*>(0), 0));
|
| + EXPECT_EQ(emptyStringHash & 0xFFFFFF,
|
| + StringHasher::computeHashAndMaskTop8Bits(nullLChars, 0));
|
| + EXPECT_EQ(
|
| + emptyStringHash & 0xFFFFFF,
|
| + StringHasher::computeHashAndMaskTop8Bits(static_cast<UChar*>(0), 0));
|
| + EXPECT_EQ(emptyStringHash & 0xFFFFFF,
|
| + StringHasher::computeHashAndMaskTop8Bits(nullUChars, 0));
|
| +
|
| + EXPECT_EQ(singleNullCharacterHash & 0xFFFFFF,
|
| + StringHasher::computeHashAndMaskTop8Bits(nullLChars, 1));
|
| + EXPECT_EQ(singleNullCharacterHash & 0xFFFFFF,
|
| + StringHasher::computeHashAndMaskTop8Bits(nullUChars, 1));
|
| +
|
| + EXPECT_EQ(testAHash5 & 0xFFFFFF,
|
| + StringHasher::computeHashAndMaskTop8Bits(testALChars, 5));
|
| + EXPECT_EQ(testAHash5 & 0xFFFFFF,
|
| + StringHasher::computeHashAndMaskTop8Bits(testAUChars, 5));
|
| + EXPECT_EQ(testBHash5 & 0xFFFFFF,
|
| + StringHasher::computeHashAndMaskTop8Bits(testBUChars, 5));
|
| }
|
|
|
| -TEST(StringHasherTest, StringHasher_hashMemory)
|
| -{
|
| - EXPECT_EQ(emptyStringHash & 0xFFFFFF, StringHasher::hashMemory(0, 0));
|
| - EXPECT_EQ(emptyStringHash & 0xFFFFFF, StringHasher::hashMemory(nullUChars, 0));
|
| - EXPECT_EQ(emptyStringHash & 0xFFFFFF, StringHasher::hashMemory<0>(0));
|
| - EXPECT_EQ(emptyStringHash & 0xFFFFFF, StringHasher::hashMemory<0>(nullUChars));
|
| -
|
| - EXPECT_EQ(singleNullCharacterHash & 0xFFFFFF, StringHasher::hashMemory(nullUChars, 2));
|
| - EXPECT_EQ(singleNullCharacterHash & 0xFFFFFF, StringHasher::hashMemory<2>(nullUChars));
|
| -
|
| - EXPECT_EQ(testAHash5 & 0xFFFFFF, StringHasher::hashMemory(testAUChars, 10));
|
| - EXPECT_EQ(testAHash5 & 0xFFFFFF, StringHasher::hashMemory<10>(testAUChars));
|
| - EXPECT_EQ(testBHash5 & 0xFFFFFF, StringHasher::hashMemory(testBUChars, 10));
|
| - EXPECT_EQ(testBHash5 & 0xFFFFFF, StringHasher::hashMemory<10>(testBUChars));
|
| +TEST(StringHasherTest, StringHasher_hashMemory) {
|
| + EXPECT_EQ(emptyStringHash & 0xFFFFFF, StringHasher::hashMemory(0, 0));
|
| + EXPECT_EQ(emptyStringHash & 0xFFFFFF,
|
| + StringHasher::hashMemory(nullUChars, 0));
|
| + EXPECT_EQ(emptyStringHash & 0xFFFFFF, StringHasher::hashMemory<0>(0));
|
| + EXPECT_EQ(emptyStringHash & 0xFFFFFF,
|
| + StringHasher::hashMemory<0>(nullUChars));
|
| +
|
| + EXPECT_EQ(singleNullCharacterHash & 0xFFFFFF,
|
| + StringHasher::hashMemory(nullUChars, 2));
|
| + EXPECT_EQ(singleNullCharacterHash & 0xFFFFFF,
|
| + StringHasher::hashMemory<2>(nullUChars));
|
| +
|
| + EXPECT_EQ(testAHash5 & 0xFFFFFF, StringHasher::hashMemory(testAUChars, 10));
|
| + EXPECT_EQ(testAHash5 & 0xFFFFFF, StringHasher::hashMemory<10>(testAUChars));
|
| + EXPECT_EQ(testBHash5 & 0xFFFFFF, StringHasher::hashMemory(testBUChars, 10));
|
| + EXPECT_EQ(testBHash5 & 0xFFFFFF, StringHasher::hashMemory<10>(testBUChars));
|
| }
|
|
|
| -} // namespace WTF
|
| +} // namespace WTF
|
|
|