OLD | NEW |
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 #ifndef FuzzedDataProvider_h | 5 #ifndef FuzzedDataProvider_h |
6 #define FuzzedDataProvider_h | 6 #define FuzzedDataProvider_h |
7 | 7 |
8 #include "base/test/fuzzed_data_provider.h" | 8 #include "base/test/fuzzed_data_provider.h" |
9 #include "wtf/Noncopyable.h" | 9 #include "wtf/Noncopyable.h" |
10 #include "wtf/text/CString.h" | 10 #include "wtf/text/CString.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 // length is greater than the length of the remaining data this is | 23 // length is greater than the length of the remaining data this is |
24 // equivalent to ConsumeRemainingBytes(). | 24 // equivalent to ConsumeRemainingBytes(). |
25 CString ConsumeBytesInRange(uint32_t minBytes, uint32_t maxBytes); | 25 CString ConsumeBytesInRange(uint32_t minBytes, uint32_t maxBytes); |
26 | 26 |
27 // Returns a String containing all remaining bytes of the input data. | 27 // Returns a String containing all remaining bytes of the input data. |
28 CString ConsumeRemainingBytes(); | 28 CString ConsumeRemainingBytes(); |
29 | 29 |
30 // Returns a bool, or false when no data remains. | 30 // Returns a bool, or false when no data remains. |
31 bool ConsumeBool(); | 31 bool ConsumeBool(); |
32 | 32 |
| 33 // Returns a value from |array|, consuming as many bytes as needed to do so. |
| 34 // |array| must be a fixed-size array. |
| 35 template <typename Type, size_t size> |
| 36 Type PickValueInArray(Type (&array)[size]) { |
| 37 return array[m_provider.ConsumeUint32InRange(0, size - 1)]; |
| 38 } |
| 39 |
33 private: | 40 private: |
34 base::FuzzedDataProvider m_provider; | 41 base::FuzzedDataProvider m_provider; |
35 }; | 42 }; |
36 | 43 |
37 } // namespace blink | 44 } // namespace blink |
38 | 45 |
39 #endif // FuzzedDataProvider_h | 46 #endif // FuzzedDataProvider_h |
OLD | NEW |