text stringlengths 0 2.2M |
|---|
ASSERT(BUFLEN - 9 == rc);
|
ASSERT( 0 == bsl::strcmp(buffer, "08:59:59+0400"));
|
//..
|
} break;
|
case 11: {
|
// --------------------------------------------------------------------
|
// PARSE: DATETIME & DATETIMETZ
|
//
|
// Concerns:
|
//: 1 All ISO 8601 string representations supported by this component
|
//: (as documented in the header file) for 'Datetime' and
|
//: 'DatetimeTz' values are parsed successfully.
|
//:
|
//: 2 If parsing succeeds, the result 'Datetime' or 'DatetimeTz' object
|
//: has the expected value.
|
//:
|
//: 3 If the optional zone designator is present in the input string
|
//: when parsing into a 'Datetime' object, the resulting value is
|
//: converted to the equivalent UTC datetime.
|
//:
|
//: 4 If the optional zone designator is *not* present in the input
|
//: string when parsing into a 'DatetimeTz' object, it is assumed to
|
//: be UTC.
|
//:
|
//: 5 If parsing succeeds, 0 is returned.
|
//:
|
//: 6 All strings that are not ISO 8601 representations supported by
|
//: this component for 'Datetime' and 'DatetimeTz' values are
|
//: rejected (i.e., parsing fails).
|
//:
|
//: 7 If parsing fails, the result object is unaffected and a non-zero
|
//: value is returned.
|
//:
|
//: 8 The entire extent of the input string is parsed.
|
//:
|
//: 9 Leap seconds, fractional seconds containing more than three
|
//: digits, and extremal values (those that can overflow a
|
//: 'Datetime') are handled correctly.
|
//:
|
//:10 QoI: Asserted precondition violations are detected when enabled.
|
//
|
// Plan:
|
//: 1 Using the table-driven technique, specify a set of distinct
|
//: 'Date' values ('D'), 'Time' values ('T'), zone designators ('Z'),
|
//: and configurations ('C').
|
//:
|
//: 2 Apply the (fully-tested) 'generateRaw' functions to each element
|
//: in the cross product, 'D x T 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 'Datetime' and 'DatetimeTz' 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 Using the table-driven technique, specify a set of distinct ISO
|
//: 8601 strings that specifically cover cases involving leap
|
//: seconds, fractional seconds containing more than three digits,
|
//: and extremal values.
|
//:
|
//: 7 Invoke the 'parse' functions on the strings from P-6 and verify
|
//: the results are as expected. (C-9)
|
//:
|
//: 8 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-10)
|
//
|
// Testing:
|
// int parse(Datetime *, const char *, int);
|
// int parse(DatetimeTz *, const char *, int);
|
// int parse(Datetime *result, const StringRef& string);
|
// int parse(DatetimeTz *result, const StringRef& string);
|
// --------------------------------------------------------------------
|
if (verbose) cout << endl
|
<< "PARSE: DATETIME & DATETIMETZ" << endl
|
<< "============================" << endl;
|
char buffer[Util::k_MAX_STRLEN];
|
const bdlt::Date DD(246, 8, 10);
|
const bdlt::Time TT(2, 4, 6, 8);
|
const bdlt::Datetime XX(DD, TT); // 'XX' and 'ZZ' are controls,
|
const bdlt::DatetimeTz 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_TIME_DATA = NUM_DEFAULT_TIME_DATA;
|
const DefaultTimeDataRow (&TIME_DATA)[NUM_TIME_DATA] =
|
DEFAULT_TIME_DATA;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.