text
stringlengths 0
2.2M
|
---|
if (verbose) cout << "\nTESTING 'printBase64' ROUND TRIP"
|
<< "\n================================" << endl;
|
static const struct TestData {
|
int d_line;
|
const char *d_input;
|
} DATA[] = {
|
//line input
|
//---- -----
|
{ L_, "" },
|
{ L_, "a" },
|
{ L_, "ab" },
|
{ L_, "abc" },
|
{ L_, "abcd" },
|
};
|
const int NUM_DATA = sizeof DATA / sizeof *DATA;
|
for (int i = 0; i < NUM_DATA; ++i) {
|
const int LINE = DATA[i].d_line;
|
const char *INPUT = DATA[i].d_input;
|
const bsl::size_t INPUT_LENGTH = bsl::strlen(INPUT);
|
const bsl::string IN(INPUT, INPUT + INPUT_LENGTH);
|
bsl::stringstream ss;
|
Print::printBase64(ss, IN);
|
ASSERTV(LINE, ss.good());
|
const bsl::string ENCODED(ss.str());
|
using TestMachinery::intLength;
|
{
|
typedef bsl::string Type;
|
Type mDecoded; const Type& DECODED = mDecoded;
|
ASSERTV(LINE, 0 == Util::parseBase64(&mDecoded,
|
ENCODED.data(),
|
intLength(ENCODED)));
|
ASSERTV(LINE, ENCODED, DECODED, INPUT, INPUT == DECODED);
|
}
|
{
|
typedef bsl::vector<char> Type;
|
Type mDecoded; const Type& DECODED = mDecoded;
|
ASSERTV(LINE, 0 == Util::parseBase64(&mDecoded,
|
ENCODED.data(),
|
intLength(ENCODED)));
|
const Type IN_VEC(IN.begin(), IN.end());
|
ASSERTV(LINE, ENCODED, DECODED, IN_VEC, IN_VEC == DECODED);
|
}
|
}
|
} break;
|
case 8: {
|
// --------------------------------------------------------------------
|
// TESTING 'parse' FUNCTION
|
//
|
// Concerns:
|
//
|
// Plan:
|
// --------------------------------------------------------------------
|
if (verbose) cout << "\nTesting 'parse' Function"
|
<< "\n========================" << endl;
|
if (verbose) cout << "\nUsing 'BASE64'." << endl;
|
{
|
typedef bsl::vector<char> Type;
|
static const struct {
|
int d_lineNum;
|
const char *d_input;
|
const char *d_result;
|
} DATA[] = {
|
//line input result
|
//---- ----- ------
|
{ L_, "X", "", },
|
{ L_, "YQ==X", "a", },
|
{ L_, "YWI=X", "ab", },
|
{ L_, "YWJjX", "abc", },
|
{ L_, "YWJjZA==X", "abcd", },
|
};
|
const int NUM_DATA = sizeof DATA / sizeof *DATA;
|
for (int i = 0; i < NUM_DATA; ++i) {
|
const int LINE = DATA[i].d_lineNum;
|
const char *INPUT = DATA[i].d_input;
|
const char *RESULT = DATA[i].d_result;
|
const int INPUT_LENGTH =
|
static_cast<int>(bsl::strlen(INPUT)) - 1;
|
const bsl::size_t RESULT_LENGTH = bsl::strlen(RESULT);
|
const Type EXPECTED_RESULT(RESULT, RESULT + RESULT_LENGTH);
|
Type mX; const Type& X = mX;
|
int retCode = Util::parse(&mX,
|
INPUT,
|
INPUT_LENGTH,
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.