text
stringlengths
0
2.2M
ASSERT_PASS(Util::generate(&mP, X));
ASSERT_FAIL(Util::generate( pp, X));
ASSERT_PASS(Util::generate(&mP, X, C));
ASSERT_FAIL(Util::generate( pp, X, C));
#endif
}
if (verbose) cout << "\t'generateRaw'" << endl;
{
const TYPE X;
char buffer[OBJLEN], *pc = 0;
ASSERT_SAFE_PASS(Util::generateRaw(buffer, X));
ASSERT_SAFE_FAIL(Util::generateRaw( pc, X));
ASSERT_SAFE_PASS(Util::generateRaw(buffer, X, C));
ASSERT_FAIL(Util::generateRaw( pc, X, C));
}
}
} break;
case 2: {
// --------------------------------------------------------------------
// GENERATE 'Date'
//
// Concerns:
//: 1 The output generated by each method has the expected format and
//: 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
//: 'Date' 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' 'Date' 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 Date&);
// int generate(char *, int, const Date&, const Config&);
// int generate(string *, const Date&);
// int generate(string *, const Date&, const Config&);
// ostream generate(ostream&, const Date&);
// ostream generate(ostream&, const Date&, const Config&);
// int generateRaw(char *, const Date&);
// int generateRaw(char *, const Date&, const Config&);
#ifndef BDE_OMIT_INTERNAL_DEPRECATED
// int generate(char *, const Date&, int);
#endif // BDE_OMIT_INTERNAL_DEPRECATED
// --------------------------------------------------------------------
if (verbose) cout << endl
<< "GENERATE 'Date'" << endl
<< "===============" << endl;
typedef bdlt::Date TYPE;
const int OBJLEN = Util::k_DATE_STRLEN;
const int BUFLEN = OBJLEN + 4;
char buffer[BUFLEN];
char chaste[BUFLEN]; bsl::memset(chaste, '?', BUFLEN);
const int NUM_DATE_DATA = NUM_DEFAULT_DATE_DATA;
const DefaultDateDataRow (&DATE_DATA)[NUM_DATE_DATA] =
DEFAULT_DATE_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_DATE_DATA; ++ti) {