summaryrefslogtreecommitdiff
path: root/unittests/Tooling/ToolingTest.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2012-12-02 13:20:44 +0000
committerDimitry Andric <dim@FreeBSD.org>2012-12-02 13:20:44 +0000
commit13cc256e404620c1de0cbcc4e43ce1e2dbbc4898 (patch)
tree2732d02d7d51218d6eed98ac7fcfc5b8794896b5 /unittests/Tooling/ToolingTest.cpp
parent657bc3d9848e3be92029b2416031340988cd0111 (diff)
Notes
Diffstat (limited to 'unittests/Tooling/ToolingTest.cpp')
-rw-r--r--unittests/Tooling/ToolingTest.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/unittests/Tooling/ToolingTest.cpp b/unittests/Tooling/ToolingTest.cpp
index fb3af2678c5f..d40c613dd059 100644
--- a/unittests/Tooling/ToolingTest.cpp
+++ b/unittests/Tooling/ToolingTest.cpp
@@ -130,5 +130,37 @@ TEST(ToolInvocation, TestMapVirtualFile) {
EXPECT_TRUE(Invocation.run());
}
+struct VerifyEndCallback : public EndOfSourceFileCallback {
+ VerifyEndCallback() : Called(0), Matched(false) {}
+ virtual void run() {
+ ++Called;
+ }
+ ASTConsumer *newASTConsumer() {
+ return new FindTopLevelDeclConsumer(&Matched);
+ }
+ unsigned Called;
+ bool Matched;
+};
+
+#if !defined(_WIN32)
+TEST(newFrontendActionFactory, InjectsEndOfSourceFileCallback) {
+ VerifyEndCallback EndCallback;
+
+ FixedCompilationDatabase Compilations("/", std::vector<std::string>());
+ std::vector<std::string> Sources;
+ Sources.push_back("/a.cc");
+ Sources.push_back("/b.cc");
+ ClangTool Tool(Compilations, Sources);
+
+ Tool.mapVirtualFile("/a.cc", "void a() {}");
+ Tool.mapVirtualFile("/b.cc", "void b() {}");
+
+ Tool.run(newFrontendActionFactory(&EndCallback, &EndCallback));
+
+ EXPECT_TRUE(EndCallback.Matched);
+ EXPECT_EQ(2u, EndCallback.Called);
+}
+#endif
+
} // end namespace tooling
} // end namespace clang