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

Side by Side Diff: third_party/WebKit/Source/platform/testing/FuzzedDataProvider.cpp

Issue 2308443002: Make FuzzedDataProvider vend std::strings (Closed)
Patch Set: thestig review Created 4 years, 2 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 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 "platform/testing/FuzzedDataProvider.h" 5 #include "platform/testing/FuzzedDataProvider.h"
6 6
7 namespace blink { 7 namespace blink {
8 8
9 FuzzedDataProvider::FuzzedDataProvider(const uint8_t* bytes, size_t numBytes) 9 FuzzedDataProvider::FuzzedDataProvider(const uint8_t* bytes, size_t numBytes)
10 : m_provider(bytes, numBytes) {} 10 : m_provider(bytes, numBytes) {}
11 11
12 CString FuzzedDataProvider::ConsumeBytesInRange(uint32_t minBytes, 12 CString FuzzedDataProvider::ConsumeBytesInRange(uint32_t minBytes,
13 uint32_t maxBytes) { 13 uint32_t maxBytes) {
14 size_t numBytes = 14 size_t numBytes =
15 static_cast<size_t>(m_provider.ConsumeUint32InRange(minBytes, maxBytes)); 15 static_cast<size_t>(m_provider.ConsumeUint32InRange(minBytes, maxBytes));
16 base::StringPiece bytes = m_provider.ConsumeBytes(numBytes); 16 std::string bytes = m_provider.ConsumeBytes(numBytes);
17 return CString(bytes.data(), bytes.length()); 17 return CString(bytes.data(), bytes.size());
18 } 18 }
19 19
20 CString FuzzedDataProvider::ConsumeRemainingBytes() { 20 CString FuzzedDataProvider::ConsumeRemainingBytes() {
21 base::StringPiece bytes = m_provider.ConsumeRemainingBytes(); 21 std::string bytes = m_provider.ConsumeRemainingBytes();
22 return CString(bytes.data(), bytes.length()); 22 return CString(bytes.data(), bytes.size());
23 } 23 }
24 24
25 bool FuzzedDataProvider::ConsumeBool() { 25 bool FuzzedDataProvider::ConsumeBool() {
26 return m_provider.ConsumeBool(); 26 return m_provider.ConsumeBool();
27 } 27 }
28 28
29 } // namespace blink 29 } // namespace blink
OLDNEW
« no previous file with comments | « net/websockets/websocket_frame_parser_fuzzer.cc ('k') | third_party/sfntly/fuzzers/subset_font_fuzzer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698