pearu commented on code in PR #50146:
URL: https://github.com/apache/arrow/pull/50146#discussion_r4263285501
##########
cpp/src/arrow/util/value_parsing_test.cc:
##########
@@ -869,11 +870,45 @@ TEST(TimestampParser, StrptimeParser) {
}
// Unparseable strings
- std::vector<std::string> unparseables = {"foo", "5/1/2000", "5/1/2000
12:34:56:6"};
+ std::vector<std::string> unparseables = {
+ "foo", "5/1/2000", "5/1/2000 12:34:56:6",
+ // Leap seconds are rejected, as by the
+ // ISO-8601 parser
+ "5/31/2000 12:30:60", "5/31/2000 23:59:60", "5/31/2000 23:59:61",
+ // Impossible dates are rejected rather
+ // than rolled over into the next month
+ "2/30/2000 12:34:56", "4/31/2000 12:34:56", "2/29/2001 12:34:56",
+ // A zero day is rejected rather than
+ // taken as the first of the month
+ "2/00/2000 12:34:56"};
for (auto& value : unparseables) {
int64_t dummy;
ASSERT_FALSE((*parser)(value.c_str(), value.size(), TimeUnit::SECOND,
&dummy));
}
+
+ // A format without a day still parses (the day defaults to the first)
+ auto month_parser = TimestampParser::MakeStrptime("%Y-%m");
+ int64_t converted, expected;
+ ASSERT_TRUE((*month_parser)("2000-02", 7, TimeUnit::SECOND, &converted));
+ ASSERT_TRUE(ParseTimestampISO8601("2000-02-01", 10, TimeUnit::SECOND,
&expected));
+ ASSERT_EQ(expected, converted);
+}
+
+TEST(TimestampParser, StrptimeYearOutOfRange) {
+ auto parser = TimestampParser::MakeStrptime("%s");
+ int64_t converted = 0;
+ if (!(*parser)("1584282600", 10, TimeUnit::SECOND, &converted)) {
Review Comment:
@ianmcook could you submit the test-debian-13-cpp-i386 job as I cannot
(https://github.com/apache/arrow/pull/50146#issuecomment-6153819189)?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]