Timestamp Parsing of YY-MM-DDT Fails As Invalid
The following test fails:
TEST(IonTimestamp, YYMMDDT) {
ION_TIMESTAMP timestamp;
SIZE chars_used;
std::string lit("2020-08-10T");
ION_ASSERT_OK(ion_timestamp_parse(
×tamp, (char *)lit.c_str(), (SIZE) (lit.size() + 1), &chars_used, &g_IonEventDecimalContext
));
ASSERT_EQ(lit.size(), chars_used);
}
ion_timestamp_parse requires a null terminated string and appears to expects the buffer to be a length inclusive of the null termination (there is explicit code to look for the null character within the length specified).
The following works (note the lack of T):
TEST(IonTimestamp, YYMMDD) {
ION_TIMESTAMP timestamp;
SIZE chars_used;
std::string lit("2020-08-10");
ION_ASSERT_OK(ion_timestamp_parse(
×tamp, (char *)lit.c_str(), (SIZE) (lit.size() + 1), &chars_used, &g_IonEventDecimalContext
));
ASSERT_EQ(lit.size(), chars_used);
}
I suspect the problem (but have not confirmed) that the problem is at ion_timestamp L561, where it should be going to end_of_days, not end_of_time.
I will add that I believe this is an edge case where a timestamp is at the end of a buffer. There is a potential issue with the timestamp parsing routine requiring the \0 termination (so that might be the larger issue here), it should not be required due to the way Ion parsing routines work (they take a BYTE * and length irrespective of nul termination.