text
stringlengths 0
2.2M
|
---|
{ L_, "NaNX", qNaN },
|
};
|
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);
|
if (bdlb::Float::isNan(EXPECTED_RESULT)) {
|
LOOP2_ASSERT(LINE, X, bdlb::Float::isNan(X));
|
}
|
else {
|
LOOP2_ASSERT(LINE, X, EXPECTED_RESULT == X);
|
}
|
}
|
}
|
if (verbose) cout << "\nUsing 'double'." << endl;
|
{
|
typedef double 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.0, },
|
{ L_, "-0.1X", -0.1, },
|
{ L_, "0X", 0.0, },
|
{ L_, "0.1X", 0.1, },
|
{ L_, "1X", 1.0, },
|
{ L_, "123.4X", 123.4, },
|
{ L_, "0.005X", 0.005 },
|
{ L_, "9.99E306X", 9.99E306 },
|
{ L_, "+INFX", posInf, },
|
{ L_, "-INFX", -posInf, },
|
{ L_, "NaNX", qNaN },
|
};
|
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);
|
if (bdlb::Float::isNan(EXPECTED_RESULT)) {
|
LOOP2_ASSERT(LINE, X, bdlb::Float::isNan(X));
|
}
|
else {
|
LOOP2_ASSERT(LINE, X, EXPECTED_RESULT == X);
|
}
|
}
|
}
|
if (verbose) cout << "\nUsing 'Decimal64'." << endl;
|
{
|
typedef bdldfp::Decimal64 Type;
|
const Type posInf = bsl::numeric_limits<Type>::infinity();
|
const Type qNaN = bsl::numeric_limits<Type>::quiet_NaN();
|
const Type qNull = BDLDFP_DECIMAL_DD(-2.3e5);
|
static const struct Data {
|
int d_lineNum;
|
const char *d_input;
|
Type d_result;
|
bool d_weird;
|
} DATA[] = {
|
//line input result weird
|
//---- ----- ------ -----
|
{ L_, "-1X", BDLDFP_DECIMAL_DD(-1.0), 0 },
|
{ L_, "-0.1X", BDLDFP_DECIMAL_DD(-0.1), 0 },
|
{ L_, "0X", BDLDFP_DECIMAL_DD(0.0), 0 },
|
{ L_, "0.1X", BDLDFP_DECIMAL_DD(0.1), 0 },
|
{ L_, "1X", BDLDFP_DECIMAL_DD(1.0), 0 },
|
{ L_, "123.4X", BDLDFP_DECIMAL_DD(123.4), 0 },
|
{ L_, "0.005X", BDLDFP_DECIMAL_DD(0.005), 0 },
|
{ L_, "9.99E306X", BDLDFP_DECIMAL_DD(9.99E306), 0 },
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.