text stringlengths 0 2.2M |
|---|
//: contents.
|
//:
|
//: 2 When sufficient capacity is indicated, the method taking
|
//: 'bufferLength' generates a null terminator.
|
//:
|
//: 3 Each method returns the expected value (the correct character
|
//: count or the supplied 'ostream', depending on the return type).
|
//:
|
//: 4 The value of the supplied object is unchanged.
|
//:
|
//: 5 The configuration that is in effect, whether user-supplied or the
|
//: process-wide default, has the desired effect on the output.
|
//:
|
//: 6 QoI: Asserted precondition violations are detected when enabled.
|
//
|
// Plan:
|
//: 1 Using the table-driven technique, specify a set of distinct
|
//: 'Time' values (one per row) and their corresponding ISO 8601
|
//: string representations.
|
//:
|
//: 2 For each row 'R' in the table from P-1: (C-1..5)
|
//:
|
//: 1 Create a 'const' 'Time' object, 'X', from 'R'.
|
//:
|
//: 2 Invoke the six methods under test on 'X' for all possible
|
//: configurations. Also exercise the method taking 'bufferLength'
|
//: for all buffer lengths in the range '[0 .. L]', where 'L'
|
//: provides sufficient capacity for a null terminator and a few
|
//: extra characters. For each call, verify that the generated
|
//: output matches the string from 'R' (taking the effect of the
|
//: configuration into account), a null terminator is appended when
|
//: expected, and the return value is correct. (C-1..5)
|
//:
|
//: 3 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-6)
|
//
|
// Testing:
|
// int generate(char *, int, const Time&);
|
// int generate(char *, int, const Time&, const Config&);
|
// int generate(string *, const Time&);
|
// int generate(string *, const Time&, const Config&);
|
// ostream generate(ostream&, const Time&);
|
// ostream generate(ostream&, const Time&, const Config&);
|
// int generateRaw(char *, const Time&);
|
// int generateRaw(char *, const Time&, const Config&);
|
#ifndef BDE_OMIT_INTERNAL_DEPRECATED
|
// int generate(char *, const Time&, int);
|
#endif // BDE_OMIT_INTERNAL_DEPRECATED
|
// --------------------------------------------------------------------
|
if (verbose) cout << endl
|
<< "GENERATE 'Time'" << endl
|
<< "===============" << endl;
|
typedef bdlt::Time TYPE;
|
const int OBJLEN = Util::k_TIME_STRLEN;
|
const int BUFLEN = OBJLEN + 4;
|
char buffer[BUFLEN];
|
char chaste[BUFLEN]; bsl::memset(chaste, '?', BUFLEN);
|
const int NUM_TIME_DATA = NUM_DEFAULT_TIME_DATA;
|
const DefaultTimeDataRow (&TIME_DATA)[NUM_TIME_DATA] =
|
DEFAULT_TIME_DATA;
|
const int NUM_CNFG_DATA = NUM_DEFAULT_CNFG_DATA;
|
const DefaultCnfgDataRow (&CNFG_DATA)[NUM_CNFG_DATA] =
|
DEFAULT_CNFG_DATA;
|
for (int ti = 0; ti < NUM_TIME_DATA; ++ti) {
|
const int ILINE = TIME_DATA[ti].d_line;
|
const int HOUR = TIME_DATA[ti].d_hour;
|
const int MIN = TIME_DATA[ti].d_min;
|
const int SEC = TIME_DATA[ti].d_sec;
|
const int MSEC = TIME_DATA[ti].d_msec;
|
const int USEC = TIME_DATA[ti].d_usec;
|
const char *ISO8601 = TIME_DATA[ti].d_iso8601;
|
const TYPE X(HOUR, MIN, SEC, MSEC, USEC);
|
const bsl::string BASE_EXPECTED(ISO8601);
|
if (veryVerbose) { T_ P_(ILINE) P_(X) P(BASE_EXPECTED) }
|
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);
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.