Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cover the \n in flex. #3461

Merged
merged 2 commits into from
Dec 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/common/time/parser/datetime_scanner.lex
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ R_BRACKET "]"
return TokenType::TIME_ZONE_NAME;
}

. {
\n|. {
/**
* Any other unmatched byte sequences will get us here,
* including the non-ascii ones, which are negative
Expand Down
30 changes: 30 additions & 0 deletions src/common/time/parser/test/DateTimeParserTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@ TEST(DatetimeReader, DateTimeFailed) {
auto result = parser.readDatetime("2019-01-03T22:22:3.2333x");
EXPECT_FALSE(result.ok()) << result.value();
}
{
auto parser = time::DatetimeReader::makeDateTimeReader();
auto result = parser.readDatetime("2019-01-03T22:22:3.2333\n");
EXPECT_FALSE(result.ok()) << result.value();
}
{
auto parser = time::DatetimeReader::makeDateTimeReader();
auto result = parser.readDatetime("\t2019-01-03T22:22:3.2333");
EXPECT_FALSE(result.ok()) << result.value();
}
// not ending delimiter
{
auto parser = time::DatetimeReader::makeDateTimeReader();
Expand Down Expand Up @@ -150,6 +160,16 @@ TEST(DatetimeReader, DateFailed) {
auto result = parser.readDate("2019-01-03*");
EXPECT_FALSE(result.ok()) << result.value();
}
{
auto parser = time::DatetimeReader::makeDateReader();
auto result = parser.readDate("2019-01-03\n");
EXPECT_FALSE(result.ok()) << result.value();
}
{
auto parser = time::DatetimeReader::makeDateReader();
auto result = parser.readDate("\t2019-01-03");
EXPECT_FALSE(result.ok()) << result.value();
}
// extra components
{
auto parser = time::DatetimeReader::makeDateReader();
Expand Down Expand Up @@ -227,6 +247,16 @@ TEST(DatetimeReader, TimeFailed) {
auto result = parser.readTime("22:22:3.2333x");
EXPECT_FALSE(result.ok()) << result.value();
}
{
auto parser = time::DatetimeReader::makeTimeReader();
auto result = parser.readTime("22:22:3.2333\n");
EXPECT_FALSE(result.ok()) << result.value();
}
{
auto parser = time::DatetimeReader::makeTimeReader();
auto result = parser.readTime("\t22:22:3.2333\n");
EXPECT_FALSE(result.ok()) << result.value();
}
// extra components
{
auto parser = time::DatetimeReader::makeTimeReader();
Expand Down