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

Unified Diff: components/safe_browsing_db/v4_store_unittest.cc

Issue 2614763002: DCHECK that full hash must be 21 bytes or 32 bytes long. (Closed)
Patch Set: Change DCHECK to accept 32 or 21 size. Add unit test. 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 2922a7aba55bfa96e37e1298db707f4ccc9e1e6d..575b340cc5631fa996aaa653bde6ea6b484f1980 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