text
stringlengths
0
2.2M
{ L_, "\xf4\x85\xa3\xbf" },
{ L_, "\xf4\x88\xbf\x80" },
{ L_, "\xf4\x8d\xbf\xa6" },
{ L_, "\xf4\x8e\xbf\xbf" },
{ L_, "\xf4\x8f\x80\x80" },
{ L_, "\xf4\x8f\x80\xa6" },
{ L_, "\xf4\x8f\x80\xbf" },
{ L_, "\xf4\x8f\xa3\x80" },
{ L_, "\xf4\x8f\xa3\xa6" },
{ L_, "\xf4\x8f\xa3\xbf" },
{ L_, "\xf4\x8f\xbf\x80" },
{ L_, "\xf4\x8f\xbf\xa6" },
{ L_, "\xf4\x8f\xbf\xbf" },
};
const int NUM_DATA = sizeof DATA / sizeof *DATA;
using TestMachinery::buildPrintTextInput;
using TestMachinery::replaceCharEntities;
// Use orthogonal perturbations for making sure that printing is
// correct regardless of position in the string: Use header,
// trailer, or both.
const bsl::string_view HEADER("HeAdEr");
const bsl::string_view TRAILER("TrAiLeR");
using TestMachinery::intLength;
if (verbose) cout << "\nTesting 'bsl::string'." << endl;
{
typedef bsl::string Type;
for (int i = 0; i < NUM_DATA; ++i) {
const int LINE = DATA[i].d_line;
const Type INPUT = DATA[i].d_input;
bsl::stringstream ss;
Print::printText(ss, INPUT);
ASSERTV(LINE, ss.good());
const bsl::string ENCODED(replaceCharEntities(ss.str()));
Type decoded;
ASSERTV(LINE, 0 == Util::parseText(&decoded,
ENCODED.data(),
intLength(ENCODED)));
ASSERTV(LINE, ENCODED, decoded, INPUT, INPUT == decoded);
const Type INPUT2(buildPrintTextInput(HEADER, INPUT, ""));
ss.str("");
Print::printText(ss, INPUT2);
ASSERTV(LINE, ss.good());
const bsl::string ENCODED2(replaceCharEntities(ss.str()));
ASSERTV(LINE, 0 == Util::parseText(&decoded,
ENCODED2.data(),
intLength(ENCODED2)));
ASSERTV(LINE, ENCODED2, decoded, INPUT2,
INPUT2 == decoded);
const Type INPUT3(buildPrintTextInput("", INPUT, TRAILER));
ss.str("");
Print::printText(ss, INPUT3);
ASSERTV(LINE, ss.good());
const bsl::string ENCODED3(replaceCharEntities(ss.str()));
ASSERTV(LINE, 0 == Util::parseText(&decoded,
ENCODED3.data(),
intLength(ENCODED3)));
ASSERTV(LINE, ENCODED3, decoded, INPUT3,
INPUT3 == decoded);
const Type INPUT4(buildPrintTextInput(HEADER,
INPUT,
TRAILER));
ss.str("");
Print::printText(ss, INPUT4);
ASSERTV(LINE, ss.good());
const bsl::string ENCODED4(replaceCharEntities(ss.str()));
ASSERTV(LINE, 0 == Util::parseText(&decoded,
ENCODED4.data(),
intLength(ENCODED4)));
ASSERTV(LINE, ENCODED4, decoded, INPUT4,
INPUT4 == decoded);
}
}
if (verbose) cout << "\nUsing 'vector<char>'." << endl;
{
typedef bsl::vector<char> Type;
for (int i = 0; i < NUM_DATA; ++i) {
const bsl::size_t LENGTH = bsl::strlen(DATA[i].d_input);
const int LINE = DATA[i].d_line;
const char *CINPUT = DATA[i].d_input;
const Type INPUT(CINPUT, CINPUT + LENGTH);
bsl::stringstream ss;
Print::printText(ss, INPUT);
ASSERTV(LINE, ss.good());
const bsl::string ENCODED(replaceCharEntities(ss.str()));
Type decoded;
ASSERTV(LINE, 0 == Util::parseText(&decoded,