8#ifndef INCLUDED_BSLIM_FUZZUTIL
9#define INCLUDED_BSLIM_FUZZUTIL
122#include <bslscm_version.h>
132#include <bsl_cmath.h>
133#include <bsl_cstdint.h>
134#include <bsl_limits.h>
135#include <bsl_string.h>
136#include <bsl_type_traits.h>
137#include <bsl_vector.h>
161 template <
class TYPE>
176 template <
class TYPE>
191 template <
class TYPE>
197 template <
class TYPE>
204 bsl::size_t maxLength);
207 bsl::size_t maxLength);
208#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_PMR
211 bsl::size_t maxLength);
228 bsl::size_t maxLength);
231 bsl::size_t maxLength);
232#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_PMR_STRING
235 bsl::size_t maxLength);
261 return 1 & consumeNumber<bsl::uint8_t>(fuzzDataView);
269 bsl::numeric_limits<TYPE>::min(),
270 bsl::numeric_limits<TYPE>::max());
279 -bsl::numeric_limits<TYPE>::max(),
280 bsl::numeric_limits<TYPE>::max());
297 rangeCpy >>= 8, ++numBytes) {
304 for (
const bsl::uint8_t *it = prefix.
begin(); it != prefix.
end(); it++) {
305 addend = (addend << 8) | *it;
308 if (bsl::numeric_limits<bsls::Types::Uint64>::max() != range) {
309 addend %= (range + 1);
312 return static_cast<TYPE
>(min + addend);
325 BSLS_ASSERT(bsl::numeric_limits<TYPE>::infinity() != max &&
326 -bsl::numeric_limits<TYPE>::infinity() != min);
330 const TYPE k_HALF = 0.5;
332 if (max > min + bsl::numeric_limits<TYPE>::max()) {
333 range = max * k_HALF - min * k_HALF;
335 addend = min + range;
347 static_cast<TYPE
>(consumeNumber<IntegralType>(fuzzDataView)) /
349 bsl::numeric_limits<IntegralType>::max());
351 return addend + range * factor;
Definition bslstl_string.h:1281
Definition bslstl_vector.h:1025
Definition bslim_fuzzdataview.h:130
const bsl::uint8_t * end() const
Return a const pointer to the end of the buffer.
Definition bslim_fuzzdataview.h:234
const bsl::uint8_t * begin() const
Return a const pointer to the beginning of the buffer.
Definition bslim_fuzzdataview.h:228
FuzzDataView removePrefix(bsl::size_t numBytes)
Definition bslim_fuzzdataview.h:205
#define BSLMF_ASSERT(expr)
Definition bslmf_assert.h:229
#define BSLS_ASSERT(X)
Definition bsls_assert.h:1804
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
Definition bslim_formatguard.h:120
Definition bslmf_conditional.h:120
Definition bslmf_enableif.h:525
Definition bslmf_isintegral.h:130
Definition bslmf_issame.h:146
Definition bslim_fuzzutil.h:152
static void consumeRandomLengthChars(bsl::vector< char > *output, FuzzDataView *fuzzDataView, bsl::size_t maxLength)
static void consumeRandomLengthString(std::string *output, FuzzDataView *fuzzDataView, bsl::size_t maxLength)
static bool consumeBool(FuzzDataView *fuzzDataView)
Definition bslim_fuzzutil.h:259
static bsl::enable_if< bsl::is_integral< TYPE >::value, TYPE >::type consumeNumber(FuzzDataView *fuzzDataView)
Definition bslim_fuzzutil.h:266
static bsl::enable_if< bsl::is_integral< TYPE >::value, TYPE >::type consumeNumberInRange(FuzzDataView *fuzzDataView, TYPE min, TYPE max)
Definition bslim_fuzzutil.h:285
static void consumeRandomLengthChars(std::vector< char > *output, FuzzDataView *fuzzDataView, bsl::size_t maxLength)
static void consumeRandomLengthString(bsl::string *output, FuzzDataView *fuzzDataView, bsl::size_t maxLength)
static bsl::enable_if< bsl::is_floating_point< TYPE >::value, TYPE >::type consumeNumberInRange(FuzzDataView *fuzzDataView, TYPE min, TYPE max)
static bsl::enable_if< bsl::is_floating_point< TYPE >::value, TYPE >::type consumeNumber(FuzzDataView *fuzzDataView)
unsigned long long Uint64
Definition bsls_types.h:137