text
stringlengths 0
2.2M
|
---|
//-----------------------------------------------------------------------------
|
int main(int argc, char **argv)
|
{
|
const int test = argc > 1 ? atoi(argv[1]) : 0;
|
const bool verbose = argc > 2;
|
const bool veryVerbose = argc > 3;
|
const bool veryVeryVerbose = argc > 4;
|
const bool veryVeryVeryVerbose = argc > 5;
|
(void) veryVeryVerbose;
|
(void) veryVeryVeryVerbose;
|
cout << "TEST " << __FILE__ << " CASE " << test << endl;
|
// CONCERN: 'BSLS_REVIEW' failures should lead to test failures.
|
bsls::ReviewFailureHandlerGuard reviewGuard(&bsls::Review::failByAbort);
|
switch (test) { case 0:
|
case 10: {
|
// --------------------------------------------------------------------
|
// USAGE EXAMPLE
|
// Extracted from component header file.
|
//
|
// Concerns:
|
//: 1 The usage example provided in the component header file compiles,
|
//: links, and runs as shown.
|
//
|
// Plan:
|
//: 1 Incorporate usage example from header into test driver, remove
|
//: leading comment characters, and replace 'assert' with 'ASSERT'.
|
//: (C-1)
|
//
|
// Testing:
|
// USAGE EXAMPLE
|
// --------------------------------------------------------------------
|
if (verbose) cout << endl
|
<< "USAGE EXAMPLE" << endl
|
<< "=============" << endl;
|
///Usage
|
///-----
|
// This section illustrates intended use of this component.
|
//
|
///Example 1: Basic Use of 'bdlsb::FixedMemOutput'
|
///- - - - - - - - - - - - - - - - - - - - - - - -
|
// This example demonstrates usage of a stream buffer by a stream, in this case
|
// a 'bslx::GenericOutStream'.
|
//
|
// First, we create an object of our stream buffer:
|
//..
|
enum { k_STREAMBUF_CAPACITY = 30 };
|
char buffer[k_STREAMBUF_CAPACITY];
|
bdlsb::FixedMemOutput streamBuf(buffer, k_STREAMBUF_CAPACITY);
|
//..
|
// Then, we create an instance of 'bslx::GenericOutStream' using 'streamBuf',
|
// with an arbitrary value for its 'versionSelector', and externalize some
|
// values:
|
//..
|
bslx::GenericOutStream<bdlsb::FixedMemOutput> outStream(&streamBuf,
|
20150707);
|
outStream.putInt32(1);
|
outStream.putInt32(2);
|
outStream.putInt8('c');
|
outStream.putString(bsl::string("hello"));
|
//..
|
// Finally, we compare the contents of the buffer to the expected value:
|
//..
|
ASSERT(15 == streamBuf.length());
|
ASSERT( 0 == bsl::memcmp(streamBuf.data(),
|
"\x00\x00\x00\x01\x00\x00\x00\x02""c\x05""hello",
|
15));
|
//..
|
} break;
|
case 9: {
|
// --------------------------------------------------------------------
|
// TESTING 'NO EFFECT' METHODS
|
// As 'pubimbue', 'pubsync' and 'getloc' methods have no effect, we
|
// can only ensure that these methods can be instantiated and return
|
// expected values.
|
//
|
// Concerns:
|
//: 1 Methods can be instantiated.
|
//:
|
//: 2 Methods return expected values.
|
//
|
// Plan:
|
//: 1 Create FixedMemOutput object. Manually call methods and verify
|
//: returned values. (C-1..2)
|
//
|
// Testing:
|
// locale pubimbue(const locale& loc);
|
// int pubsync();
|
// bsl::locale getloc() const;
|
// --------------------------------------------------------------------
|
if (verbose) cout << endl
|
<< "TESTING 'NO EFFECT' METHODS" << endl
|
<< "===========================" << endl;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.