diff --git a/benchmark/trivialre.h b/benchmark/trivialre.h index 4485f8b..3eba725 100644 --- a/benchmark/trivialre.h +++ b/benchmark/trivialre.h @@ -58,14 +58,14 @@ inline bool MatchSubstring(const Matcher& m, std::string_view str) { size_t sz = str.size(); CB succeed = [](std::string_view str, bool line_start) { return true; }; bool line_start = true; - for (size_t i = 0; i <= sz; i++) { + for (size_t i = 0; i < sz; i++) { if (m(str, line_start, succeed)) { return true; } line_start = (str[0] == '\n'); str.remove_prefix(1); } - return false; + return m("", line_start, succeed); } Matcher CompileREOrDie(std::string_view str); diff --git a/benchmark/trivialre_test.cc b/benchmark/trivialre_test.cc index 161ee54..7736947 100644 --- a/benchmark/trivialre_test.cc +++ b/benchmark/trivialre_test.cc @@ -154,6 +154,8 @@ TEST(TrivialRETest, Runnings) { {"^a", "+a", "-ba", "+b\na"}, {"a$", "+a\nb", "+ba", "+b\na"}, {"a$\\nb", "+a\nb"}, + {"$", "+", "+aaa"}, + {"^$", "+", "-aaa", "+aaa\n"}, }; for (const auto& vec : cases2) {