r195512 - Make the negative test more specific.

Samuel Benzaquen sbenza at google.com
Fri Nov 22 15:05:58 PST 2013


Author: sbenza
Date: Fri Nov 22 17:05:57 2013
New Revision: 195512

URL: http://llvm.org/viewvc/llvm-project?rev=195512&view=rev
Log:
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

Modified:
    cfe/trunk/unittests/ASTMatchers/Dynamic/RegistryTest.cpp

Modified: cfe/trunk/unittests/ASTMatchers/Dynamic/RegistryTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/Dynamic/RegistryTest.cpp?rev=195512&r1=195511&r2=195512&view=diff
==============================================================================
--- cfe/trunk/unittests/ASTMatchers/Dynamic/RegistryTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/Dynamic/RegistryTest.cpp Fri Nov 22 17:05:57 2013
@@ -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<Decl>();
+                           constructMatcher("hasName", std::string("Bar"))))
+          .getTypedMatcher<Decl>());
 
-  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) {





More information about the cfe-commits mailing list