Unverified Commit 4ba3803f authored by Tanzinul Islam's avatar Tanzinul Islam Committed by GitHub
Browse files

Merge branch 'master' into fix_death_test_child_mingw_wer_issue1116

parents 78b1ff07 d175c8bf
...@@ -1263,7 +1263,7 @@ known as <i>abstract tests</i>. As an example of its application, when you ...@@ -1263,7 +1263,7 @@ known as <i>abstract tests</i>. As an example of its application, when you
are designing an interface you can write a standard suite of abstract are designing an interface you can write a standard suite of abstract
tests (perhaps using a factory function as the test parameter) that tests (perhaps using a factory function as the test parameter) that
all implementations of the interface are expected to pass. When all implementations of the interface are expected to pass. When
someone implements the interface, he can instantiate your suite to get someone implements the interface, they can instantiate your suite to get
all the interface-conformance tests for free. all the interface-conformance tests for free.
To define abstract tests, you should organize your code like this: To define abstract tests, you should organize your code like this:
......
...@@ -102,9 +102,9 @@ Then every user of your machine can write tests without ...@@ -102,9 +102,9 @@ Then every user of your machine can write tests without
recompiling Google Test. recompiling Google Test.
This seemed like a good idea, but it has a This seemed like a good idea, but it has a
got-cha: every user needs to compile his tests using the _same_ compiler got-cha: every user needs to compile their tests using the _same_ compiler
flags used to compile the installed Google Test libraries; otherwise flags used to compile the installed Google Test libraries; otherwise
he may run into undefined behaviors (i.e. the tests can behave they may run into undefined behaviors (i.e. the tests can behave
strangely and may even crash for no obvious reasons). strangely and may even crash for no obvious reasons).
Why? Because C++ has this thing called the One-Definition Rule: if Why? Because C++ has this thing called the One-Definition Rule: if
...@@ -494,7 +494,7 @@ EXPECT_PRED1(IsPositive, 5); ...@@ -494,7 +494,7 @@ EXPECT_PRED1(IsPositive, 5);
However, this will work: However, this will work:
``` cpp ``` cpp
EXPECT_PRED1(*static_cast<bool (*)(int)>*(IsPositive), 5); EXPECT_PRED1(static_cast<bool (*)(int)>(IsPositive), 5);
``` ```
(The stuff inside the angled brackets for the `static_cast` operator is the (The stuff inside the angled brackets for the `static_cast` operator is the
...@@ -512,14 +512,14 @@ bool IsNegative(T x) { ...@@ -512,14 +512,14 @@ bool IsNegative(T x) {
you can use it in a predicate assertion like this: you can use it in a predicate assertion like this:
``` cpp ``` cpp
ASSERT_PRED1(IsNegative*<int>*, -5); ASSERT_PRED1(IsNegative<int>, -5);
``` ```
Things are more interesting if your template has more than one parameters. The Things are more interesting if your template has more than one parameters. The
following won't compile: following won't compile:
``` cpp ``` cpp
ASSERT_PRED2(*GreaterThan<int, int>*, 5, 0); ASSERT_PRED2(GreaterThan<int, int>, 5, 0);
``` ```
...@@ -528,7 +528,7 @@ which is one more than expected. The workaround is to wrap the predicate ...@@ -528,7 +528,7 @@ which is one more than expected. The workaround is to wrap the predicate
function in parentheses: function in parentheses:
``` cpp ``` cpp
ASSERT_PRED2(*(GreaterThan<int, int>)*, 5, 0); ASSERT_PRED2((GreaterThan<int, int>), 5, 0);
``` ```
......
...@@ -137,7 +137,8 @@ class TypeWithoutFormatter { ...@@ -137,7 +137,8 @@ class TypeWithoutFormatter {
public: public:
// This default version is called when kTypeKind is kOtherType. // This default version is called when kTypeKind is kOtherType.
static void PrintValue(const T& value, ::std::ostream* os) { static void PrintValue(const T& value, ::std::ostream* os) {
PrintBytesInObjectTo(reinterpret_cast<const unsigned char*>(&value), PrintBytesInObjectTo(static_cast<const unsigned char*>(
reinterpret_cast<const void *>(&value)),
sizeof(value), os); sizeof(value), os);
} }
}; };
......
...@@ -325,7 +325,7 @@ ...@@ -325,7 +325,7 @@
// -std={c,gnu}++{0x,11} is passed. The C++11 standard specifies a // -std={c,gnu}++{0x,11} is passed. The C++11 standard specifies a
// value for __cplusplus, and recent versions of clang, gcc, and // value for __cplusplus, and recent versions of clang, gcc, and
// probably other compilers set that too in C++11 mode. // probably other compilers set that too in C++11 mode.
# if __GXX_EXPERIMENTAL_CXX0X__ || __cplusplus >= 201103L # if __GXX_EXPERIMENTAL_CXX0X__ || __cplusplus >= 201103L || _MSC_VER >= 1900
// Compiling in at least C++11 mode. // Compiling in at least C++11 mode.
# define GTEST_LANG_CXX11 1 # define GTEST_LANG_CXX11 1
# else # else
...@@ -357,12 +357,16 @@ ...@@ -357,12 +357,16 @@
#if GTEST_STDLIB_CXX11 #if GTEST_STDLIB_CXX11
# define GTEST_HAS_STD_BEGIN_AND_END_ 1 # define GTEST_HAS_STD_BEGIN_AND_END_ 1
# define GTEST_HAS_STD_FORWARD_LIST_ 1 # define GTEST_HAS_STD_FORWARD_LIST_ 1
# if !defined(_MSC_VER) || (_MSC_FULL_VER >= 190023824) // works only with VS2015U2 and better
# define GTEST_HAS_STD_FUNCTION_ 1 # define GTEST_HAS_STD_FUNCTION_ 1
# endif
# define GTEST_HAS_STD_INITIALIZER_LIST_ 1 # define GTEST_HAS_STD_INITIALIZER_LIST_ 1
# define GTEST_HAS_STD_MOVE_ 1 # define GTEST_HAS_STD_MOVE_ 1
# define GTEST_HAS_STD_SHARED_PTR_ 1 # define GTEST_HAS_STD_SHARED_PTR_ 1
# define GTEST_HAS_STD_TYPE_TRAITS_ 1 # define GTEST_HAS_STD_TYPE_TRAITS_ 1
# define GTEST_HAS_STD_UNIQUE_PTR_ 1 # define GTEST_HAS_STD_UNIQUE_PTR_ 1
# define GTEST_HAS_UNORDERED_MAP_ 1
# define GTEST_HAS_UNORDERED_SET_ 1
#endif #endif
// C++11 specifies that <tuple> provides std::tuple. // C++11 specifies that <tuple> provides std::tuple.
...@@ -660,7 +664,8 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; ...@@ -660,7 +664,8 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
// support TR1 tuple. libc++ only provides std::tuple, in C++11 mode, // support TR1 tuple. libc++ only provides std::tuple, in C++11 mode,
// and it can be used with some compilers that define __GNUC__. // and it can be used with some compilers that define __GNUC__.
# if (defined(__GNUC__) && !defined(__CUDACC__) && (GTEST_GCC_VER_ >= 40000) \ # if (defined(__GNUC__) && !defined(__CUDACC__) && (GTEST_GCC_VER_ >= 40000) \
&& !GTEST_OS_QNX && !defined(_LIBCPP_VERSION)) || _MSC_VER >= 1600 && !GTEST_OS_QNX && !defined(_LIBCPP_VERSION)) \
|| (_MSC_VER >= 1600 && _MSC_VER < 1900)
# define GTEST_ENV_HAS_TR1_TUPLE_ 1 # define GTEST_ENV_HAS_TR1_TUPLE_ 1
# endif # endif
...@@ -741,7 +746,7 @@ using ::std::tuple_size; ...@@ -741,7 +746,7 @@ using ::std::tuple_size;
# define _TR1_FUNCTIONAL 1 # define _TR1_FUNCTIONAL 1
# include <tr1/tuple> # include <tr1/tuple>
# undef _TR1_FUNCTIONAL // Allows the user to #include # undef _TR1_FUNCTIONAL // Allows the user to #include
// <tr1/functional> if he chooses to. // <tr1/functional> if they choose to.
# else # else
# include <tr1/tuple> // NOLINT # include <tr1/tuple> // NOLINT
# endif // !GTEST_HAS_RTTI && GTEST_GCC_VER_ < 40302 # endif // !GTEST_HAS_RTTI && GTEST_GCC_VER_ < 40302
...@@ -2061,7 +2066,7 @@ extern "C" inline void DeleteThreadLocalValue(void* value_holder) { ...@@ -2061,7 +2066,7 @@ extern "C" inline void DeleteThreadLocalValue(void* value_holder) {
// Implements thread-local storage on pthreads-based systems. // Implements thread-local storage on pthreads-based systems.
template <typename T> template <typename T>
class ThreadLocal { class GTEST_API_ ThreadLocal {
public: public:
ThreadLocal() ThreadLocal()
: key_(CreateKey()), default_factory_(new DefaultValueHolderFactory()) {} : key_(CreateKey()), default_factory_(new DefaultValueHolderFactory()) {}
...@@ -2193,7 +2198,7 @@ class GTestMutexLock { ...@@ -2193,7 +2198,7 @@ class GTestMutexLock {
typedef GTestMutexLock MutexLock; typedef GTestMutexLock MutexLock;
template <typename T> template <typename T>
class ThreadLocal { class GTEST_API_ ThreadLocal {
public: public:
ThreadLocal() : value_() {} ThreadLocal() : value_() {}
explicit ThreadLocal(const T& value) : value_(value) {} explicit ThreadLocal(const T& value) : value_(value) {}
...@@ -2591,10 +2596,6 @@ std::string StringFromGTestEnv(const char* flag, const char* default_val); ...@@ -2591,10 +2596,6 @@ std::string StringFromGTestEnv(const char* flag, const char* default_val);
} // namespace internal } // namespace internal
// Returns a path to temporary directory.
// Tries to determine an appropriate directory for the platform.
GTEST_API_ std::string TempDir();
} // namespace testing } // namespace testing
#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_ #endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
...@@ -38,7 +38,6 @@ ...@@ -38,7 +38,6 @@
using ::testing::EmptyTestEventListener; using ::testing::EmptyTestEventListener;
using ::testing::InitGoogleTest; using ::testing::InitGoogleTest;
using ::testing::Test; using ::testing::Test;
using ::testing::TestCase;
using ::testing::TestEventListeners; using ::testing::TestEventListeners;
using ::testing::TestInfo; using ::testing::TestInfo;
using ::testing::TestPartResult; using ::testing::TestPartResult;
......
...@@ -137,7 +137,7 @@ ...@@ -137,7 +137,7 @@
// implementation. It must come before gtest-internal-inl.h is // implementation. It must come before gtest-internal-inl.h is
// included, or there will be a compiler error. This trick is to // included, or there will be a compiler error. This trick is to
// prevent a user from accidentally including gtest-internal-inl.h in // prevent a user from accidentally including gtest-internal-inl.h in
// his code. // their code.
#define GTEST_IMPLEMENTATION_ 1 #define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h" #include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION_ #undef GTEST_IMPLEMENTATION_
...@@ -1313,11 +1313,12 @@ AssertionResult EqFailure(const char* lhs_expression, ...@@ -1313,11 +1313,12 @@ AssertionResult EqFailure(const char* lhs_expression,
const std::string& rhs_value, const std::string& rhs_value,
bool ignoring_case) { bool ignoring_case) {
Message msg; Message msg;
msg << " Expected: " << lhs_expression; msg << "Expected equality of these values:";
msg << "\n " << lhs_expression;
if (lhs_value != 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) { if (rhs_value != rhs_expression) {
msg << "\n Which is: " << rhs_value; msg << "\n Which is: " << rhs_value;
} }
...@@ -2569,10 +2570,10 @@ void ReportInvalidTestCaseType(const char* test_case_name, ...@@ -2569,10 +2570,10 @@ void ReportInvalidTestCaseType(const char* test_case_name,
<< "probably rename one of the classes to put the tests into different\n" << "probably rename one of the classes to put the tests into different\n"
<< "test cases."; << "test cases.";
fprintf(stderr, "%s %s", GTEST_LOG_(ERROR)
FormatFileLocation(code_location.file.c_str(), << FormatFileLocation(code_location.file.c_str(),
code_location.line).c_str(), code_location.line)
errors.GetString().c_str()); << " " << errors.GetString();
} }
#endif // GTEST_HAS_PARAM_TEST #endif // GTEST_HAS_PARAM_TEST
...@@ -3449,9 +3450,7 @@ class XmlUnitTestResultPrinter : public EmptyTestEventListener { ...@@ -3449,9 +3450,7 @@ class XmlUnitTestResultPrinter : public EmptyTestEventListener {
XmlUnitTestResultPrinter::XmlUnitTestResultPrinter(const char* output_file) XmlUnitTestResultPrinter::XmlUnitTestResultPrinter(const char* output_file)
: output_file_(output_file) { : output_file_(output_file) {
if (output_file_.c_str() == NULL || output_file_.empty()) { if (output_file_.c_str() == NULL || output_file_.empty()) {
fprintf(stderr, "XML output file may not be null\n"); GTEST_LOG_(FATAL) << "XML output file may not be null";
fflush(stderr);
exit(EXIT_FAILURE);
} }
} }
...@@ -3476,11 +3475,8 @@ void XmlUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test, ...@@ -3476,11 +3475,8 @@ void XmlUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test,
// 3. To interpret the meaning of errno in a thread-safe way, // 3. To interpret the meaning of errno in a thread-safe way,
// we need the strerror_r() function, which is not available on // we need the strerror_r() function, which is not available on
// Windows. // Windows.
fprintf(stderr, GTEST_LOG_(FATAL) << "Unable to open file \""
"Unable to open file \"%s\"\n", << output_file_ << "\"";
output_file_.c_str());
fflush(stderr);
exit(EXIT_FAILURE);
} }
std::stringstream stream; std::stringstream stream;
PrintXmlUnitTest(&stream, unit_test); PrintXmlUnitTest(&stream, unit_test);
...@@ -4431,9 +4427,9 @@ void UnitTestImpl::ConfigureXmlOutput() { ...@@ -4431,9 +4427,9 @@ void UnitTestImpl::ConfigureXmlOutput() {
listeners()->SetDefaultXmlGenerator(new XmlUnitTestResultPrinter( listeners()->SetDefaultXmlGenerator(new XmlUnitTestResultPrinter(
UnitTestOptions::GetAbsolutePathToOutputFile().c_str())); UnitTestOptions::GetAbsolutePathToOutputFile().c_str()));
} else if (output_format != "") { } else if (output_format != "") {
printf("WARNING: unrecognized output format \"%s\" ignored.\n", GTEST_LOG_(WARNING) << "WARNING: unrecognized output format \""
output_format.c_str()); << output_format
fflush(stdout); << "\" ignored.";
} }
} }
...@@ -4448,9 +4444,9 @@ void UnitTestImpl::ConfigureStreamingOutput() { ...@@ -4448,9 +4444,9 @@ void UnitTestImpl::ConfigureStreamingOutput() {
listeners()->Append(new StreamingListener(target.substr(0, pos), listeners()->Append(new StreamingListener(target.substr(0, pos),
target.substr(pos+1))); target.substr(pos+1)));
} else { } else {
printf("WARNING: unrecognized streaming target \"%s\" ignored.\n", GTEST_LOG_(WARNING) << "unrecognized streaming target \""
target.c_str()); << target
fflush(stdout); << "\" ignored.";
} }
} }
} }
...@@ -4579,9 +4575,9 @@ static void TearDownEnvironment(Environment* env) { env->TearDown(); } ...@@ -4579,9 +4575,9 @@ static void TearDownEnvironment(Environment* env) { env->TearDown(); }
bool UnitTestImpl::RunAllTests() { bool UnitTestImpl::RunAllTests() {
// Makes sure InitGoogleTest() was called. // Makes sure InitGoogleTest() was called.
if (!GTestIsInitialized()) { if (!GTestIsInitialized()) {
printf("%s", GTEST_LOG_(ERROR) <<
"\nThis test program did NOT call ::testing::InitGoogleTest " "\nThis test program did NOT call ::testing::InitGoogleTest "
"before calling RUN_ALL_TESTS(). Please fix it.\n"); "before calling RUN_ALL_TESTS(). Please fix it.";
return false; return false;
} }
...@@ -5281,11 +5277,9 @@ bool ParseGoogleTestFlag(const char* const arg) { ...@@ -5281,11 +5277,9 @@ bool ParseGoogleTestFlag(const char* const arg) {
void LoadFlagsFromFile(const std::string& path) { void LoadFlagsFromFile(const std::string& path) {
FILE* flagfile = posix::FOpen(path.c_str(), "r"); FILE* flagfile = posix::FOpen(path.c_str(), "r");
if (!flagfile) { if (!flagfile) {
fprintf(stderr, GTEST_LOG_(FATAL) << "Unable to open file \""
"Unable to open file \"%s\"\n", << GTEST_FLAG(flagfile)
GTEST_FLAG(flagfile).c_str()); << "\"";
fflush(stderr);
exit(EXIT_FAILURE);
} }
std::string contents(ReadEntireFile(flagfile)); std::string contents(ReadEntireFile(flagfile));
posix::FClose(flagfile); posix::FClose(flagfile);
......
...@@ -61,7 +61,7 @@ using testing::internal::AlwaysTrue; ...@@ -61,7 +61,7 @@ using testing::internal::AlwaysTrue;
// implementation. It must come before gtest-internal-inl.h is // implementation. It must come before gtest-internal-inl.h is
// included, or there will be a compiler error. This trick is to // included, or there will be a compiler error. This trick is to
// prevent a user from accidentally including gtest-internal-inl.h in // prevent a user from accidentally including gtest-internal-inl.h in
// his code. // their code.
# define GTEST_IMPLEMENTATION_ 1 # define GTEST_IMPLEMENTATION_ 1
# include "src/gtest-internal-inl.h" # include "src/gtest-internal-inl.h"
# undef GTEST_IMPLEMENTATION_ # undef GTEST_IMPLEMENTATION_
......
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
// implementation. It must come before gtest-internal-inl.h is // implementation. It must come before gtest-internal-inl.h is
// included, or there will be a compiler error. This trick is to // included, or there will be a compiler error. This trick is to
// prevent a user from accidentally including gtest-internal-inl.h in // prevent a user from accidentally including gtest-internal-inl.h in
// his code. // their code.
#define GTEST_IMPLEMENTATION_ 1 #define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h" #include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION_ #undef GTEST_IMPLEMENTATION_
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
// implementation. It must come before gtest-internal-inl.h is // implementation. It must come before gtest-internal-inl.h is
// included, or there will be a compiler error. This trick is to // included, or there will be a compiler error. This trick is to
// prevent a user from accidentally including gtest-internal-inl.h in // prevent a user from accidentally including gtest-internal-inl.h in
// his code. // their code.
#define GTEST_IMPLEMENTATION_ 1 #define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h" #include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION_ #undef GTEST_IMPLEMENTATION_
......
...@@ -857,8 +857,8 @@ TEST_P(CustomLambdaNamingTest, CustomTestNames) {} ...@@ -857,8 +857,8 @@ TEST_P(CustomLambdaNamingTest, CustomTestNames) {}
INSTANTIATE_TEST_CASE_P(CustomParamNameLambda, INSTANTIATE_TEST_CASE_P(CustomParamNameLambda,
CustomLambdaNamingTest, CustomLambdaNamingTest,
Values(std::string("LambdaName")), Values(std::string("LambdaName")),
[](const ::testing::TestParamInfo<std::string>& info) { [](const ::testing::TestParamInfo<std::string>& tpinfo) {
return info.param; return tpinfo.param;
}); });
#endif // GTEST_LANG_CXX11 #endif // GTEST_LANG_CXX11
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
// implementation. It must come before gtest-internal-inl.h is // implementation. It must come before gtest-internal-inl.h is
// included, or there will be a compiler error. This trick is to // included, or there will be a compiler error. This trick is to
// prevent a user from accidentally including gtest-internal-inl.h in // prevent a user from accidentally including gtest-internal-inl.h in
// his code. // their code.
#define GTEST_IMPLEMENTATION_ 1 #define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h" #include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION_ #undef GTEST_IMPLEMENTATION_
......
...@@ -51,10 +51,15 @@ ...@@ -51,10 +51,15 @@
#include "gtest/gtest.h" #include "gtest/gtest.h"
// hash_map and hash_set are available under Visual C++, or on Linux. // hash_map and hash_set are available under Visual C++, or on Linux.
#if GTEST_HAS_HASH_MAP_ #if GTEST_HAS_UNORDERED_MAP_
# include <unordered_map> // NOLINT
#elif GTEST_HAS_HASH_MAP_
# include <hash_map> // NOLINT # include <hash_map> // NOLINT
#endif // GTEST_HAS_HASH_MAP_ #endif // GTEST_HAS_HASH_MAP_
#if GTEST_HAS_HASH_SET_
#if GTEST_HAS_UNORDERED_SET_
# include <unordered_set> // NOLINT
#elif GTEST_HAS_HASH_SET_
# include <hash_set> // NOLINT # include <hash_set> // NOLINT
#endif // GTEST_HAS_HASH_SET_ #endif // GTEST_HAS_HASH_SET_
...@@ -239,21 +244,47 @@ using ::testing::internal::UniversalTersePrintTupleFieldsToStrings; ...@@ -239,21 +244,47 @@ using ::testing::internal::UniversalTersePrintTupleFieldsToStrings;
#endif #endif
using ::testing::internal::string; using ::testing::internal::string;
#if GTEST_HAS_HASH_MAP_
// The hash_* classes are not part of the C++ standard. STLport // The hash_* classes are not part of the C++ standard. STLport
// defines them in namespace std. MSVC defines them in ::stdext. GCC // defines them in namespace std. MSVC defines them in ::stdext. GCC
// defines them in ::. // defines them in ::.
#if GTEST_HAS_UNORDERED_MAP_
#define GTEST_HAS_HASH_MAP_ 1
template<class Key, class T>
using hash_map = ::std::unordered_map<Key, T>;
template<class Key, class T>
using hash_multimap = ::std::unordered_multimap<Key, T>;
#elif GTEST_HAS_HASH_MAP_
#ifdef _STLP_HASH_MAP // We got <hash_map> from STLport. #ifdef _STLP_HASH_MAP // We got <hash_map> from STLport.
using ::std::hash_map; using ::std::hash_map;
using ::std::hash_set;
using ::std::hash_multimap; using ::std::hash_multimap;
using ::std::hash_multiset;
#elif _MSC_VER #elif _MSC_VER
using ::stdext::hash_map; using ::stdext::hash_map;
using ::stdext::hash_set;
using ::stdext::hash_multimap; using ::stdext::hash_multimap;
#endif
#endif
#if GTEST_HAS_UNORDERED_SET_
#define GTEST_HAS_HASH_SET_ 1
template<class Key>
using hash_set = ::std::unordered_set<Key>;
template<class Key>
using hash_multiset = ::std::unordered_multiset<Key>;
#elif GTEST_HAS_HASH_SET_
#ifdef _STLP_HASH_MAP // We got <hash_map> from STLport.
using ::std::hash_set;
using ::std::hash_multiset;
#elif _MSC_VER
using ::stdext::hash_set;
using ::stdext::hash_multiset; using ::stdext::hash_multiset;
#endif #endif
#endif #endif
// Prints a value to a string using the universal value printer. This // Prints a value to a string using the universal value printer. This
...@@ -1061,8 +1092,8 @@ TEST(PrintTr1TupleTest, VariousSizes) { ...@@ -1061,8 +1092,8 @@ TEST(PrintTr1TupleTest, VariousSizes) {
::std::tr1::tuple<bool, char, short, testing::internal::Int32, // NOLINT ::std::tr1::tuple<bool, char, short, testing::internal::Int32, // NOLINT
testing::internal::Int64, float, double, const char*, void*, testing::internal::Int64, float, double, const char*, void*,
std::string> std::string>
t10(false, 'a', 3, 4, 5, 1.5F, -2.5, str, ImplicitCast_<void*>(NULL), t10(false, 'a', static_cast<short>(3), 4, 5, 1.5F, -2.5, str,
"10"); ImplicitCast_<void*>(NULL), "10");
EXPECT_EQ("(false, 'a' (97, 0x61), 3, 4, 5, 1.5, -2.5, " + PrintPointer(str) + EXPECT_EQ("(false, 'a' (97, 0x61), 3, 4, 5, 1.5, -2.5, " + PrintPointer(str) +
" pointing to \"8\", NULL, \"10\")", " pointing to \"8\", NULL, \"10\")",
Print(t10)); Print(t10));
...@@ -1121,8 +1152,8 @@ TEST(PrintStdTupleTest, VariousSizes) { ...@@ -1121,8 +1152,8 @@ TEST(PrintStdTupleTest, VariousSizes) {
::std::tuple<bool, char, short, testing::internal::Int32, // NOLINT ::std::tuple<bool, char, short, testing::internal::Int32, // NOLINT
testing::internal::Int64, float, double, const char*, void*, testing::internal::Int64, float, double, const char*, void*,
std::string> std::string>
t10(false, 'a', 3, 4, 5, 1.5F, -2.5, str, ImplicitCast_<void*>(NULL), t10(false, 'a', static_cast<short>(3), 4, 5, 1.5F, -2.5, str,
"10"); ImplicitCast_<void*>(NULL), "10");
EXPECT_EQ("(false, 'a' (97, 0x61), 3, 4, 5, 1.5, -2.5, " + PrintPointer(str) + EXPECT_EQ("(false, 'a' (97, 0x61), 3, 4, 5, 1.5, -2.5, " + PrintPointer(str) +
" pointing to \"8\", NULL, \"10\")", " pointing to \"8\", NULL, \"10\")",
Print(t10)); Print(t10));
......
...@@ -138,7 +138,7 @@ TEST_F(CxxExceptionInConstructorTest, ThrowsExceptionInConstructor) { ...@@ -138,7 +138,7 @@ TEST_F(CxxExceptionInConstructorTest, ThrowsExceptionInConstructor) {
} }
// Exceptions in destructors are not supported in C++11. // Exceptions in destructors are not supported in C++11.
#if !defined(__GXX_EXPERIMENTAL_CXX0X__) && __cplusplus < 201103L && _MSC_VER < 1900 #if !GTEST_LANG_CXX11
class CxxExceptionInDestructorTest : public Test { class CxxExceptionInDestructorTest : public Test {
public: public:
static void TearDownTestCase() { static void TearDownTestCase() {
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
// implementation. It must come before gtest-internal-inl.h is // implementation. It must come before gtest-internal-inl.h is
// included, or there will be a compiler error. This trick is to // included, or there will be a compiler error. This trick is to
// prevent a user from accidentally including gtest-internal-inl.h in // prevent a user from accidentally including gtest-internal-inl.h in
// his code. // their code.
#define GTEST_IMPLEMENTATION_ 1 #define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h" #include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION_ #undef GTEST_IMPLEMENTATION_
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
// implementation. It must come before gtest-internal-inl.h is // implementation. It must come before gtest-internal-inl.h is
// included, or there will be a compiler error. This trick is to // included, or there will be a compiler error. This trick is to
// prevent a user from accidentally including gtest-internal-inl.h in // prevent a user from accidentally including gtest-internal-inl.h in
// his code. // their code.
#define GTEST_IMPLEMENTATION_ 1 #define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h" #include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION_ #undef GTEST_IMPLEMENTATION_
......
...@@ -5,8 +5,9 @@ Value of: false ...@@ -5,8 +5,9 @@ Value of: false
Actual: false Actual: false
Expected: true Expected: true
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Expected: 2 Expected equality of these values:
To be equal to: 3 2
3
[==========] Running 66 tests from 29 test cases. [==========] Running 66 tests from 29 test cases.
[----------] Global test environment set-up. [----------] Global test environment set-up.
FooEnvironment::SetUp() called. FooEnvironment::SetUp() called.
...@@ -34,21 +35,24 @@ BarEnvironment::SetUp() called. ...@@ -34,21 +35,24 @@ BarEnvironment::SetUp() called.
[----------] 2 tests from NonfatalFailureTest [----------] 2 tests from NonfatalFailureTest
[ RUN ] NonfatalFailureTest.EscapesStringOperands [ RUN ] NonfatalFailureTest.EscapesStringOperands
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Expected: kGoldenString Expected equality of these values:
kGoldenString
Which is: "\"Line" Which is: "\"Line"
To be equal to: actual actual
Which is: "actual \"string\"" Which is: "actual \"string\""
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Expected: golden Expected equality of these values:
golden
Which is: "\"Line" Which is: "\"Line"
To be equal to: actual actual
Which is: "actual \"string\"" Which is: "actual \"string\""
[ FAILED ] NonfatalFailureTest.EscapesStringOperands [ FAILED ] NonfatalFailureTest.EscapesStringOperands
[ RUN ] NonfatalFailureTest.DiffForLongStrings [ RUN ] NonfatalFailureTest.DiffForLongStrings
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Expected: golden_str Expected equality of these values:
golden_str
Which is: "\"Line\0 1\"\nLine 2" Which is: "\"Line\0 1\"\nLine 2"
To be equal to: "Line 2" "Line 2"
With diff: With diff:
@@ -1,2 @@ @@ -1,2 @@
-\"Line\0 1\" -\"Line\0 1\"
...@@ -59,15 +63,17 @@ With diff: ...@@ -59,15 +63,17 @@ With diff:
[ RUN ] FatalFailureTest.FatalFailureInSubroutine [ RUN ] FatalFailureTest.FatalFailureInSubroutine
(expecting a failure that x should be 1) (expecting a failure that x should be 1)
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Expected: 1 Expected equality of these values:
To be equal to: x 1
x
Which is: 2 Which is: 2
[ FAILED ] FatalFailureTest.FatalFailureInSubroutine [ FAILED ] FatalFailureTest.FatalFailureInSubroutine
[ RUN ] FatalFailureTest.FatalFailureInNestedSubroutine [ RUN ] FatalFailureTest.FatalFailureInNestedSubroutine
(expecting a failure that x should be 1) (expecting a failure that x should be 1)
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Expected: 1 Expected equality of these values:
To be equal to: x 1
x
Which is: 2 Which is: 2
[ FAILED ] FatalFailureTest.FatalFailureInNestedSubroutine [ FAILED ] FatalFailureTest.FatalFailureInNestedSubroutine
[ RUN ] FatalFailureTest.NonfatalFailureInSubroutine [ RUN ] FatalFailureTest.NonfatalFailureInSubroutine
...@@ -107,14 +113,16 @@ This failure is expected, and shouldn't have a trace. ...@@ -107,14 +113,16 @@ This failure is expected, and shouldn't have a trace.
[ RUN ] SCOPED_TRACETest.WorksInLoop [ RUN ] SCOPED_TRACETest.WorksInLoop
(expected to fail) (expected to fail)
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Expected: 2 Expected equality of these values:
To be equal to: n 2
n
Which is: 1 Which is: 1
Google Test trace: Google Test trace:
gtest_output_test_.cc:#: i = 1 gtest_output_test_.cc:#: i = 1
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Expected: 1 Expected equality of these values:
To be equal to: n 1
n
Which is: 2 Which is: 2
Google Test trace: Google Test trace:
gtest_output_test_.cc:#: i = 2 gtest_output_test_.cc:#: i = 2
...@@ -122,14 +130,16 @@ gtest_output_test_.cc:#: i = 2 ...@@ -122,14 +130,16 @@ gtest_output_test_.cc:#: i = 2
[ RUN ] SCOPED_TRACETest.WorksInSubroutine [ RUN ] SCOPED_TRACETest.WorksInSubroutine
(expected to fail) (expected to fail)
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Expected: 2 Expected equality of these values:
To be equal to: n 2
n
Which is: 1 Which is: 1
Google Test trace: Google Test trace:
gtest_output_test_.cc:#: n = 1 gtest_output_test_.cc:#: n = 1
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Expected: 1 Expected equality of these values:
To be equal to: n 1
n
Which is: 2 Which is: 2
Google Test trace: Google Test trace:
gtest_output_test_.cc:#: n = 2 gtest_output_test_.cc:#: n = 2
...@@ -137,8 +147,9 @@ gtest_output_test_.cc:#: n = 2 ...@@ -137,8 +147,9 @@ gtest_output_test_.cc:#: n = 2
[ RUN ] SCOPED_TRACETest.CanBeNested [ RUN ] SCOPED_TRACETest.CanBeNested
(expected to fail) (expected to fail)
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Expected: 1 Expected equality of these values:
To be equal to: n 1
n
Which is: 2 Which is: 2
Google Test trace: Google Test trace:
gtest_output_test_.cc:#: n = 2 gtest_output_test_.cc:#: n = 2
...@@ -437,8 +448,9 @@ Expected: 1 fatal failure ...@@ -437,8 +448,9 @@ Expected: 1 fatal failure
[ OK ] TypedTest/0.Success [ OK ] TypedTest/0.Success
[ RUN ] TypedTest/0.Failure [ RUN ] TypedTest/0.Failure
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Expected: 1 Expected equality of these values:
To be equal to: TypeParam() 1
TypeParam()
Which is: 0 Which is: 0
Expected failure Expected failure
[ FAILED ] TypedTest/0.Failure, where TypeParam = int [ FAILED ] TypedTest/0.Failure, where TypeParam = int
...@@ -447,9 +459,10 @@ Expected failure ...@@ -447,9 +459,10 @@ Expected failure
[ OK ] Unsigned/TypedTestP/0.Success [ OK ] Unsigned/TypedTestP/0.Success
[ RUN ] Unsigned/TypedTestP/0.Failure [ RUN ] Unsigned/TypedTestP/0.Failure
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Expected: 1U Expected equality of these values:
1U
Which is: 1 Which is: 1
To be equal to: TypeParam() TypeParam()
Which is: '\0' Which is: '\0'
Expected failure Expected failure
[ FAILED ] Unsigned/TypedTestP/0.Failure, where TypeParam = unsigned char [ FAILED ] Unsigned/TypedTestP/0.Failure, where TypeParam = unsigned char
...@@ -458,9 +471,10 @@ Expected failure ...@@ -458,9 +471,10 @@ Expected failure
[ OK ] Unsigned/TypedTestP/1.Success [ OK ] Unsigned/TypedTestP/1.Success
[ RUN ] Unsigned/TypedTestP/1.Failure [ RUN ] Unsigned/TypedTestP/1.Failure
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Expected: 1U Expected equality of these values:
1U
Which is: 1 Which is: 1
To be equal to: TypeParam() TypeParam()
Which is: 0 Which is: 0
Expected failure Expected failure
[ FAILED ] Unsigned/TypedTestP/1.Failure, where TypeParam = unsigned int [ FAILED ] Unsigned/TypedTestP/1.Failure, where TypeParam = unsigned int
...@@ -597,8 +611,9 @@ Expected non-fatal failure. ...@@ -597,8 +611,9 @@ Expected non-fatal failure.
[----------] 1 test from PrintingFailingParams/FailingParamTest [----------] 1 test from PrintingFailingParams/FailingParamTest
[ RUN ] PrintingFailingParams/FailingParamTest.Fails/0 [ RUN ] PrintingFailingParams/FailingParamTest.Fails/0
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Expected: 1 Expected equality of these values:
To be equal to: GetParam() 1
GetParam()
Which is: 2 Which is: 2
[ FAILED ] PrintingFailingParams/FailingParamTest.Fails/0, where GetParam() = 2 [ FAILED ] PrintingFailingParams/FailingParamTest.Fails/0, where GetParam() = 2
[----------] 2 tests from PrintingStrings/ParamTest [----------] 2 tests from PrintingStrings/ParamTest
...@@ -606,8 +621,9 @@ To be equal to: GetParam() ...@@ -606,8 +621,9 @@ To be equal to: GetParam()
[ OK ] PrintingStrings/ParamTest.Success/a [ OK ] PrintingStrings/ParamTest.Success/a
[ RUN ] PrintingStrings/ParamTest.Failure/a [ RUN ] PrintingStrings/ParamTest.Failure/a
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Expected: "b" Expected equality of these values:
To be equal to: GetParam() "b"
GetParam()
Which is: "a" Which is: "a"
Expected failure Expected failure
[ FAILED ] PrintingStrings/ParamTest.Failure/a, where GetParam() = "a" [ FAILED ] PrintingStrings/ParamTest.Failure/a, where GetParam() = "a"
...@@ -678,15 +694,17 @@ Expected fatal failure. ...@@ -678,15 +694,17 @@ Expected fatal failure.
[ RUN ] FatalFailureTest.FatalFailureInSubroutine [ RUN ] FatalFailureTest.FatalFailureInSubroutine
(expecting a failure that x should be 1) (expecting a failure that x should be 1)
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Expected: 1 Expected equality of these values:
To be equal to: x 1
x
Which is: 2 Which is: 2
[ FAILED ] FatalFailureTest.FatalFailureInSubroutine (? ms) [ FAILED ] FatalFailureTest.FatalFailureInSubroutine (? ms)
[ RUN ] FatalFailureTest.FatalFailureInNestedSubroutine [ RUN ] FatalFailureTest.FatalFailureInNestedSubroutine
(expecting a failure that x should be 1) (expecting a failure that x should be 1)
gtest_output_test_.cc:#: Failure gtest_output_test_.cc:#: Failure
Expected: 1 Expected equality of these values:
To be equal to: x 1
x
Which is: 2 Which is: 2
[ FAILED ] FatalFailureTest.FatalFailureInNestedSubroutine (? ms) [ FAILED ] FatalFailureTest.FatalFailureInNestedSubroutine (? ms)
[ RUN ] FatalFailureTest.NonfatalFailureInSubroutine [ RUN ] FatalFailureTest.NonfatalFailureInSubroutine
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
// implementation. It must come before gtest-internal-inl.h is // implementation. It must come before gtest-internal-inl.h is
// included, or there will be a compiler error. This trick is to // included, or there will be a compiler error. This trick is to
// prevent a user from accidentally including gtest-internal-inl.h in // prevent a user from accidentally including gtest-internal-inl.h in
// his code. // their code.
#define GTEST_IMPLEMENTATION_ 1 #define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h" #include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION_ #undef GTEST_IMPLEMENTATION_
......
...@@ -71,7 +71,7 @@ TEST(CommandLineFlagsTest, CanBeAccessedInCodeOnceGTestHIsIncluded) { ...@@ -71,7 +71,7 @@ TEST(CommandLineFlagsTest, CanBeAccessedInCodeOnceGTestHIsIncluded) {
// implementation. It must come before gtest-internal-inl.h is // implementation. It must come before gtest-internal-inl.h is
// included, or there will be a compiler error. This trick is to // included, or there will be a compiler error. This trick is to
// prevent a user from accidentally including gtest-internal-inl.h in // prevent a user from accidentally including gtest-internal-inl.h in
// his code. // their code.
#define GTEST_IMPLEMENTATION_ 1 #define GTEST_IMPLEMENTATION_ 1
#include "src/gtest-internal-inl.h" #include "src/gtest-internal-inl.h"
#undef GTEST_IMPLEMENTATION_ #undef GTEST_IMPLEMENTATION_
...@@ -2096,7 +2096,7 @@ class UnitTestRecordPropertyTestEnvironment : public Environment { ...@@ -2096,7 +2096,7 @@ class UnitTestRecordPropertyTestEnvironment : public Environment {
}; };
// This will test property recording outside of any test or test case. // This will test property recording outside of any test or test case.
static Environment* record_property_env = Environment* record_property_env GTEST_ATTRIBUTE_UNUSED_ =
AddGlobalTestEnvironment(new UnitTestRecordPropertyTestEnvironment); AddGlobalTestEnvironment(new UnitTestRecordPropertyTestEnvironment);
// This group of tests is for predicate assertions (ASSERT_PRED*, etc) // This group of tests is for predicate assertions (ASSERT_PRED*, etc)
...@@ -2429,8 +2429,9 @@ TEST(StringAssertionTest, ASSERT_STREQ) { ...@@ -2429,8 +2429,9 @@ TEST(StringAssertionTest, ASSERT_STREQ) {
const char p2[] = "good"; const char p2[] = "good";
ASSERT_STREQ(p1, p2); ASSERT_STREQ(p1, p2);
EXPECT_FATAL_FAILURE(ASSERT_STREQ("bad", "good"), EXPECT_FATAL_FAILURE(
"Expected: \"bad\""); ASSERT_STREQ("bad", "good"),
"Expected equality of these values:\n \"bad\"\n \"good\"");
} }
// Tests ASSERT_STREQ with NULL arguments. // Tests ASSERT_STREQ with NULL arguments.
...@@ -3528,9 +3529,10 @@ TEST(AssertionTest, EqFailure) { ...@@ -3528,9 +3529,10 @@ TEST(AssertionTest, EqFailure) {
EqFailure("foo", "bar", foo_val, bar_val, false) EqFailure("foo", "bar", foo_val, bar_val, false)
.failure_message()); .failure_message());
EXPECT_STREQ( EXPECT_STREQ(
" Expected: foo\n" "Expected equality of these values:\n"
" foo\n"
" Which is: 5\n" " Which is: 5\n"
"To be equal to: bar\n" " bar\n"
" Which is: 6", " Which is: 6",
msg1.c_str()); msg1.c_str());
...@@ -3538,25 +3540,28 @@ TEST(AssertionTest, EqFailure) { ...@@ -3538,25 +3540,28 @@ TEST(AssertionTest, EqFailure) {
EqFailure("foo", "6", foo_val, bar_val, false) EqFailure("foo", "6", foo_val, bar_val, false)
.failure_message()); .failure_message());
EXPECT_STREQ( EXPECT_STREQ(
" Expected: foo\n" "Expected equality of these values:\n"
" foo\n"
" Which is: 5\n" " Which is: 5\n"
"To be equal to: 6", " 6",
msg2.c_str()); msg2.c_str());
const std::string msg3( const std::string msg3(
EqFailure("5", "bar", foo_val, bar_val, false) EqFailure("5", "bar", foo_val, bar_val, false)
.failure_message()); .failure_message());
EXPECT_STREQ( EXPECT_STREQ(
" Expected: 5\n" "Expected equality of these values:\n"
"To be equal to: bar\n" " 5\n"
" bar\n"
" Which is: 6", " Which is: 6",
msg3.c_str()); msg3.c_str());
const std::string msg4( const std::string msg4(
EqFailure("5", "6", foo_val, bar_val, false).failure_message()); EqFailure("5", "6", foo_val, bar_val, false).failure_message());
EXPECT_STREQ( EXPECT_STREQ(
" Expected: 5\n" "Expected equality of these values:\n"
"To be equal to: 6", " 5\n"
" 6",
msg4.c_str()); msg4.c_str());
const std::string msg5( const std::string msg5(
...@@ -3564,9 +3569,10 @@ TEST(AssertionTest, EqFailure) { ...@@ -3564,9 +3569,10 @@ TEST(AssertionTest, EqFailure) {
std::string("\"x\""), std::string("\"y\""), std::string("\"x\""), std::string("\"y\""),
true).failure_message()); true).failure_message());
EXPECT_STREQ( EXPECT_STREQ(
" Expected: foo\n" "Expected equality of these values:\n"
" foo\n"
" Which is: \"x\"\n" " Which is: \"x\"\n"
"To be equal to: bar\n" " bar\n"
" Which is: \"y\"\n" " Which is: \"y\"\n"
"Ignoring case", "Ignoring case",
msg5.c_str()); msg5.c_str());
...@@ -3580,10 +3586,11 @@ TEST(AssertionTest, EqFailureWithDiff) { ...@@ -3580,10 +3586,11 @@ TEST(AssertionTest, EqFailureWithDiff) {
const std::string msg1( const std::string msg1(
EqFailure("left", "right", left, right, false).failure_message()); EqFailure("left", "right", left, right, false).failure_message());
EXPECT_STREQ( EXPECT_STREQ(
" Expected: left\n" "Expected equality of these values:\n"
" left\n"
" Which is: " " Which is: "
"1\\n2XXX\\n3\\n5\\n6\\n7\\n8\\n9\\n10\\n11\\n12XXX\\n13\\n14\\n15\n" "1\\n2XXX\\n3\\n5\\n6\\n7\\n8\\n9\\n10\\n11\\n12XXX\\n13\\n14\\n15\n"
"To be equal to: right\n" " right\n"
" Which is: 1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n11\\n12\\n13\\n14\n" " Which is: 1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n11\\n12\\n13\\n14\n"
"With diff:\n@@ -1,5 +1,6 @@\n 1\n-2XXX\n+2\n 3\n+4\n 5\n 6\n" "With diff:\n@@ -1,5 +1,6 @@\n 1\n-2XXX\n+2\n 3\n+4\n 5\n 6\n"
"@@ -7,8 +8,6 @@\n 8\n 9\n-10\n 11\n-12XXX\n+12\n 13\n 14\n-15\n", "@@ -7,8 +8,6 @@\n 8\n 9\n-10\n 11\n-12XXX\n+12\n 13\n 14\n-15\n",
...@@ -3679,8 +3686,9 @@ TEST(ExpectTest, ASSERT_EQ_Double) { ...@@ -3679,8 +3686,9 @@ TEST(ExpectTest, ASSERT_EQ_Double) {
TEST(AssertionTest, ASSERT_EQ) { TEST(AssertionTest, ASSERT_EQ) {
ASSERT_EQ(5, 2 + 3); ASSERT_EQ(5, 2 + 3);
EXPECT_FATAL_FAILURE(ASSERT_EQ(5, 2*3), EXPECT_FATAL_FAILURE(ASSERT_EQ(5, 2*3),
" Expected: 5\n" "Expected equality of these values:\n"
"To be equal to: 2*3\n" " 5\n"
" 2*3\n"
" Which is: 6"); " Which is: 6");
} }
...@@ -3698,7 +3706,7 @@ TEST(AssertionTest, ASSERT_EQ_NULL) { ...@@ -3698,7 +3706,7 @@ TEST(AssertionTest, ASSERT_EQ_NULL) {
// A failure. // A failure.
static int n = 0; static int n = 0;
EXPECT_FATAL_FAILURE(ASSERT_EQ(NULL, &n), EXPECT_FATAL_FAILURE(ASSERT_EQ(NULL, &n),
"To be equal to: &n\n"); " &n\n Which is:");
} }
#endif // GTEST_CAN_COMPARE_NULL #endif // GTEST_CAN_COMPARE_NULL
...@@ -3714,7 +3722,7 @@ TEST(ExpectTest, ASSERT_EQ_0) { ...@@ -3714,7 +3722,7 @@ TEST(ExpectTest, ASSERT_EQ_0) {
// A failure. // A failure.
EXPECT_FATAL_FAILURE(ASSERT_EQ(0, 5.6), EXPECT_FATAL_FAILURE(ASSERT_EQ(0, 5.6),
"Expected: 0"); " 0\n 5.6");
} }
// Tests ASSERT_NE. // Tests ASSERT_NE.
...@@ -3813,7 +3821,7 @@ void TestEq1(int x) { ...@@ -3813,7 +3821,7 @@ void TestEq1(int x) {
// Tests calling a test subroutine that's not part of a fixture. // Tests calling a test subroutine that's not part of a fixture.
TEST(AssertionTest, NonFixtureSubroutine) { TEST(AssertionTest, NonFixtureSubroutine) {
EXPECT_FATAL_FAILURE(TestEq1(2), EXPECT_FATAL_FAILURE(TestEq1(2),
"To be equal to: x"); "Which is: 2");
} }
// An uncopyable class. // An uncopyable class.
...@@ -3862,7 +3870,8 @@ TEST(AssertionTest, AssertWorksWithUncopyableObject) { ...@@ -3862,7 +3870,8 @@ TEST(AssertionTest, AssertWorksWithUncopyableObject) {
EXPECT_FATAL_FAILURE(TestAssertNonPositive(), EXPECT_FATAL_FAILURE(TestAssertNonPositive(),
"IsPositiveUncopyable(y) evaluates to false, where\ny evaluates to -1"); "IsPositiveUncopyable(y) evaluates to false, where\ny evaluates to -1");
EXPECT_FATAL_FAILURE(TestAssertEqualsUncopyable(), EXPECT_FATAL_FAILURE(TestAssertEqualsUncopyable(),
"Expected: x\n Which is: 5\nTo be equal to: y\n Which is: -1"); "Expected equality of these values:\n"
" x\n Which is: 5\n y\n Which is: -1");
} }
// Tests that uncopyable objects can be used in expects. // Tests that uncopyable objects can be used in expects.
...@@ -3874,7 +3883,8 @@ TEST(AssertionTest, ExpectWorksWithUncopyableObject) { ...@@ -3874,7 +3883,8 @@ TEST(AssertionTest, ExpectWorksWithUncopyableObject) {
"IsPositiveUncopyable(y) evaluates to false, where\ny evaluates to -1"); "IsPositiveUncopyable(y) evaluates to false, where\ny evaluates to -1");
EXPECT_EQ(x, x); EXPECT_EQ(x, x);
EXPECT_NONFATAL_FAILURE(EXPECT_EQ(x, y), EXPECT_NONFATAL_FAILURE(EXPECT_EQ(x, y),
"Expected: x\n Which is: 5\nTo be equal to: y\n Which is: -1"); "Expected equality of these values:\n"
" x\n Which is: 5\n y\n Which is: -1");
} }
enum NamedEnum { enum NamedEnum {
...@@ -3950,7 +3960,7 @@ TEST(AssertionTest, AnonymousEnum) { ...@@ -3950,7 +3960,7 @@ TEST(AssertionTest, AnonymousEnum) {
// ICE's in C++Builder. // ICE's in C++Builder.
EXPECT_FATAL_FAILURE(ASSERT_EQ(kCaseA, kCaseB), EXPECT_FATAL_FAILURE(ASSERT_EQ(kCaseA, kCaseB),
"To be equal to: kCaseB"); "kCaseB");
EXPECT_FATAL_FAILURE(ASSERT_EQ(kCaseA, kCaseC), EXPECT_FATAL_FAILURE(ASSERT_EQ(kCaseA, kCaseC),
"Which is: 42"); "Which is: 42");
# endif # endif
...@@ -4390,8 +4400,9 @@ TEST(ExpectTest, ExpectFalseWithAssertionResult) { ...@@ -4390,8 +4400,9 @@ TEST(ExpectTest, ExpectFalseWithAssertionResult) {
TEST(ExpectTest, EXPECT_EQ) { TEST(ExpectTest, EXPECT_EQ) {
EXPECT_EQ(5, 2 + 3); EXPECT_EQ(5, 2 + 3);
EXPECT_NONFATAL_FAILURE(EXPECT_EQ(5, 2*3), EXPECT_NONFATAL_FAILURE(EXPECT_EQ(5, 2*3),
" Expected: 5\n" "Expected equality of these values:\n"
"To be equal to: 2*3\n" " 5\n"
" 2*3\n"
" Which is: 6"); " Which is: 6");
EXPECT_NONFATAL_FAILURE(EXPECT_EQ(5, 2 - 3), EXPECT_NONFATAL_FAILURE(EXPECT_EQ(5, 2 - 3),
"2 - 3"); "2 - 3");
...@@ -4423,7 +4434,7 @@ TEST(ExpectTest, EXPECT_EQ_NULL) { ...@@ -4423,7 +4434,7 @@ TEST(ExpectTest, EXPECT_EQ_NULL) {
// A failure. // A failure.
int n = 0; int n = 0;
EXPECT_NONFATAL_FAILURE(EXPECT_EQ(NULL, &n), EXPECT_NONFATAL_FAILURE(EXPECT_EQ(NULL, &n),
"To be equal to: &n\n"); "&n\n");
} }
#endif // GTEST_CAN_COMPARE_NULL #endif // GTEST_CAN_COMPARE_NULL
...@@ -4439,7 +4450,7 @@ TEST(ExpectTest, EXPECT_EQ_0) { ...@@ -4439,7 +4450,7 @@ TEST(ExpectTest, EXPECT_EQ_0) {
// A failure. // A failure.
EXPECT_NONFATAL_FAILURE(EXPECT_EQ(0, 5.6), EXPECT_NONFATAL_FAILURE(EXPECT_EQ(0, 5.6),
"Expected: 0"); "Expected equality of these values:\n 0\n 5.6");
} }
// Tests EXPECT_NE. // Tests EXPECT_NE.
...@@ -4539,7 +4550,7 @@ TEST(ExpectTest, EXPECT_ANY_THROW) { ...@@ -4539,7 +4550,7 @@ TEST(ExpectTest, EXPECT_ANY_THROW) {
TEST(ExpectTest, ExpectPrecedence) { TEST(ExpectTest, ExpectPrecedence) {
EXPECT_EQ(1 < 2, true); EXPECT_EQ(1 < 2, true);
EXPECT_NONFATAL_FAILURE(EXPECT_EQ(true, true && false), EXPECT_NONFATAL_FAILURE(EXPECT_EQ(true, true && false),
"To be equal to: true && false"); "true && false");
} }
...@@ -4686,7 +4697,7 @@ TEST(EqAssertionTest, Bool) { ...@@ -4686,7 +4697,7 @@ TEST(EqAssertionTest, Bool) {
EXPECT_FATAL_FAILURE({ EXPECT_FATAL_FAILURE({
bool false_value = false; bool false_value = false;
ASSERT_EQ(false_value, true); ASSERT_EQ(false_value, true);
}, "To be equal to: true"); }, "Which is: false");
} }
// Tests using int values in {EXPECT|ASSERT}_EQ. // Tests using int values in {EXPECT|ASSERT}_EQ.
...@@ -4720,9 +4731,10 @@ TEST(EqAssertionTest, WideChar) { ...@@ -4720,9 +4731,10 @@ TEST(EqAssertionTest, WideChar) {
EXPECT_EQ(L'b', L'b'); EXPECT_EQ(L'b', L'b');
EXPECT_NONFATAL_FAILURE(EXPECT_EQ(L'\0', L'x'), EXPECT_NONFATAL_FAILURE(EXPECT_EQ(L'\0', L'x'),
" Expected: L'\0'\n" "Expected equality of these values:\n"
" L'\0'\n"
" Which is: L'\0' (0, 0x0)\n" " Which is: L'\0' (0, 0x0)\n"
"To be equal to: L'x'\n" " L'x'\n"
" Which is: L'x' (120, 0x78)"); " Which is: L'x' (120, 0x78)");
static wchar_t wchar; static wchar_t wchar;
...@@ -4731,7 +4743,7 @@ TEST(EqAssertionTest, WideChar) { ...@@ -4731,7 +4743,7 @@ TEST(EqAssertionTest, WideChar) {
"wchar"); "wchar");
wchar = 0x8119; wchar = 0x8119;
EXPECT_FATAL_FAILURE(ASSERT_EQ(static_cast<wchar_t>(0x8120), wchar), EXPECT_FATAL_FAILURE(ASSERT_EQ(static_cast<wchar_t>(0x8120), wchar),
"To be equal to: wchar"); "wchar");
} }
// Tests using ::std::string values in {EXPECT|ASSERT}_EQ. // Tests using ::std::string values in {EXPECT|ASSERT}_EQ.
...@@ -4760,7 +4772,7 @@ TEST(EqAssertionTest, StdString) { ...@@ -4760,7 +4772,7 @@ TEST(EqAssertionTest, StdString) {
static ::std::string str3(str1); static ::std::string str3(str1);
str3.at(2) = '\0'; str3.at(2) = '\0';
EXPECT_FATAL_FAILURE(ASSERT_EQ(str1, str3), EXPECT_FATAL_FAILURE(ASSERT_EQ(str1, str3),
"To be equal to: str3\n" " str3\n"
" Which is: \"A \\0 in the middle\""); " Which is: \"A \\0 in the middle\"");
} }
...@@ -4881,7 +4893,7 @@ TEST(EqAssertionTest, CharPointer) { ...@@ -4881,7 +4893,7 @@ TEST(EqAssertionTest, CharPointer) {
ASSERT_EQ(p1, p1); ASSERT_EQ(p1, p1);
EXPECT_NONFATAL_FAILURE(EXPECT_EQ(p0, p2), EXPECT_NONFATAL_FAILURE(EXPECT_EQ(p0, p2),
"To be equal to: p2"); "p2");
EXPECT_NONFATAL_FAILURE(EXPECT_EQ(p1, p2), EXPECT_NONFATAL_FAILURE(EXPECT_EQ(p1, p2),
"p2"); "p2");
EXPECT_FATAL_FAILURE(ASSERT_EQ(reinterpret_cast<char*>(0x1234), EXPECT_FATAL_FAILURE(ASSERT_EQ(reinterpret_cast<char*>(0x1234),
...@@ -4903,7 +4915,7 @@ TEST(EqAssertionTest, WideCharPointer) { ...@@ -4903,7 +4915,7 @@ TEST(EqAssertionTest, WideCharPointer) {
EXPECT_EQ(p0, p0); EXPECT_EQ(p0, p0);
EXPECT_NONFATAL_FAILURE(EXPECT_EQ(p0, p2), EXPECT_NONFATAL_FAILURE(EXPECT_EQ(p0, p2),
"To be equal to: p2"); "p2");
EXPECT_NONFATAL_FAILURE(EXPECT_EQ(p1, p2), EXPECT_NONFATAL_FAILURE(EXPECT_EQ(p1, p2),
"p2"); "p2");
void* pv3 = (void*)0x1234; // NOLINT void* pv3 = (void*)0x1234; // NOLINT
......
...@@ -64,20 +64,23 @@ EXPECTED_NON_EMPTY_XML = """<?xml version="1.0" encoding="UTF-8"?> ...@@ -64,20 +64,23 @@ EXPECTED_NON_EMPTY_XML = """<?xml version="1.0" encoding="UTF-8"?>
</testsuite> </testsuite>
<testsuite name="FailedTest" tests="1" failures="1" disabled="0" errors="0" time="*"> <testsuite name="FailedTest" tests="1" failures="1" disabled="0" errors="0" time="*">
<testcase name="Fails" status="run" time="*" classname="FailedTest"> <testcase name="Fails" status="run" time="*" classname="FailedTest">
<failure message="gtest_xml_output_unittest_.cc:*&#x0A; Expected: 1&#x0A;To be equal to: 2" type=""><![CDATA[gtest_xml_output_unittest_.cc:* <failure message="gtest_xml_output_unittest_.cc:*&#x0A;Expected equality of these values:&#x0A; 1&#x0A; 2" type=""><![CDATA[gtest_xml_output_unittest_.cc:*
Expected: 1 Expected equality of these values:
To be equal to: 2%(stack)s]]></failure> 1
2%(stack)s]]></failure>
</testcase> </testcase>
</testsuite> </testsuite>
<testsuite name="MixedResultTest" tests="3" failures="1" disabled="1" errors="0" time="*"> <testsuite name="MixedResultTest" tests="3" failures="1" disabled="1" errors="0" time="*">
<testcase name="Succeeds" status="run" time="*" classname="MixedResultTest"/> <testcase name="Succeeds" status="run" time="*" classname="MixedResultTest"/>
<testcase name="Fails" status="run" time="*" classname="MixedResultTest"> <testcase name="Fails" status="run" time="*" classname="MixedResultTest">
<failure message="gtest_xml_output_unittest_.cc:*&#x0A; Expected: 1&#x0A;To be equal to: 2" type=""><![CDATA[gtest_xml_output_unittest_.cc:* <failure message="gtest_xml_output_unittest_.cc:*&#x0A;Expected equality of these values:&#x0A; 1&#x0A; 2" type=""><![CDATA[gtest_xml_output_unittest_.cc:*
Expected: 1 Expected equality of these values:
To be equal to: 2%(stack)s]]></failure> 1
<failure message="gtest_xml_output_unittest_.cc:*&#x0A; Expected: 2&#x0A;To be equal to: 3" type=""><![CDATA[gtest_xml_output_unittest_.cc:* 2%(stack)s]]></failure>
Expected: 2 <failure message="gtest_xml_output_unittest_.cc:*&#x0A;Expected equality of these values:&#x0A; 2&#x0A; 3" type=""><![CDATA[gtest_xml_output_unittest_.cc:*
To be equal to: 3%(stack)s]]></failure> Expected equality of these values:
2
3%(stack)s]]></failure>
</testcase> </testcase>
<testcase name="DISABLED_test" status="notrun" time="*" classname="MixedResultTest"/> <testcase name="DISABLED_test" status="notrun" time="*" classname="MixedResultTest"/>
</testsuite> </testsuite>
......
#!/usr/bin/env sh #!/usr/bin/env sh
set -evx set -evx
# if possible, ask for the precise number of processors,
# otherwise take 2 processors as reasonable default; see
# https://docs.travis-ci.com/user/speeding-up-the-build/#Makefile-optimization
if [ -x /usr/bin/getconf ]; then
NPROCESSORS=$(/usr/bin/getconf _NPROCESSORS_ONLN)
else
NPROCESSORS=2
fi
# as of 2017-09-04 Travis CI reports 32 processors, but GCC build
# crashes if parallelized too much (maybe memory consumption problem),
# so limit to 4 processors for the time being.
if [ $NPROCESSORS -gt 4 ] ; then
echo "$0:Note: Limiting processors to use by make from $NPROCESSORS to 4."
NPROCESSORS=4
fi
# Tell make to use the processors. No preceding '-' required.
MAKEFLAGS="j${NPROCESSORS}"
export MAKEFLAGS
env | sort env | sort
mkdir build || true mkdir build || true
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment