From: Saleem Abdulrasool Date: Sat, 25 Jan 2014 20:04:44 +0000 (+0000) Subject: unittests: explicit stringify StringRefs for conversion X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=92e49c2805398d4cbeb86f620ad407c153262562;p=clang unittests: explicit stringify StringRefs for conversion When clang is built outside of the LLVM tree (against a corresponding version), there is no definition providing for operator<<(std::ostream &, StringRef) which is required for the assertion routines in google-test tests. Avoid the compilation failure by explicitly stringifying the StringRef prior to use. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@200096 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/unittests/AST/DeclPrinterTest.cpp b/unittests/AST/DeclPrinterTest.cpp index ade55aaee3..66da386602 100644 --- a/unittests/AST/DeclPrinterTest.cpp +++ b/unittests/AST/DeclPrinterTest.cpp @@ -77,7 +77,8 @@ public: OwningPtr Factory(newFrontendActionFactory(&Finder)); if (!runToolOnCodeWithArgs(Factory->create(), Code, Args, FileName)) - return testing::AssertionFailure() << "Parsing error in \"" << Code << "\""; + return testing::AssertionFailure() + << "Parsing error in \"" << Code.str() << "\""; if (Printer.getNumFoundDecls() == 0) return testing::AssertionFailure() @@ -90,8 +91,8 @@ public: if (Printer.getPrinted() != ExpectedPrinted) return ::testing::AssertionFailure() - << "Expected \"" << ExpectedPrinted << "\", " - "got \"" << Printer.getPrinted() << "\""; + << "Expected \"" << ExpectedPrinted.str() << "\", " + "got \"" << Printer.getPrinted().str() << "\""; return ::testing::AssertionSuccess(); } diff --git a/unittests/AST/StmtPrinterTest.cpp b/unittests/AST/StmtPrinterTest.cpp index 473ee13b2a..eac36d65ee 100644 --- a/unittests/AST/StmtPrinterTest.cpp +++ b/unittests/AST/StmtPrinterTest.cpp @@ -76,7 +76,8 @@ public: OwningPtr Factory(newFrontendActionFactory(&Finder)); if (!runToolOnCodeWithArgs(Factory->create(), Code, Args)) - return testing::AssertionFailure() << "Parsing error in \"" << Code << "\""; + return testing::AssertionFailure() + << "Parsing error in \"" << Code.str() << "\""; if (Printer.getNumFoundStmts() == 0) return testing::AssertionFailure() @@ -89,8 +90,8 @@ public: if (Printer.getPrinted() != ExpectedPrinted) return ::testing::AssertionFailure() - << "Expected \"" << ExpectedPrinted << "\", " - "got \"" << Printer.getPrinted() << "\""; + << "Expected \"" << ExpectedPrinted.str() << "\", " + "got \"" << Printer.getPrinted().str() << "\""; return ::testing::AssertionSuccess(); } diff --git a/unittests/Tooling/CompilationDatabaseTest.cpp b/unittests/Tooling/CompilationDatabaseTest.cpp index c575dff209..4920d6d66b 100644 --- a/unittests/Tooling/CompilationDatabaseTest.cpp +++ b/unittests/Tooling/CompilationDatabaseTest.cpp @@ -24,7 +24,7 @@ static void expectFailure(StringRef JSONDatabase, StringRef Explanation) { std::string ErrorMessage; EXPECT_EQ(NULL, JSONCompilationDatabase::loadFromBuffer(JSONDatabase, ErrorMessage)) - << "Expected an error because of: " << Explanation; + << "Expected an error because of: " << Explanation.str(); } TEST(JSONCompilationDatabase, ErrsOnInvalidFormat) {