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

Unified Diff: components/safe_browsing_db/v4_store_unittest.cc

Issue 2151193002: Revert of PVer4: Keep track of the smallest hashes not their sizes. Replace counters with iterators. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@01_read_map_from_disk
Patch Set: Created 4 years, 5 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 3bcb884e2803c572ec93f2efa9a8a1e7a1cd64c9..cb0fd02aaaf26e80826517b633ff3f73e7a753b8 100644
--- a/components/safe_browsing_db/v4_store_unittest.cc
+++ b/components/safe_browsing_db/v4_store_unittest.cc
@@ -177,29 +177,46 @@
EXPECT_EQ("abcde5432100000-----", hash_prefixes);
}
-TEST_F(V4StoreTest, TestGetNextSmallestUnmergedPrefixWithEmptyPrefixMap) {
- HashPrefixMap prefix_map;
- IteratorMap iterator_map;
- V4Store::InitializeIteratorMap(prefix_map, &iterator_map);
-
- HashPrefix prefix;
- EXPECT_FALSE(V4Store::GetNextSmallestUnmergedPrefix(prefix_map, iterator_map,
- &prefix));
-}
-
-TEST_F(V4StoreTest, TestGetNextSmallestUnmergedPrefix) {
+TEST_F(V4StoreTest, TestGetNextSmallestPrefixSizeWithEmptyPrefixMap) {
+ HashPrefixMap prefix_map;
+ CounterMap counter_map;
+ V4Store::InitializeCounterMap(prefix_map, &counter_map);
+
+ PrefixSize prefix_size;
+ EXPECT_FALSE(V4Store::GetNextSmallestPrefixSize(prefix_map, counter_map,
+ &prefix_size));
+}
+
+TEST_F(V4StoreTest, TestGetNextSmallestPrefixSize) {
HashPrefixMap prefix_map;
EXPECT_EQ(APPLY_UPDATE_SUCCESS,
V4Store::AddUnlumpedHashes(5, "-----0000054321abcde", &prefix_map));
EXPECT_EQ(APPLY_UPDATE_SUCCESS,
- V4Store::AddUnlumpedHashes(4, "*****0000054321abcde", &prefix_map));
- IteratorMap iterator_map;
- V4Store::InitializeIteratorMap(prefix_map, &iterator_map);
-
- HashPrefix prefix;
- EXPECT_TRUE(V4Store::GetNextSmallestUnmergedPrefix(prefix_map, iterator_map,
- &prefix));
- EXPECT_EQ("****", prefix);
+ V4Store::AddUnlumpedHashes(4, "-----0000054321abcde", &prefix_map));
+ CounterMap counter_map;
+ V4Store::InitializeCounterMap(prefix_map, &counter_map);
+
+ PrefixSize prefix_size;
+ EXPECT_TRUE(V4Store::GetNextSmallestPrefixSize(prefix_map, counter_map,
+ &prefix_size));
+ EXPECT_EQ(4u, prefix_size);
+}
+
+TEST_F(V4StoreTest, TestGetNextUnmergedPrefix) {
+ HashPrefixMap prefix_map;
+ EXPECT_EQ(APPLY_UPDATE_SUCCESS,
+ V4Store::AddUnlumpedHashes(5, "-----0000054321abcde", &prefix_map));
+ EXPECT_EQ(APPLY_UPDATE_SUCCESS,
+ V4Store::AddUnlumpedHashes(4, "-----0000054321abcde", &prefix_map));
+ CounterMap counter_map;
+ V4Store::InitializeCounterMap(prefix_map, &counter_map);
+
+ PrefixSize prefix_size;
+ EXPECT_TRUE(V4Store::GetNextSmallestPrefixSize(prefix_map, counter_map,
+ &prefix_size));
+ const HashPrefix& prefix = V4Store::GetNextUnmergedPrefixForSize(
+ prefix_size, prefix_map, counter_map);
+ EXPECT_EQ("----", prefix);
}
TEST_F(V4StoreTest, TestMergeUpdatesWithSameSizesInEachMap) {
« 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