File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -1239,6 +1239,30 @@ TEST(HashOf, DoubleSignCollision) {
12391239 EXPECT_NE (absl::HashOf (-1.0 ), absl::HashOf (1.0 ));
12401240}
12411241
1242+ // Test for collisions in short strings if PrecombineLengthMix is low quality.
1243+ TEST (PrecombineLengthMix, ShortStringCollision) {
1244+ std::string s1 = " 00" ;
1245+ std::string s2 = " 000" ;
1246+ constexpr char kMinChar = 0 ;
1247+ constexpr char kMaxChar = 32 ;
1248+ for (s1[0 ] = kMinChar ; s1[0 ] < kMaxChar ; ++s1[0 ]) {
1249+ for (s1[1 ] = kMinChar ; s1[1 ] < kMaxChar ; ++s1[1 ]) {
1250+ for (s2[0 ] = kMinChar ; s2[0 ] < kMaxChar ; ++s2[0 ]) {
1251+ for (s2[1 ] = kMinChar ; s2[1 ] < kMaxChar ; ++s2[1 ]) {
1252+ for (s2[2 ] = kMinChar ; s2[2 ] < kMaxChar ; ++s2[2 ]) {
1253+ ASSERT_NE (absl::HashOf (s1), absl::HashOf (s2))
1254+ << " s1[0]: " << static_cast <int >(s1[0 ])
1255+ << " ; s1[1]: " << static_cast <int >(s1[1 ])
1256+ << " ; s2[0]: " << static_cast <int >(s2[0 ])
1257+ << " ; s2[1]: " << static_cast <int >(s2[1 ])
1258+ << " ; s2[2]: " << static_cast <int >(s2[2 ]);
1259+ }
1260+ }
1261+ }
1262+ }
1263+ }
1264+ }
1265+
12421266// Test that we don't cause excessive collisions on the hash table for
12431267// doubles in the range [-1024, 1024]. See cl/773069881 for more information.
12441268TEST (SwisstableCollisions, DoubleRange) {
You can’t perform that action at this time.
0 commit comments