text
stringlengths 0
2.2M
|
---|
void aSsErT(bool condition, const char *message, int line)
|
{
|
if (condition) {
|
cout << "Error " __FILE__ "(" << line << "): " << message
|
<< " (failed)" << endl;
|
if (0 <= testStatus && testStatus <= 100) {
|
++testStatus;
|
}
|
}
|
}
|
} // close unnamed namespace
|
// ============================================================================
|
// STANDARD BDE TEST DRIVER MACRO ABBREVIATIONS
|
// ----------------------------------------------------------------------------
|
#define ASSERT BSLIM_TESTUTIL_ASSERT
|
#define ASSERTV BSLIM_TESTUTIL_ASSERTV
|
#define LOOP_ASSERT BSLIM_TESTUTIL_LOOP_ASSERT
|
#define LOOP0_ASSERT BSLIM_TESTUTIL_LOOP0_ASSERT
|
#define LOOP1_ASSERT BSLIM_TESTUTIL_LOOP1_ASSERT
|
#define LOOP2_ASSERT BSLIM_TESTUTIL_LOOP2_ASSERT
|
#define LOOP3_ASSERT BSLIM_TESTUTIL_LOOP3_ASSERT
|
#define LOOP4_ASSERT BSLIM_TESTUTIL_LOOP4_ASSERT
|
#define LOOP5_ASSERT BSLIM_TESTUTIL_LOOP5_ASSERT
|
#define LOOP6_ASSERT BSLIM_TESTUTIL_LOOP6_ASSERT
|
#define Q BSLIM_TESTUTIL_Q // Quote identifier literally.
|
#define P BSLIM_TESTUTIL_P // Print identifier and value.
|
#define P_ BSLIM_TESTUTIL_P_ // P(X) without '\n'.
|
#define T_ BSLIM_TESTUTIL_T_ // Print a tab (w/o newline).
|
#define L_ BSLIM_TESTUTIL_L_ // current Line number
|
// ============================================================================
|
// NEGATIVE-TEST MACRO ABBREVIATIONS
|
// ----------------------------------------------------------------------------
|
#define ASSERT_SAFE_PASS(EXPR) BSLS_ASSERTTEST_ASSERT_SAFE_PASS(EXPR)
|
#define ASSERT_SAFE_FAIL(EXPR) BSLS_ASSERTTEST_ASSERT_SAFE_FAIL(EXPR)
|
#define ASSERT_PASS(EXPR) BSLS_ASSERTTEST_ASSERT_PASS(EXPR)
|
#define ASSERT_FAIL(EXPR) BSLS_ASSERTTEST_ASSERT_FAIL(EXPR)
|
#define ASSERT_OPT_PASS(EXPR) BSLS_ASSERTTEST_ASSERT_OPT_PASS(EXPR)
|
#define ASSERT_OPT_FAIL(EXPR) BSLS_ASSERTTEST_ASSERT_OPT_FAIL(EXPR)
|
#define ASSERT_SAFE_PASS_RAW(EXPR) BSLS_ASSERTTEST_ASSERT_SAFE_PASS_RAW(EXPR)
|
#define ASSERT_SAFE_FAIL_RAW(EXPR) BSLS_ASSERTTEST_ASSERT_SAFE_FAIL_RAW(EXPR)
|
#define ASSERT_PASS_RAW(EXPR) BSLS_ASSERTTEST_ASSERT_PASS_RAW(EXPR)
|
#define ASSERT_FAIL_RAW(EXPR) BSLS_ASSERTTEST_ASSERT_FAIL_RAW(EXPR)
|
#define ASSERT_OPT_PASS_RAW(EXPR) BSLS_ASSERTTEST_ASSERT_OPT_PASS_RAW(EXPR)
|
#define ASSERT_OPT_FAIL_RAW(EXPR) BSLS_ASSERTTEST_ASSERT_OPT_FAIL_RAW(EXPR)
|
//=============================================================================
|
// GLOBAL TYPEDEFS/CONSTANTS FOR TESTING
|
//-----------------------------------------------------------------------------
|
typedef bdlsb::FixedMemOutput Obj;
|
typedef bsl::ios_base::openmode io_openmode;
|
typedef bsl::ios_base::seekdir io_seekdir;
|
const int INIT_BUFSIZE = 20;
|
//=============================================================================
|
// GLOBAL HELPER FUNCTIONS FOR TESTING
|
//-----------------------------------------------------------------------------
|
// ===============================
|
// operator<< for bdlsb::MemOutput
|
// ===============================
|
// FREE OPERATORS
|
bsl::ostream& operator<<(bsl::ostream& stream,
|
const bdlsb::FixedMemOutput& streamBuffer);
|
// Write the contents of the specified 'streamBuffer' (as well as a marker
|
// indicating eight bytes groupings) to the specified output 'stream' in
|
// binary format, and return a reference to the modifiable 'stream'.
|
bsl::ostream& operator<<(bsl::ostream& stream,
|
const bdlsb::FixedMemOutput& streamBuffer)
|
{
|
const bsl::streamsize len = streamBuffer.length();
|
const char *data = streamBuffer.data();
|
bsl::ios::fmtflags flags = stream.flags();
|
stream << bsl::hex;
|
for (int i = 0; i < len; ++i) {
|
if (0 < i && 0 != i % 8) stream << ' ';
|
if (0 == i % 8) { // print new line and address after 8 bytes
|
stream << '\n' << bsl::setw(4) << bsl::setfill('0') << i << '\t';
|
}
|
for (int j = 7; j >= 0; --j) stream << !!((data[i] >> j) & 0x01);
|
}
|
stream.flags(flags); // reset stream format flags
|
return stream;
|
}
|
//=============================================================================
|
// MAIN PROGRAM
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.