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

Side by Side Diff: chrome/common/safe_browsing/binary_feature_extractor_unittest.cc

Issue 1880143002: Convert chrome/common to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 8 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/common/safe_browsing/binary_feature_extractor.h" 5 #include "chrome/common/safe_browsing/binary_feature_extractor.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include <memory>
11
10 #include "base/base_paths.h" 12 #include "base/base_paths.h"
11 #include "base/files/file.h" 13 #include "base/files/file.h"
12 #include "base/files/scoped_temp_dir.h" 14 #include "base/files/scoped_temp_dir.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/path_service.h" 15 #include "base/path_service.h"
15 #include "chrome/common/safe_browsing/csd.pb.h" 16 #include "chrome/common/safe_browsing/csd.pb.h"
16 #include "crypto/sha2.h" 17 #include "crypto/sha2.h"
17 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
18 19
19 namespace safe_browsing { 20 namespace safe_browsing {
20 21
21 class BinaryFeatureExtractorTest : public testing::Test { 22 class BinaryFeatureExtractorTest : public testing::Test {
22 protected: 23 protected:
23 BinaryFeatureExtractorTest() : extractor_(new BinaryFeatureExtractor()) {} 24 BinaryFeatureExtractorTest() : extractor_(new BinaryFeatureExtractor()) {}
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 } 76 }
76 77
77 // Hash a file that is exactly 1 4k block. 78 // Hash a file that is exactly 1 4k block.
78 TEST_F(BinaryFeatureExtractorTest, ExtractOneBlockDigest) { 79 TEST_F(BinaryFeatureExtractorTest, ExtractOneBlockDigest) {
79 static const uint8_t kDigest[] = { 80 static const uint8_t kDigest[] = {
80 0x4f, 0x93, 0x6e, 0xee, 0x89, 0x55, 0xa5, 0xe7, 0x46, 0xd0, 0x61, 81 0x4f, 0x93, 0x6e, 0xee, 0x89, 0x55, 0xa5, 0xe7, 0x46, 0xd0, 0x61,
81 0x43, 0x54, 0x5f, 0x33, 0x7b, 0xdc, 0x30, 0x3a, 0x4b, 0x18, 0xb4, 82 0x43, 0x54, 0x5f, 0x33, 0x7b, 0xdc, 0x30, 0x3a, 0x4b, 0x18, 0xb4,
82 0x82, 0x20, 0xe3, 0x93, 0x4c, 0x65, 0xe0, 0xc1, 0xc0, 0x19}; 83 0x82, 0x20, 0xe3, 0x93, 0x4c, 0x65, 0xe0, 0xc1, 0xc0, 0x19};
83 84
84 const int kDataLen = kBlockSize; 85 const int kDataLen = kBlockSize;
85 scoped_ptr<char[]> data(new char[kDataLen]); 86 std::unique_ptr<char[]> data(new char[kDataLen]);
86 memset(data.get(), 71, kDataLen); 87 memset(data.get(), 71, kDataLen);
87 WriteFileToHash(data.get(), kDataLen); 88 WriteFileToHash(data.get(), kDataLen);
88 ExpectFileDigestEq(kDigest); 89 ExpectFileDigestEq(kDigest);
89 } 90 }
90 91
91 // Hash a file that is larger than 1 4k block. 92 // Hash a file that is larger than 1 4k block.
92 TEST_F(BinaryFeatureExtractorTest, ExtractBigBlockDigest) { 93 TEST_F(BinaryFeatureExtractorTest, ExtractBigBlockDigest) {
93 static const uint8_t kDigest[] = { 94 static const uint8_t kDigest[] = {
94 0xda, 0xae, 0xa0, 0xd5, 0x3b, 0xce, 0x0b, 0x4e, 0x5f, 0x5d, 0x0b, 95 0xda, 0xae, 0xa0, 0xd5, 0x3b, 0xce, 0x0b, 0x4e, 0x5f, 0x5d, 0x0b,
95 0xc7, 0x6a, 0x69, 0x0e, 0xf1, 0x8b, 0x2d, 0x20, 0xcd, 0xf2, 0x6d, 96 0xc7, 0x6a, 0x69, 0x0e, 0xf1, 0x8b, 0x2d, 0x20, 0xcd, 0xf2, 0x6d,
96 0x33, 0xa7, 0x70, 0xf3, 0x6b, 0x85, 0xbf, 0xce, 0x9d, 0x5c}; 97 0x33, 0xa7, 0x70, 0xf3, 0x6b, 0x85, 0xbf, 0xce, 0x9d, 0x5c};
97 98
98 const int kDataLen = kBlockSize + 1; 99 const int kDataLen = kBlockSize + 1;
99 scoped_ptr<char[]> data(new char[kDataLen]); 100 std::unique_ptr<char[]> data(new char[kDataLen]);
100 memset(data.get(), 71, kDataLen); 101 memset(data.get(), 71, kDataLen);
101 WriteFileToHash(data.get(), kDataLen); 102 WriteFileToHash(data.get(), kDataLen);
102 ExpectFileDigestEq(kDigest); 103 ExpectFileDigestEq(kDigest);
103 } 104 }
104 105
105 } // namespace safe_browsing 106 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « chrome/common/safe_browsing/binary_feature_extractor.cc ('k') | chrome/common/safe_browsing/mach_o_image_reader_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698