summaryrefslogtreecommitdiffstats
path: root/googletest/src/gtest.cc
diff options
context:
space:
mode:
authorTanzinul Islam <tanzislam@users.noreply.github.com>2017-11-19 20:17:46 (GMT)
committerGitHub <noreply@github.com>2017-11-19 20:17:46 (GMT)
commit4ba3803f936a2f432e60841bc9358ea2f3a951eb (patch)
tree778e7ffd3bfda62cd3be3e01a2d0207d5ffe1d82 /googletest/src/gtest.cc
parent78b1ff074799c776f90a77203fcd7adc98e11736 (diff)
parentd175c8bf823e709d570772b038757fadf63bc632 (diff)
downloadgoogletest-4ba3803f936a2f432e60841bc9358ea2f3a951eb.zip
googletest-4ba3803f936a2f432e60841bc9358ea2f3a951eb.tar.gz
googletest-4ba3803f936a2f432e60841bc9358ea2f3a951eb.tar.bz2
Merge branch 'master' into fix_death_test_child_mingw_wer_issue1116
Diffstat (limited to 'googletest/src/gtest.cc')
-rw-r--r--googletest/src/gtest.cc56
1 files changed, 25 insertions, 31 deletions
diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
index 92eb524..1394941 100644
--- a/googletest/src/gtest.cc
+++ b/googletest/src/gtest.cc
@@ -137,7 +137,7 @@
// implementation. It must come before gtest-internal-inl.h is
// included, or there will be a compiler error. This trick is to
// prevent a user from accidentally including gtest-internal-inl.h in
-// his code.
+// their code.
#define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION_
@@ -1313,13 +1313,14 @@ AssertionResult EqFailure(const char* lhs_expression,
const std::string& rhs_value,
bool ignoring_case) {
Message msg;
- msg << " Expected: " << lhs_expression;
+ msg << "Expected equality of these values:";
+ msg << "\n " << lhs_expression;
if (lhs_value != lhs_expression) {
- msg << "\n Which is: " << lhs_value;
+ msg << "\n Which is: " << lhs_value;
}
- msg << "\nTo be equal to: " << rhs_expression;
+ msg << "\n " << rhs_expression;
if (rhs_value != rhs_expression) {
- msg << "\n Which is: " << rhs_value;
+ msg << "\n Which is: " << rhs_value;
}
if (ignoring_case) {
@@ -2569,10 +2570,10 @@ void ReportInvalidTestCaseType(const char* test_case_name,
<< "probably rename one of the classes to put the tests into different\n"
<< "test cases.";
- fprintf(stderr, "%s %s",
- FormatFileLocation(code_location.file.c_str(),
- code_location.line).c_str(),
- errors.GetString().c_str());
+ GTEST_LOG_(ERROR)
+ << FormatFileLocation(code_location.file.c_str(),
+ code_location.line)
+ << " " << errors.GetString();
}
#endif // GTEST_HAS_PARAM_TEST
@@ -3449,9 +3450,7 @@ class XmlUnitTestResultPrinter : public EmptyTestEventListener {
XmlUnitTestResultPrinter::XmlUnitTestResultPrinter(const char* output_file)
: output_file_(output_file) {
if (output_file_.c_str() == NULL || output_file_.empty()) {
- fprintf(stderr, "XML output file may not be null\n");
- fflush(stderr);
- exit(EXIT_FAILURE);
+ GTEST_LOG_(FATAL) << "XML output file may not be null";
}
}
@@ -3476,11 +3475,8 @@ void XmlUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test,
// 3. To interpret the meaning of errno in a thread-safe way,
// we need the strerror_r() function, which is not available on
// Windows.
- fprintf(stderr,
- "Unable to open file \"%s\"\n",
- output_file_.c_str());
- fflush(stderr);
- exit(EXIT_FAILURE);
+ GTEST_LOG_(FATAL) << "Unable to open file \""
+ << output_file_ << "\"";
}
std::stringstream stream;
PrintXmlUnitTest(&stream, unit_test);
@@ -4431,9 +4427,9 @@ void UnitTestImpl::ConfigureXmlOutput() {
listeners()->SetDefaultXmlGenerator(new XmlUnitTestResultPrinter(
UnitTestOptions::GetAbsolutePathToOutputFile().c_str()));
} else if (output_format != "") {
- printf("WARNING: unrecognized output format \"%s\" ignored.\n",
- output_format.c_str());
- fflush(stdout);
+ GTEST_LOG_(WARNING) << "WARNING: unrecognized output format \""
+ << output_format
+ << "\" ignored.";
}
}
@@ -4448,9 +4444,9 @@ void UnitTestImpl::ConfigureStreamingOutput() {
listeners()->Append(new StreamingListener(target.substr(0, pos),
target.substr(pos+1)));
} else {
- printf("WARNING: unrecognized streaming target \"%s\" ignored.\n",
- target.c_str());
- fflush(stdout);
+ GTEST_LOG_(WARNING) << "unrecognized streaming target \""
+ << target
+ << "\" ignored.";
}
}
}
@@ -4579,9 +4575,9 @@ static void TearDownEnvironment(Environment* env) { env->TearDown(); }
bool UnitTestImpl::RunAllTests() {
// Makes sure InitGoogleTest() was called.
if (!GTestIsInitialized()) {
- printf("%s",
- "\nThis test program did NOT call ::testing::InitGoogleTest "
- "before calling RUN_ALL_TESTS(). Please fix it.\n");
+ GTEST_LOG_(ERROR) <<
+ "\nThis test program did NOT call ::testing::InitGoogleTest "
+ "before calling RUN_ALL_TESTS(). Please fix it.";
return false;
}
@@ -5281,11 +5277,9 @@ bool ParseGoogleTestFlag(const char* const arg) {
void LoadFlagsFromFile(const std::string& path) {
FILE* flagfile = posix::FOpen(path.c_str(), "r");
if (!flagfile) {
- fprintf(stderr,
- "Unable to open file \"%s\"\n",
- GTEST_FLAG(flagfile).c_str());
- fflush(stderr);
- exit(EXIT_FAILURE);
+ GTEST_LOG_(FATAL) << "Unable to open file \""
+ << GTEST_FLAG(flagfile)
+ << "\"";
}
std::string contents(ReadEntireFile(flagfile));
posix::FClose(flagfile);