text stringlengths 0 2.2M |
|---|
//:
|
//: 2 Apply the (fully-tested) 'generateRaw' functions to each element
|
//: in the cross product, 'D x Z x C', of the test data from P-1.
|
//:
|
//: 3 Invoke the 'parse' functions on the strings generated in P-2 and
|
//: verify that parsing succeeds, i.e., that 0 is returned and the
|
//: result objects have the expected values. (C-1..5)
|
//:
|
//: 4 Using the table-driven technique, specify a set of distinct
|
//: strings that are not ISO 8601 representations supported by this
|
//: component for 'Date' and 'DateTz' values.
|
//:
|
//: 5 Invoke the 'parse' functions on the strings from P-4 and verify
|
//: that parsing fails, i.e., that a non-zero value is returned and
|
//: the result objects are unchanged. (C-6..8)
|
//:
|
//: 6 Verify that, in appropriate build modes, defensive checks are
|
//: triggered for invalid arguments, but not triggered for adjacent
|
//: valid ones (using the 'BSLS_ASSERTTEST_*' macros). (C-9)
|
//
|
// Testing:
|
// int parse(Date *, const char *, int);
|
// int parse(DateTz *, const char *, int);
|
// int parse(Date *result, const StringRef& string);
|
// int parse(DateTz *result, const StringRef& string);
|
// --------------------------------------------------------------------
|
if (verbose) cout << endl
|
<< "PARSE: DATE & DATETZ" << endl
|
<< "====================" << endl;
|
char buffer[Util::k_MAX_STRLEN];
|
const bdlt::Date XX(246, 8, 10); // 'XX' and 'ZZ' are controls,
|
const bdlt::DateTz ZZ(XX, -7); // distinct from any test data
|
const int NUM_DATE_DATA = NUM_DEFAULT_DATE_DATA;
|
const DefaultDateDataRow (&DATE_DATA)[NUM_DATE_DATA] =
|
DEFAULT_DATE_DATA;
|
const int NUM_ZONE_DATA = NUM_DEFAULT_ZONE_DATA;
|
const DefaultZoneDataRow (&ZONE_DATA)[NUM_ZONE_DATA] =
|
DEFAULT_ZONE_DATA;
|
const int NUM_CNFG_DATA = NUM_DEFAULT_CNFG_DATA;
|
const DefaultCnfgDataRow (&CNFG_DATA)[NUM_CNFG_DATA] =
|
DEFAULT_CNFG_DATA;
|
if (verbose) cout << "\nValid ISO 8601 strings." << endl;
|
for (int ti = 0; ti < NUM_DATE_DATA; ++ti) {
|
const int ILINE = DATE_DATA[ti].d_line;
|
const int YEAR = DATE_DATA[ti].d_year;
|
const int MONTH = DATE_DATA[ti].d_month;
|
const int DAY = DATE_DATA[ti].d_day;
|
const bdlt::Date DATE(YEAR, MONTH, DAY);
|
for (int tj = 0; tj < NUM_ZONE_DATA; ++tj) {
|
const int JLINE = ZONE_DATA[tj].d_line;
|
const int OFFSET = ZONE_DATA[tj].d_offset;
|
const bdlt::DateTz DATETZ(DATE, OFFSET);
|
if (veryVerbose) { T_ P_(ILINE) P_(JLINE) P_(DATE) P(DATETZ) }
|
for (int tc = 0; tc < NUM_CNFG_DATA; ++tc) {
|
const int CLINE = CNFG_DATA[tc].d_line;
|
const bool OMITCOLON = CNFG_DATA[tc].d_omitColon;
|
const int PRECISION = CNFG_DATA[tc].d_precision;
|
const bool USECOMMA = CNFG_DATA[tc].d_useComma;
|
const bool USEZ = CNFG_DATA[tc].d_useZ;
|
if (veryVerbose) {
|
T_ P_(CLINE) P_(OMITCOLON) P_(PRECISION)
|
P_(USECOMMA) P(USEZ)
|
}
|
Config mC; const Config& C = mC;
|
gg(&mC, PRECISION, OMITCOLON, USECOMMA, USEZ);
|
// without zone designator in parsed string
|
{
|
const int LENGTH = Util::generateRaw(buffer, DATE, C);
|
if (veryVerbose) {
|
const bsl::string STRING(buffer, LENGTH);
|
T_ T_ P(STRING)
|
}
|
bdlt::Date mX(XX); const bdlt::Date& X = mX;
|
bdlt::DateTz mZ(ZZ); const bdlt::DateTz& Z = mZ;
|
ASSERTV(ILINE, JLINE, CLINE,
|
0 == Util::parse(&mX, buffer, LENGTH));
|
ASSERTV(ILINE, JLINE, CLINE, DATE == X);
|
ASSERTV(ILINE, JLINE, CLINE,
|
0 == Util::parse(&mZ, buffer, LENGTH));
|
ASSERTV(ILINE, JLINE, CLINE, DATE == Z.localDate());
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.