Skip to content

Commit

Permalink
Cover the \n in flex (#3461)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shylock-Hg authored Dec 14, 2021
1 parent 6b7560b commit d06fd9f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
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

0 comments on commit d06fd9f

Please sign in to comment.