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.

llvm-svn: 200096
This commit is contained in:
Saleem Abdulrasool 2014-01-25 20:04:44 +00:00
parent b8d499fe2f
commit 8a8454bc31
3 changed files with 9 additions and 7 deletions

View File

@ -77,7 +77,8 @@ public:
OwningPtr<FrontendActionFactory> 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();
}

View File

@ -76,7 +76,8 @@ public:
OwningPtr<FrontendActionFactory> 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();
}

View File

@ -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) {