diff options
Diffstat (limited to 'clang/unittests/AST/NamedDeclPrinterTest.cpp')
-rw-r--r-- | clang/unittests/AST/NamedDeclPrinterTest.cpp | 31 |
1 files changed, 6 insertions, 25 deletions
diff --git a/clang/unittests/AST/NamedDeclPrinterTest.cpp b/clang/unittests/AST/NamedDeclPrinterTest.cpp index 1042312..cd83372 100644 --- a/clang/unittests/AST/NamedDeclPrinterTest.cpp +++ b/clang/unittests/AST/NamedDeclPrinterTest.cpp @@ -15,6 +15,7 @@ // //===----------------------------------------------------------------------===// +#include "ASTPrint.h" #include "clang/AST/ASTContext.h" #include "clang/AST/Decl.h" #include "clang/AST/PrettyPrinter.h" @@ -66,31 +67,11 @@ public: const DeclarationMatcher &NodeMatch, StringRef ExpectedPrinted, StringRef FileName, std::function<void(llvm::raw_ostream &, const NamedDecl *)> Print) { - PrintMatch Printer(std::move(Print)); - MatchFinder Finder; - Finder.addMatcher(NodeMatch, &Printer); - std::unique_ptr<FrontendActionFactory> Factory = - newFrontendActionFactory(&Finder); - - if (!runToolOnCodeWithArgs(Factory->create(), Code, Args, FileName)) - return testing::AssertionFailure() - << "Parsing error in \"" << Code.str() << "\""; - - if (Printer.getNumFoundDecls() == 0) - return testing::AssertionFailure() - << "Matcher didn't find any named declarations"; - - if (Printer.getNumFoundDecls() > 1) - return testing::AssertionFailure() - << "Matcher should match only one named declaration " - "(found " << Printer.getNumFoundDecls() << ")"; - - if (Printer.getPrinted() != ExpectedPrinted) - return ::testing::AssertionFailure() - << "Expected \"" << ExpectedPrinted.str() << "\", " - "got \"" << Printer.getPrinted().str() << "\""; - - return ::testing::AssertionSuccess(); + return PrintedNodeMatches<NamedDecl>( + Code, Args, NodeMatch, ExpectedPrinted, FileName, + [Print](llvm::raw_ostream &Out, const ASTContext *Context, + const NamedDecl *ND, + PrintingPolicyAdjuster PolicyAdjuster) { Print(Out, ND); }); } ::testing::AssertionResult |