text
stringlengths 0
2.2M
|
---|
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::parseDecimal(&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::parseDecimal(&mX, INPUT, INPUT_LENGTH);
|
LOOP2_ASSERT(LINE, retCode, 0 == retCode);
|
LOOP2_ASSERT(LINE, X, EXPECTED_RESULT == X);
|
}
|
}
|
if (verbose) cout << "\nUsing 'MyEnumeration::Value' (with success)."
|
<< endl;
|
{
|
typedef test::MyEnumeration::Value Type;
|
static const struct {
|
int d_lineNum;
|
const char *d_input;
|
Type d_result;
|
} DATA[] = {
|
//line input result
|
//---- ----- ------
|
{ L_, "0X", test::MyEnumeration::VALUE1 },
|
{ L_, "1X", test::MyEnumeration::VALUE2 },
|
};
|
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 = DATA[(i+1)%2].d_result; const Type& X = mX;
|
LOOP2_ASSERT(LINE, X, EXPECTED_RESULT != X);
|
int retCode = Util::parseDecimal(&mX, INPUT, INPUT_LENGTH);
|
ASSERTV(LINE, retCode, 0 == retCode);
|
ASSERTV(LINE, EXPECTED_RESULT, X, EXPECTED_RESULT == X);
|
}
|
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.