| OLD | NEW | 
|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #include "chrome/browser/safe_browsing/prefix_set.h" | 5 #include "chrome/browser/safe_browsing/prefix_set.h" | 
| 6 | 6 | 
| 7 #include <algorithm> | 7 #include <algorithm> | 
| 8 | 8 | 
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" | 
| 10 #include "base/logging.h" | 10 #include "base/logging.h" | 
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 425   // Add some junk to the trunk. | 425   // Add some junk to the trunk. | 
| 426   file_util::ScopedFILE file(file_util::OpenFile(filename, "ab")); | 426   file_util::ScopedFILE file(file_util::OpenFile(filename, "ab")); | 
| 427   const char buf[] = "im in ur base, killing ur d00dz."; | 427   const char buf[] = "im in ur base, killing ur d00dz."; | 
| 428   ASSERT_EQ(strlen(buf), fwrite(buf, 1, strlen(buf), file.get())); | 428   ASSERT_EQ(strlen(buf), fwrite(buf, 1, strlen(buf), file.get())); | 
| 429   file.reset(); | 429   file.reset(); | 
| 430   scoped_ptr<safe_browsing::PrefixSet> | 430   scoped_ptr<safe_browsing::PrefixSet> | 
| 431       prefix_set(safe_browsing::PrefixSet::LoadFile(filename)); | 431       prefix_set(safe_browsing::PrefixSet::LoadFile(filename)); | 
| 432   ASSERT_FALSE(prefix_set.get()); | 432   ASSERT_FALSE(prefix_set.get()); | 
| 433 } | 433 } | 
| 434 | 434 | 
|  | 435 // TODO(shess): Remove once the problem is debugged.  But, until then, | 
|  | 436 // make sure the accessors work! | 
|  | 437 TEST_F(PrefixSetTest, DebuggingAccessors) { | 
|  | 438   std::vector<SBPrefix> prefixes; | 
|  | 439   std::unique_copy(shared_prefixes_.begin(), shared_prefixes_.end(), | 
|  | 440                    std::back_inserter(prefixes)); | 
|  | 441   safe_browsing::PrefixSet prefix_set(prefixes); | 
|  | 442 | 
|  | 443   EXPECT_EQ(prefixes.size(), prefix_set.GetSize()); | 
|  | 444   EXPECT_FALSE(prefix_set.IsDeltaAt(0)); | 
|  | 445   for (size_t i = 1; i < prefixes.size(); ++i) { | 
|  | 446     const int delta = prefixes[i] - prefixes[i - 1]; | 
|  | 447     if (delta > 0xFFFF) { | 
|  | 448       EXPECT_FALSE(prefix_set.IsDeltaAt(i)); | 
|  | 449     } else { | 
|  | 450       ASSERT_TRUE(prefix_set.IsDeltaAt(i)); | 
|  | 451       EXPECT_EQ(delta, prefix_set.DeltaAt(i)); | 
|  | 452     } | 
|  | 453   } | 
|  | 454 } | 
|  | 455 | 
| 435 }  // namespace | 456 }  // namespace | 
| OLD | NEW | 
|---|