text
stringlengths 0
2.2M
|
---|
{ L_, "+INFX", posInf, 1 },
|
{ L_, "-INFX", -posInf, 1 },
|
{ L_, "NaNX", qNaN, 1 },
|
};
|
const int NUM_DATA = sizeof DATA / sizeof *DATA;
|
for (int ti = 0; ti < 2 * NUM_DATA; ++ti) {
|
const bool DECIMAL = ti % 2;
|
const Data& data = DATA[ti / 2];
|
const int LINE = data.d_lineNum;
|
const char *INPUT = data.d_input;
|
const int INPUT_LENGTH =
|
static_cast<int>(bsl::strlen(INPUT)) - 1;
|
const Type EXPECTED_RESULT = data.d_result;
|
const bool WEIRD = data.d_weird;
|
const bool SUCCESS = !DECIMAL || !WEIRD;
|
Type mX(qNull); const Type& X = mX;
|
int rc = DECIMAL
|
? Util::parseDecimal(&mX, INPUT, INPUT_LENGTH)
|
: Util::parseDefault(&mX, INPUT, INPUT_LENGTH);
|
ASSERTV(LINE, rc, SUCCESS, SUCCESS == (0 == rc));
|
if (SUCCESS && bdldfp::DecimalUtil::isNan(EXPECTED_RESULT)) {
|
ASSERTV(LINE, X, bdldfp::DecimalUtil::isNan(X));
|
}
|
else {
|
ASSERTV(LINE, X, EXPECTED_RESULT, SUCCESS,
|
(SUCCESS ? EXPECTED_RESULT : qNull) == X);
|
}
|
}
|
}
|
if (verbose) cout << "\nUsing 'bsl::string'." << endl;
|
{
|
typedef bsl::string Type;
|
static const struct {
|
int d_lineNum;
|
const char *d_input;
|
Type d_result;
|
} DATA[] = {
|
//line input result
|
//---- ----- ------
|
{ L_, "X", "", },
|
{ L_, "HelloX", "Hello", },
|
{ L_, "World!!X", "World!!", },
|
};
|
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::parseDefault(&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;
|
static const struct {
|
int d_lineNum;
|
const char *d_input;
|
const char *d_result;
|
} DATA[] = {
|
//line input result
|
//---- ----- ------
|
{ L_, "X", "", },
|
{ L_, "YQ==X", "a", },
|
{ L_, "YWI=X", "ab", },
|
{ L_, "YWJjX", "abc", },
|
{ L_, "YWJjZA==X", "abcd", },
|
};
|
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 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::parseDefault(&mX, INPUT, INPUT_LENGTH);
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.