Add matcher for float literals.
Patch by Chris Gray! Thanks!
llvm-svn: 187232
diff --git a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersTest.cpp
index b6d21e6..fb17a40 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -1853,6 +1853,17 @@
EXPECT_TRUE(notMatches("int i = 10.0;", HasIntLiteral));
}
+TEST(Matcher, FloatLiterals) {
+ StatementMatcher HasFloatLiteral = floatLiteral();
+ EXPECT_TRUE(matches("float i = 10.0;", HasFloatLiteral));
+ EXPECT_TRUE(matches("float i = 10.0f;", HasFloatLiteral));
+ EXPECT_TRUE(matches("double i = 10.0;", HasFloatLiteral));
+ EXPECT_TRUE(matches("double i = 10.0L;", HasFloatLiteral));
+ EXPECT_TRUE(matches("double i = 1e10;", HasFloatLiteral));
+
+ EXPECT_TRUE(notMatches("float i = 10;", HasFloatLiteral));
+}
+
TEST(Matcher, NullPtrLiteral) {
EXPECT_TRUE(matches("int* i = nullptr;", nullPtrLiteralExpr()));
}