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

Unified Diff: chrome/browser/safe_browsing/prefix_set_unittest.cc

Issue 99883003: Explicit PrefixSet test prefix distribution. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/safe_browsing/prefix_set_unittest.cc
diff --git a/chrome/browser/safe_browsing/prefix_set_unittest.cc b/chrome/browser/safe_browsing/prefix_set_unittest.cc
index 7f78a6af975081f161705f7607be6cc938f91bd4..c76447af8ef68b68cdc900bd5f9b58eb4e1192ac 100644
--- a/chrome/browser/safe_browsing/prefix_set_unittest.cc
+++ b/chrome/browser/safe_browsing/prefix_set_unittest.cc
@@ -29,8 +29,25 @@ class PrefixSetTest : public PlatformTest {
// Generate a set of random prefixes to share between tests. For
// most tests this generation was a large fraction of the test time.
+ //
+ // The set should contain sparse areas where adjacent items are more
+ // than 2^16 apart, and dense areas where adjacent items are less
+ // than 2^16 apart.
static void SetUpTestCase() {
- for (size_t i = 0; i < 50000; ++i) {
+ // Distribute clusters of prefixes.
+ for (size_t i = 0; i < 250; ++i) {
+ // Unsigned for overflow characteristics.
+ const uint32 base = static_cast<uint32>(base::RandUint64());
+ for (size_t j = 0; j < 10; ++j) {
+ const uint32 delta = static_cast<uint32>(base::RandUint64() & 0xFFFF);
+ const SBPrefix prefix = static_cast<SBPrefix>(base + delta);
+ shared_prefixes_.push_back(prefix);
+ }
+ }
+
+ // Lay down a sparsely-distributed layer.
+ const size_t count = shared_prefixes_.size();
+ for (size_t i = 0; i < count; ++i) {
const SBPrefix prefix = static_cast<SBPrefix>(base::RandUint64());
shared_prefixes_.push_back(prefix);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698