BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bdlt_fuzzutil

Detailed Description

Outline

Purpose

Provide creation of bdlt data types from fuzz data.

Classes

See also
bslim_fuzzdataview, bslim_fuzzutil

Description

This component defines a struct, bdlt::FuzzUtil, which serves as a namespace for functions to create bdlt data types from supplied fuzz input data.

Usage

This section illustrates intended use of this component.

Example 1: Provide bdlt::Datetime within a Range

The provided fuzz data is here represented by an array of bytes:

const uint8_t data[] = {0x8A, 0x19, 0x0D, 0x44, 0x37, 0x0D,
0x38, 0x5E, 0x9B, 0xAA, 0xF3, 0xDA};

First, we default construct a bslim::FuzzDataView object, fdv:

bslim::FuzzDataView fdv(data, sizeof(data));
assert(12 == fdv.length());
Definition bslim_fuzzdataview.h:130

Next, we construct Date objects to represent the begin and end of the time interval in which we wish to construct our new Date from the fuzz data:

bdlt::Date begin(1833, 5, 7);
bdlt::Date end(1897, 4, 3);
Definition bdlt_date.h:294

Finally, we create a Date object, within, by employing bdlt_fuzzutil :

assert(begin <= within);
assert(within <= end);
static bdlt::Date consumeDateInRange(bslim::FuzzDataView *fuzzDataView, const bdlt::Date &begin, const bdlt::Date &end)
Definition bdlt_fuzzutil.h:164