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

Unified Diff: components/safe_browsing_db/v4_store_unittest.cc

Issue 2625933007: [M56] DCHECK that full hash must be 32 bytes or 21 bytes long (Closed)
Patch Set: Created 3 years, 11 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 | « components/safe_browsing_db/v4_store.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/safe_browsing_db/v4_store_unittest.cc
diff --git a/components/safe_browsing_db/v4_store_unittest.cc b/components/safe_browsing_db/v4_store_unittest.cc
index bcd2a7db0fc9a55afe8dd5cd0db2d992d06d5c9f..2d2e3d76720cfb10486ca9f6a771ac51c7ae6489 100644
--- a/components/safe_browsing_db/v4_store_unittest.cc
+++ b/components/safe_browsing_db/v4_store_unittest.cc
@@ -673,6 +673,22 @@ TEST_F(V4StoreTest, TestHashPrefixDoesNotExistInMapWithDifferentSizes) {
EXPECT_TRUE(store.GetMatchingHashPrefix(full_hash).empty());
}
+TEST_F(V4StoreTest, GetMatchingHashPrefixSize32Or21) {
+ HashPrefix prefix = "0123";
+ V4Store store(task_runner_, store_path_);
+ store.hash_prefix_map_[4] = prefix;
+
+ FullHash full_hash_21 = "0123456789ABCDEF01234";
+ EXPECT_EQ(prefix, store.GetMatchingHashPrefix(full_hash_21));
+ FullHash full_hash_32 = "0123456789ABCDEF0123456789ABCDEF";
+ EXPECT_EQ(prefix, store.GetMatchingHashPrefix(full_hash_32));
+#if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON)
+ // This hits a DCHECK so it is release mode only.
+ FullHash full_hash_22 = "0123456789ABCDEF012345";
+ EXPECT_EQ(prefix, store.GetMatchingHashPrefix(full_hash_22));
+#endif
+}
+
#if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON)
// This test hits a NOTREACHED so it is a release mode only test.
TEST_F(V4StoreTest, TestAdditionsWithRiceEncodingFailsWithInvalidInput) {
« no previous file with comments | « components/safe_browsing_db/v4_store.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698