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

Side by Side Diff: components/safe_browsing_db/v4_store_unittest.cc

Issue 2228393003: PVer4: DecodeHashes needs to sort the output of the Rice decoder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@01_checksum
Patch Set: DecodeBytes->DecodePrefixes. More detailed comment. Created 4 years, 4 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 unified diff | Download patch
« no previous file with comments | « components/safe_browsing_db/v4_store.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/files/file_util.h" 6 #include "base/files/file_util.h"
7 #include "base/files/scoped_temp_dir.h" 7 #include "base/files/scoped_temp_dir.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/test/test_simple_task_runner.h" 10 #include "base/test/test_simple_task_runner.h"
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 // The following value is hand-crafted by getting inspiration from: 724 // The following value is hand-crafted by getting inspiration from:
725 // https://goto.google.com/testlargenumbersriceencoded 725 // https://goto.google.com/testlargenumbersriceencoded
726 // The value listed at that place fails the "integer overflow" check so I 726 // The value listed at that place fails the "integer overflow" check so I
727 // modified it until the decoder parsed it successfully. 727 // modified it until the decoder parsed it successfully.
728 rice_hashes->set_encoded_data( 728 rice_hashes->set_encoded_data(
729 "\xbf\xa8\x3f\xfb\xf\xf\x5e\x27\xe6\xc3\x1d\xc6\x38"); 729 "\xbf\xa8\x3f\xfb\xf\xf\x5e\x27\xe6\xc3\x1d\xc6\x38");
730 HashPrefixMap additions_map; 730 HashPrefixMap additions_map;
731 EXPECT_EQ(APPLY_UPDATE_SUCCESS, V4Store::UpdateHashPrefixMapFromAdditions( 731 EXPECT_EQ(APPLY_UPDATE_SUCCESS, V4Store::UpdateHashPrefixMapFromAdditions(
732 additions, &additions_map)); 732 additions, &additions_map));
733 EXPECT_EQ(1u, additions_map.size()); 733 EXPECT_EQ(1u, additions_map.size());
734 EXPECT_EQ(std::string("\x5\0\0\0V\x7F\xF6o\xCEo1\x81\fL\x93\xAD", 16), 734 EXPECT_EQ(std::string("\x5\0\0\0\fL\x93\xADV\x7F\xF6o\xCEo1\x81", 16),
735 additions_map[4]); 735 additions_map[4]);
736 } 736 }
737 737
738 TEST_F(V4StoreTest, TestRemovalsWithRiceEncodingSucceeds) { 738 TEST_F(V4StoreTest, TestRemovalsWithRiceEncodingSucceeds) {
739 HashPrefixMap prefix_map_old; 739 HashPrefixMap prefix_map_old;
740 EXPECT_EQ(APPLY_UPDATE_SUCCESS, 740 EXPECT_EQ(APPLY_UPDATE_SUCCESS,
741 V4Store::AddUnlumpedHashes(4, "1111abcdefgh", &prefix_map_old)); 741 V4Store::AddUnlumpedHashes(4, "1111abcdefgh", &prefix_map_old));
742 HashPrefixMap prefix_map_additions; 742 HashPrefixMap prefix_map_additions;
743 EXPECT_EQ(APPLY_UPDATE_SUCCESS, 743 EXPECT_EQ(APPLY_UPDATE_SUCCESS,
744 V4Store::AddUnlumpedHashes(5, "22222bcdef", &prefix_map_additions)); 744 V4Store::AddUnlumpedHashes(5, "22222bcdef", &prefix_map_additions));
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 792
793 HashPrefixMap prefix_map_old; 793 HashPrefixMap prefix_map_old;
794 EXPECT_EQ(APPLY_UPDATE_SUCCESS, 794 EXPECT_EQ(APPLY_UPDATE_SUCCESS,
795 V4Store::AddUnlumpedHashes(4, "2222", &prefix_map_old)); 795 V4Store::AddUnlumpedHashes(4, "2222", &prefix_map_old));
796 EXPECT_EQ(CHECKSUM_MISMATCH_FAILURE, 796 EXPECT_EQ(CHECKSUM_MISMATCH_FAILURE,
797 V4Store(task_runner_, store_path_) 797 V4Store(task_runner_, store_path_)
798 .MergeUpdate(prefix_map_old, HashPrefixMap(), nullptr, "aawc")); 798 .MergeUpdate(prefix_map_old, HashPrefixMap(), nullptr, "aawc"));
799 } 799 }
800 800
801 } // namespace safe_browsing 801 } // namespace safe_browsing
OLDNEW
« 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