text
stringlengths
0
2.2M
int retCode = Util::parseDefault(&mX, INPUT, INPUT_LENGTH);
LOOP2_ASSERT(LINE, retCode, 0 == retCode);
LOOP2_ASSERT(LINE, X, EXPECTED_RESULT == X);
}
}
if (verbose) cout << "\nUsing 'unsigned int'." << endl;
{
typedef unsigned int Type;
static const struct {
int d_lineNum;
const char *d_input;
Type d_result;
} DATA[] = {
//line input result
//---- ----- -----------
{ L_, "0X", 0 },
{ L_, "1X", 1 },
{ L_, "4294967294X", 4294967294U },
{ L_, "4294967295X", 4294967295U },
};
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::parseDefault(&mX, INPUT, INPUT_LENGTH);
LOOP2_ASSERT(LINE, retCode, 0 == retCode);
LOOP2_ASSERT(LINE, X, EXPECTED_RESULT == X);
}
}
if (verbose) cout << "\nUsing 'bsls::Types::Uint64'." << endl;
{
typedef bsls::Types::Uint64 Type;
static const struct {
int d_lineNum;
const char *d_input;
Type d_result;
} DATA[] = {
//line input result
//---- ----- ------
{ L_, "0X", 0ULL, },
{ L_, "1X", 1ULL, },
{ L_, "18446744073709551614X", 18446744073709551614ULL, },
{ L_, "18446744073709551615X", 18446744073709551615ULL, },
};
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::parseDefault(&mX, INPUT, INPUT_LENGTH);
LOOP2_ASSERT(LINE, retCode, 0 == retCode);
LOOP2_ASSERT(LINE, X, EXPECTED_RESULT == X);
}
}
if (verbose) cout << "\nUsing 'float'." << endl;
{
typedef float Type;
Type posInf = bsl::numeric_limits<Type>::infinity();
Type qNaN = bsl::numeric_limits<Type>::quiet_NaN();
static const struct {
int d_lineNum;
const char *d_input;
Type d_result;
} DATA[] = {
//line input result
//---- ----- ---------
{ L_, "-1X", -1.0f },
{ L_, "-0.1X", -0.1f },
{ L_, "0X", 0.0f },
{ L_, "0.1X", 0.1f },
{ L_, "1X", 1.0f },
{ L_, "123.4X", 123.4f },
{ L_, "0.005X", 0.005f },
{ L_, "9.99E36X", 9.99E36f },
{ L_, "+INFX", posInf },
{ L_, "-INFX", -posInf },