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 BASE_TEST_FUZZED_DATA_PROVIDER_H_ | 5 #ifndef BASE_TEST_FUZZED_DATA_PROVIDER_H_ |
6 #define BASE_TEST_FUZZED_DATA_PROVIDER_H_ | 6 #define BASE_TEST_FUZZED_DATA_PROVIDER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 15 matching lines...) Expand all Loading... | |
26 ~FuzzedDataProvider(); | 26 ~FuzzedDataProvider(); |
27 | 27 |
28 // Returns a std::string containing |num_bytes| of input data. If fewer than | 28 // Returns a std::string containing |num_bytes| of input data. If fewer than |
29 // |num_bytes| of data remain, returns a shorter std::string containing all | 29 // |num_bytes| of data remain, returns a shorter std::string containing all |
30 // of the data that's left. | 30 // of the data that's left. |
31 std::string ConsumeBytes(size_t num_bytes); | 31 std::string ConsumeBytes(size_t num_bytes); |
32 | 32 |
33 // Returns a std::string containing all remaining bytes of the input data. | 33 // Returns a std::string containing all remaining bytes of the input data. |
34 std::string ConsumeRemainingBytes(); | 34 std::string ConsumeRemainingBytes(); |
35 | 35 |
36 // Returns a std::string of length from 0 to |max_length|. When it runs out of | |
37 // input data, returns what remains of the input. Designed to be more stable w ith respect to inserting characters than picking a random length and then consum ing that many bytes with ConsumeBytes(). | |
Charlie Harrison
2016/11/01 19:02:05
wrap to 80 cols.
mmenke
2016/11/01 19:14:29
Done. Oops. Had to bypass the whine due to CR's
| |
38 std::string ConsumeRandomLengthString(size_t max_length); | |
Charlie Harrison
2016/11/01 19:02:05
Can you document that this looks for the magic str
mmenke
2016/11/01 19:14:29
I don't think it's useful to consumers unless we d
| |
39 | |
36 // Returns a number in the range [min, max] by consuming bytes from the input | 40 // Returns a number in the range [min, max] by consuming bytes from the input |
37 // data. The value might not be uniformly distributed in the given range. If | 41 // data. The value might not be uniformly distributed in the given range. If |
38 // there's no input data left, always returns |min|. |min| must be less than | 42 // there's no input data left, always returns |min|. |min| must be less than |
39 // or equal to |max|. | 43 // or equal to |max|. |
40 uint32_t ConsumeUint32InRange(uint32_t min, uint32_t max); | 44 uint32_t ConsumeUint32InRange(uint32_t min, uint32_t max); |
41 int ConsumeInt32InRange(int min, int max); | 45 int ConsumeInt32InRange(int min, int max); |
42 | 46 |
43 // Returns a bool, or false when no data remains. | 47 // Returns a bool, or false when no data remains. |
44 bool ConsumeBool(); | 48 bool ConsumeBool(); |
45 | 49 |
(...skipping 19 matching lines...) Expand all Loading... | |
65 | 69 |
66 private: | 70 private: |
67 StringPiece remaining_data_; | 71 StringPiece remaining_data_; |
68 | 72 |
69 DISALLOW_COPY_AND_ASSIGN(FuzzedDataProvider); | 73 DISALLOW_COPY_AND_ASSIGN(FuzzedDataProvider); |
70 }; | 74 }; |
71 | 75 |
72 } // namespace base | 76 } // namespace base |
73 | 77 |
74 #endif // BASE_TEST_FUZZED_DATA_PROVIDER_H_ | 78 #endif // BASE_TEST_FUZZED_DATA_PROVIDER_H_ |
OLD | NEW |