text
stringlengths 0
2.2M
|
---|
} DATA[] = {
|
//line input result
|
//---- ----- ------
|
{ L_, "-9223372036854775808X",
|
static_cast<Type>(-9223372036854775808ULL) },
|
{ L_, "-9223372036854775807X", -9223372036854775807LL },
|
{ L_, "-1X", -1LL },
|
{ L_, "0X", 0LL },
|
{ L_, "1X", 1LL },
|
{ L_, "9223372036854775806X", 9223372036854775806LL },
|
{ L_, "9223372036854775807X", 9223372036854775807LL },
|
};
|
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 'unsigned char'." << endl;
|
{
|
typedef unsigned char 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_, "254X", 254 },
|
{ L_, "255X", 255 },
|
};
|
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 'unsigned short'." << endl;
|
{
|
typedef unsigned short 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_, "65534X", 65534 },
|
{ L_, "65535X", 65535 },
|
};
|
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 'unsigned int'." << endl;
|
{
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.