text
stringlengths
0
2.2M
if (verbose) cout << "\nUsing 'MyEnumeration::Value' (with failure)."
<< endl;
{
typedef test::MyEnumeration::Value Type;
static const struct {
int d_lineNum;
const char *d_input;
} DATA[] = {
//line input
//---- -----
{ L_, "2X", },
{ L_, "3X", },
};
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;
Type mX;
int retCode = Util::parseDecimal(&mX, INPUT, INPUT_LENGTH);
LOOP2_ASSERT(LINE, retCode, 0 != retCode);
}
}
if (verbose) cout << "\nUsing 'CustomizedInt' (with success)." << endl;
{
typedef test::CustomizedInt Type;
static const struct {
int d_lineNum;
const char *d_input;
Type d_result;
} DATA[] = {
//line input result
//---- ----- ------
{ L_, "-2147483648X", Type(-2147483647-1)},
{ L_, "-2147483647X", Type(-2147483647) },
{ L_, "-1X", Type(-1) },
{ L_, "0X", Type(0) },
{ L_, "1X", Type(1) },
{ L_, "2X", Type(2) },
{ L_, "3X", Type(3) },
{ L_, "4X", Type(4) },
{ L_, "5X", Type(5) },
};
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; 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 'CustomizedInt' (with failure)." << endl;
{
typedef test::CustomizedInt Type;
static const struct {
int d_lineNum;
const char *d_input;
} DATA[] = {
//line input
//---- -----
{ L_, "6X", },
{ L_, "7X", },
{ L_, "2147483646X", },
{ L_, "2147483647X", },
};
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;
Type mX;
int retCode = Util::parseDecimal(&mX, INPUT, INPUT_LENGTH);
LOOP2_ASSERT(LINE, retCode, 0 != retCode);
}
}