Quick Links:

bal | bbl | bdl | bsl

Namespaces

Component bdlt_fuzzutil
[Package bdlt]

Provide creation of bdlt data types from fuzz data. More...

Namespaces

namespace  bdlt

Detailed Description

Outline
Purpose:
Provide creation of bdlt data types from fuzz data.
Classes:
bdlt::FuzzUtil functions to create bdlt data types from fuzz data
See also:
Component bslim_fuzzdataview, Component 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());
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);
Finally, we create a Date object, within, by employing bdlt_fuzzutil:
  bdlt::Date within = bdlt::FuzzUtil::consumeDateInRange(&fdv, begin, end);

  assert(begin  <= within);
  assert(within <= end);