aboutsummaryrefslogtreecommitdiff
path: root/unittests/ASTMatchers/ASTMatchersTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'unittests/ASTMatchers/ASTMatchersTest.cpp')
-rw-r--r--unittests/ASTMatchers/ASTMatchersTest.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/unittests/ASTMatchers/ASTMatchersTest.cpp b/unittests/ASTMatchers/ASTMatchersTest.cpp
index 82f349fb0e..24438a2ee4 100644
--- a/unittests/ASTMatchers/ASTMatchersTest.cpp
+++ b/unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -1500,6 +1500,27 @@ TEST(Matcher, MatchesAccessSpecDecls) {
EXPECT_TRUE(notMatches("class C { int i; };", accessSpecDecl()));
}
+TEST(Matcher, MatchesVirtualMethod) {
+ EXPECT_TRUE(matches("class X { virtual int f(); };",
+ methodDecl(isVirtual(), hasName("::X::f"))));
+ EXPECT_TRUE(notMatches("class X { int f(); };",
+ methodDecl(isVirtual())));
+}
+
+TEST(Matcher, MatchesOverridingMethod) {
+ EXPECT_TRUE(matches("class X { virtual int f(); }; "
+ "class Y : public X { int f(); };",
+ methodDecl(isOverride(), hasName("::Y::f"))));
+ EXPECT_TRUE(notMatches("class X { virtual int f(); }; "
+ "class Y : public X { int f(); };",
+ methodDecl(isOverride(), hasName("::X::f"))));
+ EXPECT_TRUE(notMatches("class X { int f(); }; "
+ "class Y : public X { int f(); };",
+ methodDecl(isOverride())));
+ EXPECT_TRUE(notMatches("class X { int f(); int f(int); }; ",
+ methodDecl(isOverride())));
+}
+
TEST(Matcher, ConstructorCall) {
StatementMatcher Constructor = constructExpr();