text
stringlengths
0
2.2M
char buffer[INIT_BUFSIZE];
memset(buffer, 'Z', INIT_BUFSIZE);
Obj mSB(buffer, INIT_BUFSIZE);
if (verbose) {
cout << "\nTesting 'no effect' methods" << endl;
}
bsl::locale loc;
ASSERT(loc == mSB.pubimbue(loc));
ASSERT(0 == mSB.pubsync());
ASSERT(loc == mSB.getloc());
} break;
case 8: {
// --------------------------------------------------------------------
// TESTING 'data' METHOD
//
// Concerns:
//: 1 'data' method return a pointer providing modifiable access to the
//: character buffer held by this stream buffer (supplied at
//: construction).
//
// Plan:
//: 1 Create FixedMemOutput object. Verify that we can modify
//: character buffer, using pointer, returned by 'data' method call.
//: (C-1)
//
// Testing:
// char *data();
// --------------------------------------------------------------------
if (verbose) cout << endl
<< "TESTING 'data' METHOD" << endl
<< "=====================" << endl;
char buffer[INIT_BUFSIZE];
memset(buffer, 'Z', INIT_BUFSIZE);
Obj mSB(buffer, INIT_BUFSIZE);
if (verbose) {
cout << "\nClient provided character buffer changing." << endl;
}
ASSERT('Z' == buffer[0]);
*(mSB.data()) = 'a';
ASSERT('a' == buffer[0]);
} break;
case 7: {
// --------------------------------------------------------------------
// TESTING 'pubsetbuf' METHOD
// Ensure that we can reset put area to client-provided buffer for a
// constructed stream buffer object
//
// Concerns:
//: 1 The 'pubsetbuf' method can reset internal buffer.
//:
//: 2 The 'pubsetbuf' method can replace internal buffer with new user
//: provided buffer.
//:
//: 3 QoI: Asserted precondition violations are detected when enabled.
//
// Plan:
//: 1 Manually call 'pubsetbuf' method and verify that the buffer has
//: been reset to the new address and length. (C-1..2)
//:
//: 2 Verify that, in appropriate build modes, defensive checks are
//: triggered for invalid attribute values, but not triggered for
//: adjacent valid ones (using the 'BSLS_ASSERTTEST_*' macros). (C-3)
//
// Testing:
// FixedMemOutput *pubsetbuf(char *buffer, streamsize length);
// --------------------------------------------------------------------
if (verbose) cout << endl
<< "TESTING 'pubsetbuf' METHOD" << endl
<< "==========================" << endl;
if (verbose) cout << "\nBuffer resetting." << endl;
{
char buffer[INIT_BUFSIZE];
Obj mSB(buffer, INIT_BUFSIZE);
const Obj& SB = mSB;
mSB.sputc('a');
ASSERT(buffer == SB.data());
ASSERT(INIT_BUFSIZE == SB.capacity());
ASSERT(1 == SB.length());
mSB.pubsetbuf(0, 0);
ASSERT(0 == SB.data());
ASSERT(0 == SB.capacity());
ASSERT(0 == SB.length());
}
if (verbose) cout << "\nBuffer replacement." << endl;
{
char buffer1[INIT_BUFSIZE];
memset(buffer1, 'Z', INIT_BUFSIZE);
char buffer2[INIT_BUFSIZE];
memset(buffer2, 'A', INIT_BUFSIZE);