diff options
author | dim <dim@FreeBSD.org> | 2012-08-15 20:02:54 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2012-08-15 20:02:54 +0000 |
commit | 554bcb69c2d785a011a30e7db87a36a87fe7db10 (patch) | |
tree | 9abb1a658a297776086f4e0dfa6ca533de02104e /unittests/Tooling/ToolingTest.cpp | |
parent | bb67ca86b31f67faee50bd10c3b036d65751745a (diff) | |
download | FreeBSD-src-554bcb69c2d785a011a30e7db87a36a87fe7db10.zip FreeBSD-src-554bcb69c2d785a011a30e7db87a36a87fe7db10.tar.gz |
Vendor import of clang trunk r161861:
http://llvm.org/svn/llvm-project/cfe/trunk@161861
Diffstat (limited to 'unittests/Tooling/ToolingTest.cpp')
-rw-r--r-- | unittests/Tooling/ToolingTest.cpp | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/unittests/Tooling/ToolingTest.cpp b/unittests/Tooling/ToolingTest.cpp index c7b2210..fb3af26 100644 --- a/unittests/Tooling/ToolingTest.cpp +++ b/unittests/Tooling/ToolingTest.cpp @@ -15,6 +15,7 @@ #include "clang/Tooling/CompilationDatabase.h" #include "clang/Tooling/Tooling.h" #include "gtest/gtest.h" +#include <string> namespace clang { namespace tooling { @@ -52,11 +53,16 @@ class FindTopLevelDeclConsumer : public clang::ASTConsumer { }; } // end namespace -TEST(runToolOnCode, FindsTopLevelDeclOnEmptyCode) { +TEST(runToolOnCode, FindsNoTopLevelDeclOnEmptyCode) { bool FoundTopLevelDecl = false; EXPECT_TRUE(runToolOnCode( new TestAction(new FindTopLevelDeclConsumer(&FoundTopLevelDecl)), "")); +#if !defined(_MSC_VER) + EXPECT_FALSE(FoundTopLevelDecl); +#else + // FIXME: LangOpts.MicrosoftExt appends "class type_info;" EXPECT_TRUE(FoundTopLevelDecl); +#endif } namespace { @@ -98,7 +104,9 @@ TEST(newFrontendActionFactory, CreatesFrontendActionFactoryFromType) { } struct IndependentFrontendActionCreator { - FrontendAction *newFrontendAction() { return new SyntaxOnlyAction; } + ASTConsumer *newASTConsumer() { + return new FindTopLevelDeclConsumer(NULL); + } }; TEST(newFrontendActionFactory, CreatesFrontendActionFactoryFromFactoryType) { @@ -109,5 +117,18 @@ TEST(newFrontendActionFactory, CreatesFrontendActionFactoryFromFactoryType) { EXPECT_TRUE(Action.get() != NULL); } +TEST(ToolInvocation, TestMapVirtualFile) { + clang::FileManager Files((clang::FileSystemOptions())); + std::vector<std::string> Args; + Args.push_back("tool-executable"); + Args.push_back("-Idef"); + Args.push_back("-fsyntax-only"); + Args.push_back("test.cpp"); + clang::tooling::ToolInvocation Invocation(Args, new SyntaxOnlyAction, &Files); + Invocation.mapVirtualFile("test.cpp", "#include <abc>\n"); + Invocation.mapVirtualFile("def/abc", "\n"); + EXPECT_TRUE(Invocation.run()); +} + } // end namespace tooling } // end namespace clang |