diff options
author | David Neto <dneto@google.com> | 2017-05-03 13:33:24 +0200 |
---|---|---|
committer | David Neto <dneto@google.com> | 2017-05-03 13:33:24 +0200 |
commit | df58d1187e8cedca2d4c0f7b37ffc2a27d45dae4 (patch) | |
tree | f40a86e867ac7fdea82aa26ebea89c9e0cbcf8f6 | |
parent | 6d5d7c6e29f7c3b2b3beb9c778df77606d813334 (diff) | |
download | effcee-df58d1187e8cedca2d4c0f7b37ffc2a27d45dae4.tar.gz |
Test regex parentheses counting
-rw-r--r-- | effcee/match_test.cc | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/effcee/match_test.cc b/effcee/match_test.cc index bb52ac5..daa51d7 100644 --- a/effcee/match_test.cc +++ b/effcee/match_test.cc @@ -831,4 +831,29 @@ TEST(Match, OutOfOrderDefAndUseViaDAGChecks) { EXPECT_FALSE(result) << result.message(); } +TEST(Match, VarDefRegexCountsParenthesesProperlyPass) { + const auto result = Match( + "FirstabababSecondcdcd\n1ababab2cdcd", + "CHECK: First[[X:(ab)+]]Second[[Y:(cd)+]]\nCHECK: 1[[X]]2[[Y]]"); + EXPECT_TRUE(result) << result.message(); +} + +TEST(Match, VarDefRegexCountsParenthesesProperlyFail) { + const auto result = Match( + "Firstababab1abab", + "CHECK: First[[X:(ab)+]]\nCHECK: 1[[X]]"); + EXPECT_FALSE(result) << result.message(); + EXPECT_THAT(result.message(), + HasSubstr(R"(<stdin>:2:8: error: expected string not found in input +CHECK: 1[[X]] + ^ +<stdin>:1:12: note: scanning from here +Firstababab1abab + ^ +<stdin>:1:12: note: with variable "X" equal to "ababab" +Firstababab1abab + ^ +)")); +} + } // namespace |