text
stringlengths
0
2.2M
int retResult = mSB.sputc(DATA[i].d_outChar);
ASSERTV(LINE, 0 == strncmp(bytes,
DATA[i].d_result,
strlen(DATA[i].d_result)));
ASSERTV(LINE, DATA[i].d_returnVal == retResult);
ASSERTV(LINE, 'Z' == bytes[DATA[i].d_strCap]);
delete [] bytes;
}
}
if (verbose) { cout << "\tOverflow test." << endl; }
{
// Do an extra test to ensure that overflow does not corrupt
// the stream
const int BUF_SIZE = 5;
char buffer[BUF_SIZE];
Obj mSB(buffer, BUF_SIZE);
const Obj& SB = mSB;
mSB.sputc('a');
mSB.sputc('b');
mSB.sputc('c');
mSB.sputc('d');
mSB.sputc('e');
ASSERT( SB.length() == SB.capacity());
int retResult = mSB.sputc('f');
ASSERT(-1 == retResult);
ASSERT( 0 == strncmp(buffer, "abcde", BUF_SIZE));
ASSERT( BUF_SIZE == SB.capacity());
ASSERT( BUF_SIZE == SB.length());
ASSERT( buffer == SB.data());
}
}
} break;
case 1: {
// --------------------------------------------------------------------
// BREATHING TEST
// This case exercises (but does not fully test) basic functionality.
//
// Concerns:
//: 1 The class is sufficiently functional to enable comprehensive
//: testing in subsequent test cases.
//
// Plan:
//: 1 Developer test sandbox. (C-1)
//
// Testing:
// BREATHING TEST
// --------------------------------------------------------------------
if (verbose) cout << endl
<< "BREATHING TEST" << endl
<< "==============" << endl;
if (verbose) cout <<
"\nMake sure we can create and use a 'bdlsb::FixedMemOutput'."
<< endl;
{
char buffer[INIT_BUFSIZE];
Obj mSB(buffer, INIT_BUFSIZE);
const Obj& SB = mSB;
if (verbose) { cout << \
"\tCreate a fixed-length output stream buffer: ";
P(SB) }
ASSERT(0 == SB.length());
mSB.sputn("hello", 5);
if (verbose) { cout <<
"\n\tWrite a string (five chars) to the stream buffer: ";
P(SB) }
ASSERT(5 == SB.length());
ASSERT(0 == strncmp(SB.data(), "hello", 5));
mSB.sputc('s');
if (verbose) { cout <<
"\n\tWrite a single char to the stream buffer: ";
P(SB) }
ASSERT(6 == SB.length());
ASSERT(0 == strncmp(SB.data(), "hellos", 6));
}
} break;
default: {
cerr << "WARNING: CASE `" << test << "' NOT FOUND." << endl;
testStatus = -1;
}
}
if (testStatus > 0) {
cerr << "Error, non-zero test status = " << testStatus << "." << endl;
}
return testStatus;
}
// ----------------------------------------------------------------------------