text
stringlengths
0
2.2M
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::parseHex(&mX, INPUT, INPUT_LENGTH);
LOOP2_ASSERT(LINE, retCode, 0 == retCode);
LOOP2_ASSERT(LINE, X, EXPECTED_RESULT == X);
}
}
if (verbose) cout << "\nUsing 'bsl::vector<char>'." << endl;
{
typedef bsl::vector<char> Type;
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::parseHex(&mX, INPUT, INPUT_LENGTH);
LOOP2_ASSERT(LINE, retCode, 0 == retCode);
LOOP2_ASSERT(LINE, X, EXPECTED_RESULT == X);
}
}
} break;
case 3: {
// --------------------------------------------------------------------
// TESTING 'parseDecimal' FUNCTIONS
//
// Concerns:
//
// Plan:
// --------------------------------------------------------------------
if (verbose) cout << "\nTesting 'parseDecimal' Functions"
<< "\n================================" << endl;
if (verbose) cout << "\nUsing 'bool'." << endl;
{
typedef bool Type;
static const struct {
int d_lineNum;
const char *d_input;
Type d_result;
} DATA[] = {
//line input result
//---- ----- ------
{ L_, "1X", true },
{ L_, "0X", false },
};
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 int INPUT_LENGTH =
static_cast<int>(bsl::strlen(INPUT)) - 1;
const Type EXPECTED_RESULT = DATA[i].d_result;
Type mX(!EXPECTED_RESULT); const Type& X = mX;
int retCode = Util::parseDecimal(&mX, INPUT, INPUT_LENGTH);
LOOP2_ASSERT(LINE, retCode, 0 == retCode);
LOOP2_ASSERT(LINE, X, EXPECTED_RESULT == X);
}
}
if (verbose) cout << "\nUsing 'char'." << endl;
{
typedef char Type;
static const struct {
int d_lineNum;
const char *d_input;
Type d_result;
} DATA[] = {
//line input result
//---- ----- ------
{ L_, "-128X", -128 },
{ L_, "-127X", -127 },
{ L_, "-1X", -1 },
{ L_, "0X", 0 },
{ L_, "1X", 1 },
{ L_, "126X", 126 },
{ L_, "127X", 127 },
};