text
stringlengths 0
2.2M
|
---|
{
|
typedef test::CustomizedInt Type;
|
static const RoundTripTestData<Type> DATA[] =
|
{
|
//line input
|
//---- -----
|
{ L_, Type(-2147483647-1) },
|
{ L_, Type(-2147483647) },
|
{ L_, Type(-1) },
|
{ L_, Type(0) },
|
{ L_, Type(1) },
|
{ L_, Type(2) },
|
{ L_, Type(3) },
|
{ L_, Type(4) },
|
{ L_, Type(5) },
|
};
|
printDefaultRoundTripTester(DATA);
|
}
|
if (verbose) cout << "\nTesting date and time types." << endl;
|
{
|
static const struct TestData {
|
int d_line;
|
int d_year;
|
int d_month;
|
int d_day;
|
int d_hour;
|
int d_minute;
|
int d_second;
|
int d_millisecond;
|
int d_microsecond;
|
int d_offset;
|
} DATA[] = {
|
//Line Year Mon Day Hour Min Sec ms us offset
|
//---- ---- --- --- ---- --- --- -- -- ------
|
// Valid dates and times
|
{ L_, 1, 1, 1, 0, 0, 0, 0, 0, 0 },
|
{ L_, 2005, 1, 1, 0, 0, 0, 0, 0, -90 },
|
{ L_, 123, 6, 15, 13, 40, 59, 0, 0, -240 },
|
{ L_, 1999, 10, 12, 23, 0, 1, 0, 0, -720 },
|
// Vary milliseconds
|
{ L_, 1999, 10, 12, 23, 0, 1, 0, 0, 90 },
|
{ L_, 1999, 10, 12, 23, 0, 1, 456, 0, 240 },
|
{ L_, 1999, 10, 12, 23, 0, 1, 456, 789, 240 },
|
{ L_, 1999, 10, 12, 23, 0, 1, 999, 789, 720 },
|
{ L_, 1999, 12, 31, 23, 59, 59, 999, 999, 720 }
|
};
|
const int NUM_DATA = sizeof DATA / sizeof *DATA;
|
for (int ti = 0; ti < NUM_DATA; ++ti) {
|
const int LINE = DATA[ti].d_line;
|
const int YEAR = DATA[ti].d_year;
|
const int MONTH = DATA[ti].d_month;
|
const int DAY = DATA[ti].d_day;
|
const int HOUR = DATA[ti].d_hour;
|
const int MINUTE = DATA[ti].d_minute;
|
const int SECOND = DATA[ti].d_second;
|
const int MILLISECOND = DATA[ti].d_millisecond;
|
const int MICROSECOND = DATA[ti].d_microsecond;
|
const int OFFSET = DATA[ti].d_offset;;
|
const bdlt::Date IN_DATE(YEAR, MONTH, DAY);
|
const bdlt::Time IN_TIME(HOUR, MINUTE, SECOND,
|
MILLISECOND);
|
const bdlt::Datetime IN_DATETIME(YEAR, MONTH, DAY,
|
HOUR, MINUTE, SECOND,
|
MILLISECOND, MICROSECOND);
|
const bdlt::DateTz IN_DATETZ(IN_DATE, OFFSET);
|
const bdlt::TimeTz IN_TIMETZ(IN_TIME, OFFSET);
|
const bdlt::DatetimeTz IN_DATETIMETZ(IN_DATETIME, OFFSET);
|
using TestMachinery::intLength;
|
{
|
bsl::ostringstream ss;
|
Print::printDefault(ss, IN_DATE);
|
ASSERTV(LINE, ss.good());
|
const bsl::string ENCODED(ss.str());
|
bdlt::Date decoded;
|
ASSERTV(LINE, ENCODED,
|
0 == Util::parseDefault(&decoded,
|
ENCODED.data(),
|
intLength(ENCODED)));
|
ASSERTV(LINE, ENCODED, IN_DATE, decoded,
|
IN_DATE == decoded);
|
}
|
{
|
bsl::ostringstream ss;
|
Print::printDefault(ss, IN_DATETZ);
|
ASSERTV(LINE, ss.good());
|
const bsl::string ENCODED(ss.str());
|
bdlt::DateTz decoded;
|
ASSERTV(LINE, ENCODED,
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.