diff options
Diffstat (limited to 'unittests/Tooling/ToolingTest.cpp')
-rw-r--r-- | unittests/Tooling/ToolingTest.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/unittests/Tooling/ToolingTest.cpp b/unittests/Tooling/ToolingTest.cpp index fb3af2678c5f4..d40c613dd0592 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 |