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

Side by Side Diff: components/webcrypto/algorithms/sha_unittest.cc

Issue 1461703009: Switch //components from vector_as_array to vector::data. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: eroman comment Created 5 years, 1 month 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/webcrypto/algorithms/sha.cc ('k') | components/webcrypto/algorithms/test_helpers.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/logging.h" 5 #include "base/logging.h"
6 #include "base/stl_util.h"
7 #include "base/values.h" 6 #include "base/values.h"
8 #include "components/webcrypto/algorithm_dispatch.h" 7 #include "components/webcrypto/algorithm_dispatch.h"
9 #include "components/webcrypto/algorithms/test_helpers.h" 8 #include "components/webcrypto/algorithms/test_helpers.h"
10 #include "components/webcrypto/crypto_data.h" 9 #include "components/webcrypto/crypto_data.h"
11 #include "components/webcrypto/status.h" 10 #include "components/webcrypto/status.h"
12 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
13 #include "third_party/WebKit/public/platform/WebCryptoAlgorithmParams.h" 12 #include "third_party/WebKit/public/platform/WebCryptoAlgorithmParams.h"
14 #include "third_party/WebKit/public/platform/WebCryptoKey.h" 13 #include "third_party/WebKit/public/platform/WebCryptoKey.h"
15 #include "third_party/WebKit/public/platform/WebCryptoKeyAlgorithm.h" 14 #include "third_party/WebKit/public/platform/WebCryptoKeyAlgorithm.h"
16 15
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 static const size_t kChunkSizeBytes = 129; 61 static const size_t kChunkSizeBytes = 129;
63 size_t length = test_input.size(); 62 size_t length = test_input.size();
64 scoped_ptr<blink::WebCryptoDigestor> digestor( 63 scoped_ptr<blink::WebCryptoDigestor> digestor(
65 CreateDigestor(test_algorithm.id())); 64 CreateDigestor(test_algorithm.id()));
66 std::vector<uint8_t>::iterator begin = test_input.begin(); 65 std::vector<uint8_t>::iterator begin = test_input.begin();
67 size_t chunk_index = 0; 66 size_t chunk_index = 0;
68 while (begin != test_input.end()) { 67 while (begin != test_input.end()) {
69 size_t chunk_length = std::min(kChunkSizeBytes, length - chunk_index); 68 size_t chunk_length = std::min(kChunkSizeBytes, length - chunk_index);
70 std::vector<uint8_t> chunk(begin, begin + chunk_length); 69 std::vector<uint8_t> chunk(begin, begin + chunk_length);
71 ASSERT_TRUE(chunk.size() > 0); 70 ASSERT_TRUE(chunk.size() > 0);
72 EXPECT_TRUE(digestor->consume(vector_as_array(&chunk), 71 EXPECT_TRUE(digestor->consume(chunk.data(),
73 static_cast<unsigned int>(chunk.size()))); 72 static_cast<unsigned int>(chunk.size())));
74 chunk_index = chunk_index + chunk_length; 73 chunk_index = chunk_index + chunk_length;
75 begin = begin + chunk_length; 74 begin = begin + chunk_length;
76 } 75 }
77 EXPECT_TRUE(digestor->finish(output, output_length)); 76 EXPECT_TRUE(digestor->finish(output, output_length));
78 EXPECT_BYTES_EQ(test_output, CryptoData(output, output_length)); 77 EXPECT_BYTES_EQ(test_output, CryptoData(output, output_length));
79 } 78 }
80 } 79 }
81 80
82 } // namespace 81 } // namespace
83 82
84 } // namespace webcrypto 83 } // namespace webcrypto
OLDNEW
« no previous file with comments | « components/webcrypto/algorithms/sha.cc ('k') | components/webcrypto/algorithms/test_helpers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698