text
stringlengths
0
2.2M
{ L_, -Limits::infinity(), 'F', 0, 1 },
{ L_, Limits::signaling_NaN(), 'F', 0, 1 },
{ L_, Limits::quiet_NaN(), 'F', 0, 1 },
{ L_, DFP(0.1), 'S', 0, 0 },
{ L_, DFP(15.13), 'S', 3, 0 },
{ L_, DFP(-9.876543210987654e307), 'S', 15, 0 },
{ L_, DFP(0.001), 'S', 0, 0 },
{ L_, DFP(0.001), 'S', 1, 0 },
{ L_, DFP(0.001), 'S', 2, 0 },
{ L_, DFP(0.01), 'S', 0, 0 },
{ L_, DFP(0.01), 'S', 1, 0 },
{ L_, DFP(0.01), 'S', 2, 0 },
{ L_, DFP(0.1), 'S', 0, 0 },
{ L_, DFP(0.1), 'S', 1, 0 },
{ L_, DFP(0.1), 'S', 2, 0 },
{ L_, DFP(1.), 'S', 0, 0 },
{ L_, DFP(1.), 'S', 1, 0 },
{ L_, DFP(1.), 'S', 2, 0 },
{ L_, DFP(1.0), 'S', 0, 0 },
{ L_, DFP(1.0), 'S', 1, 0 },
{ L_, DFP(1.0), 'S', 2, 0 },
{ L_, DFP(1.00), 'S', 0, 0 },
{ L_, DFP(1.00), 'S', 1, 0 },
{ L_, DFP(1.00), 'S', 2, 0 },
{ L_, DFP(1.000), 'S', 0, 0 },
{ L_, DFP(1.000), 'S', 1, 0 },
{ L_, DFP(1.000), 'S', 2, 0 },
{ L_, Limits::max(), 'S', 15, 0 },
{ L_, -Limits::max(), 'S', 15, 0 },
{ L_, Limits::min(), 'S', 0, 0 },
{ L_, -Limits::min(), 'S', 0, 0 },
{ L_, Limits::infinity(), 'S', 0, 1 },
{ L_, -Limits::infinity(), 'S', 0, 1 },
{ L_, Limits::signaling_NaN(), 'S', 0, 1 },
{ L_, Limits::quiet_NaN(), 'S', 0, 1 },
#undef DFP
};
const int NUM_DATA = sizeof DATA / sizeof *DATA;
for (int ti = 0; ti < 2 * NUM_DATA; ++ti) {
const bool DECIMAL = ti % 2;
const TestData& data = DATA[ti / 2];
const int LINE = data.d_line;
const Type INPUT = data.d_input;
const char STYLE = data.d_style;
const int PRECISION = data.d_precision;
const bool WEIRD = data.d_weird;
if (DECIMAL && WEIRD) {
// SKIP unprintable combinations
continue; // CONTINUE
}
bsl::stringstream ss;
ss.precision(PRECISION);
if ('F' == STYLE) ss << bsl::fixed;
if ('S' == STYLE) ss << bsl::scientific;
DECIMAL ? Print::printDecimal(ss, INPUT)
: Print::printDefault(ss, INPUT);
ASSERTV(LINE, false == ss.fail());
const bsl::string ENCODED(ss.str());
Type decoded;
if (DECIMAL) {
using TestMachinery::intLength;
ASSERTV(LINE, ENCODED, PRECISION, STYLE,
0 == Util::parseDecimal(&decoded,
ENCODED.data(),
intLength(ENCODED)));
}
else {
using TestMachinery::intLength;
ASSERTV(LINE, ENCODED, PRECISION, STYLE,
0 == Util::parseDefault(&decoded,
ENCODED.data(),
intLength(ENCODED)));
}
if (INPUT != INPUT) { // NaN
ASSERTV(LINE, ENCODED, PRECISION, STYLE, INPUT, decoded,
decoded != decoded);
}
else { // Comparable values
ASSERTV(LINE, ENCODED, PRECISION, STYLE, INPUT, decoded,
INPUT == decoded);
}
}
}
if (verbose) cout << "\nTesting 'char *'." << endl;
{
static const RoundTripTestData<const char *> DATA[] =
{
//line input
//---- -----