diff options
Diffstat (limited to 'clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp')
-rw-r--r-- | clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp b/clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp index fd7bbdde4a1..cda22ef3555 100644 --- a/clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp +++ b/clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp @@ -148,8 +148,8 @@ TEST(ParserTest, ParseMatcher) { const uint64_t ExpectedBar = Sema.expectMatcher("Bar"); const uint64_t ExpectedBaz = Sema.expectMatcher("Baz"); Sema.parse(" Foo ( Bar ( 17), Baz( \n \"B A,Z\") ) .bind( \"Yo!\") "); - for (size_t i = 0, e = Sema.Errors.size(); i != e; ++i) { - EXPECT_EQ("", Sema.Errors[i]); + for (const auto &E : Sema.Errors) { + EXPECT_EQ("", E); } EXPECT_NE(ExpectedFoo, ExpectedBar); @@ -181,6 +181,21 @@ TEST(ParserTest, ParseMatcher) { EXPECT_EQ("Yo!", Foo.BoundID); } +TEST(ParserTest, ParseComment) { + MockSema Sema; + const uint64_t ExpectedFoo = Sema.expectMatcher("Foo"); + Sema.parse(" Foo() # Bar() "); + for (const auto &E : Sema.Errors) { + EXPECT_EQ("", E); + } + + EXPECT_EQ(1ULL, Sema.Matchers.size()); + + Sema.parse("Foo(#) "); + + EXPECT_EQ("1:4: Error parsing matcher. Found end-of-code while looking for ')'.", Sema.Errors[1]); +} + using ast_matchers::internal::Matcher; Parser::NamedValueMap getTestNamedValues() { |