From: Samuel Benzaquen Date: Fri, 22 Nov 2013 23:05:57 +0000 (+0000) Subject: Make the negative test more specific. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d8e863b2d90bc644539eb55fe027e71a908b94ed;p=clang Make the negative test more specific. Summary: Make the negative test more specific. Otherwise it can accidentally match injected code. Reviewers: aaron.ballman CC: klimek, cfe-commits, revane Differential Revision: http://llvm-reviews.chandlerc.com/D2257 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195512 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/unittests/ASTMatchers/Dynamic/RegistryTest.cpp b/unittests/ASTMatchers/Dynamic/RegistryTest.cpp index dad9499ad4..8694c642cd 100644 --- a/unittests/ASTMatchers/Dynamic/RegistryTest.cpp +++ b/unittests/ASTMatchers/Dynamic/RegistryTest.cpp @@ -296,16 +296,16 @@ TEST_F(RegistryTest, VariadicOp) { EXPECT_TRUE(matches("class Bar{};", D)); EXPECT_FALSE(matches("class OtherBar{};", D)); - D = constructMatcher( - "recordDecl", + D = recordDecl( + has(fieldDecl(hasName("Foo"))), constructMatcher( "unless", constructMatcher("namedDecl", - constructMatcher("hasName", std::string("Bar"))))) - .getTypedMatcher(); + constructMatcher("hasName", std::string("Bar")))) + .getTypedMatcher()); - EXPECT_FALSE(matches("class Bar{};", D)); - EXPECT_TRUE(matches("class OtherBar{};", D)); + EXPECT_FALSE(matches("class Bar{ int Foo; };", D)); + EXPECT_TRUE(matches("class OtherBar{ int Foo; };", D)); } TEST_F(RegistryTest, Errors) {