text
stringlengths
0
2.2M
ASSERT_PASS(Util::generate(&mS, X, C));
ASSERT_FAIL(Util::generate( ps, X, C));
#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_PMR
std::pmr::string mP("qwerty"), *pp = 0;
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 4: {
// --------------------------------------------------------------------
// GENERATE 'Datetime'
//
// 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 In a second table, specify a set of distinct 'Time' values (one
//: per row) and their corresponding ISO 8601 string representations.
//:
//: 3 For each element 'R' in the cross product of the tables from P-1
//: and P-2: (C-1..5)
//:
//: 1 Create a 'const' 'Datetime' 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 Datetime&);
// int generate(char *, int, const Datetime&, const Config&);
// int generate(string *, const Datetime&);
// int generate(string *, const Datetime&, const Config&);
// ostream generate(ostream&, const Datetime&);
// ostream generate(ostream&, const Datetime&, const Config&);
// int generateRaw(char *, const Datetime&);
// int generateRaw(char *, const Datetime&, const Config&);
#ifndef BDE_OMIT_INTERNAL_DEPRECATED
// int generate(char *, const Datetime&, int);
#endif // BDE_OMIT_INTERNAL_DEPRECATED
// --------------------------------------------------------------------
if (verbose) cout << endl
<< "GENERATE 'Datetime'" << endl
<< "===================" << endl;
typedef bdlt::Datetime TYPE;
const int OBJLEN = Util::k_DATETIME_STRLEN;
const int BUFLEN = OBJLEN + 4;
char buffer[BUFLEN];
char chaste[BUFLEN]; bsl::memset(chaste, '?', BUFLEN);