Unverified Commit fa673010 authored by Gennadiy Civil's avatar Gennadiy Civil Committed by GitHub
Browse files

Merge branch 'master' into uintptr

parents ca6a70c6 1c2f1907
...@@ -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_
......
...@@ -36,8 +36,6 @@ ...@@ -36,8 +36,6 @@
#include "test/gtest-param-test_test.h" #include "test/gtest-param-test_test.h"
#if GTEST_HAS_PARAM_TEST
using ::testing::Values; using ::testing::Values;
using ::testing::internal::ParamGenerator; using ::testing::internal::ParamGenerator;
...@@ -61,5 +59,3 @@ INSTANTIATE_TEST_CASE_P(MultiplesOf33, ...@@ -61,5 +59,3 @@ INSTANTIATE_TEST_CASE_P(MultiplesOf33,
INSTANTIATE_TEST_CASE_P(Sequence2, INSTANTIATE_TEST_CASE_P(Sequence2,
InstantiationInMultipleTranslaionUnitsTest, InstantiationInMultipleTranslaionUnitsTest,
Values(42*3, 42*4, 42*5)); Values(42*3, 42*4, 42*5));
#endif // GTEST_HAS_PARAM_TEST
...@@ -35,8 +35,6 @@ ...@@ -35,8 +35,6 @@
#include "gtest/gtest.h" #include "gtest/gtest.h"
#if GTEST_HAS_PARAM_TEST
# include <algorithm> # include <algorithm>
# include <iostream> # include <iostream>
# include <list> # include <list>
...@@ -141,7 +139,7 @@ void VerifyGenerator(const ParamGenerator<T>& generator, ...@@ -141,7 +139,7 @@ void VerifyGenerator(const ParamGenerator<T>& generator,
<< ", expected_values[i] is " << PrintValue(expected_values[i]) << ", expected_values[i] is " << PrintValue(expected_values[i])
<< ", *it is " << PrintValue(*it) << ", *it is " << PrintValue(*it)
<< ", and 'it' is an iterator created with the copy constructor.\n"; << ", and 'it' is an iterator created with the copy constructor.\n";
it++; ++it;
} }
EXPECT_TRUE(it == generator.end()) EXPECT_TRUE(it == generator.end())
<< "At the presumed end of sequence when accessing via an iterator " << "At the presumed end of sequence when accessing via an iterator "
...@@ -161,7 +159,7 @@ void VerifyGenerator(const ParamGenerator<T>& generator, ...@@ -161,7 +159,7 @@ void VerifyGenerator(const ParamGenerator<T>& generator,
<< ", expected_values[i] is " << PrintValue(expected_values[i]) << ", expected_values[i] is " << PrintValue(expected_values[i])
<< ", *it is " << PrintValue(*it) << ", *it is " << PrintValue(*it)
<< ", and 'it' is an iterator created with the copy constructor.\n"; << ", and 'it' is an iterator created with the copy constructor.\n";
it++; ++it;
} }
EXPECT_TRUE(it == generator.end()) EXPECT_TRUE(it == generator.end())
<< "At the presumed end of sequence when accessing via an iterator " << "At the presumed end of sequence when accessing via an iterator "
...@@ -196,7 +194,7 @@ TEST(IteratorTest, ParamIteratorConformsToForwardIteratorConcept) { ...@@ -196,7 +194,7 @@ TEST(IteratorTest, ParamIteratorConformsToForwardIteratorConcept) {
<< "element same as its source points to"; << "element same as its source points to";
// Verifies that iterator assignment works as expected. // Verifies that iterator assignment works as expected.
it++; ++it;
EXPECT_FALSE(*it == *it2); EXPECT_FALSE(*it == *it2);
it2 = it; it2 = it;
EXPECT_TRUE(*it == *it2) << "Assigned iterators must point to the " EXPECT_TRUE(*it == *it2) << "Assigned iterators must point to the "
...@@ -215,7 +213,7 @@ TEST(IteratorTest, ParamIteratorConformsToForwardIteratorConcept) { ...@@ -215,7 +213,7 @@ TEST(IteratorTest, ParamIteratorConformsToForwardIteratorConcept) {
// Verifies that prefix and postfix operator++() advance an iterator // Verifies that prefix and postfix operator++() advance an iterator
// all the same. // all the same.
it2 = it; it2 = it;
it++; ++it;
++it2; ++it2;
EXPECT_TRUE(*it == *it2); EXPECT_TRUE(*it == *it2);
} }
...@@ -857,8 +855,8 @@ TEST_P(CustomLambdaNamingTest, CustomTestNames) {} ...@@ -857,8 +855,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
...@@ -1025,31 +1023,19 @@ TEST_F(ParameterizedDeathTest, GetParamDiesFromTestF) { ...@@ -1025,31 +1023,19 @@ TEST_F(ParameterizedDeathTest, GetParamDiesFromTestF) {
INSTANTIATE_TEST_CASE_P(RangeZeroToFive, ParameterizedDerivedTest, Range(0, 5)); INSTANTIATE_TEST_CASE_P(RangeZeroToFive, ParameterizedDerivedTest, Range(0, 5));
#endif // GTEST_HAS_PARAM_TEST
TEST(CompileTest, CombineIsDefinedOnlyWhenGtestHasParamTestIsDefined) {
#if GTEST_HAS_COMBINE && !GTEST_HAS_PARAM_TEST
FAIL() << "GTEST_HAS_COMBINE is defined while GTEST_HAS_PARAM_TEST is not\n"
#endif
}
int main(int argc, char **argv) { int main(int argc, char **argv) {
#if GTEST_HAS_PARAM_TEST
// Used in TestGenerationTest test case. // Used in TestGenerationTest test case.
AddGlobalTestEnvironment(TestGenerationTest::Environment::Instance()); AddGlobalTestEnvironment(TestGenerationTest::Environment::Instance());
// Used in GeneratorEvaluationTest test case. Tests that the updated value // Used in GeneratorEvaluationTest test case. Tests that the updated value
// will be picked up for instantiating tests in GeneratorEvaluationTest. // will be picked up for instantiating tests in GeneratorEvaluationTest.
GeneratorEvaluationTest::set_param_value(1); GeneratorEvaluationTest::set_param_value(1);
#endif // GTEST_HAS_PARAM_TEST
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);
#if GTEST_HAS_PARAM_TEST
// Used in GeneratorEvaluationTest test case. Tests that value updated // Used in GeneratorEvaluationTest test case. Tests that value updated
// here will NOT be used for instantiating tests in // here will NOT be used for instantiating tests in
// GeneratorEvaluationTest. // GeneratorEvaluationTest.
GeneratorEvaluationTest::set_param_value(2); GeneratorEvaluationTest::set_param_value(2);
#endif // GTEST_HAS_PARAM_TEST
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();
} }
...@@ -39,8 +39,6 @@ ...@@ -39,8 +39,6 @@
#include "gtest/gtest.h" #include "gtest/gtest.h"
#if GTEST_HAS_PARAM_TEST
// Test fixture for testing definition and instantiation of a test // Test fixture for testing definition and instantiation of a test
// in separate translation units. // in separate translation units.
class ExternalInstantiationTest : public ::testing::TestWithParam<int> { class ExternalInstantiationTest : public ::testing::TestWithParam<int> {
...@@ -52,6 +50,4 @@ class InstantiationInMultipleTranslaionUnitsTest ...@@ -52,6 +50,4 @@ class InstantiationInMultipleTranslaionUnitsTest
: public ::testing::TestWithParam<int> { : public ::testing::TestWithParam<int> {
}; };
#endif // GTEST_HAS_PARAM_TEST
#endif // GTEST_TEST_GTEST_PARAM_TEST_TEST_H_ #endif // GTEST_TEST_GTEST_PARAM_TEST_TEST_H_
...@@ -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_
...@@ -187,6 +192,29 @@ inline ::std::ostream& operator<<(::std::ostream& os, ...@@ -187,6 +192,29 @@ inline ::std::ostream& operator<<(::std::ostream& os,
return os << "StreamableTemplateInFoo: " << x.value(); return os << "StreamableTemplateInFoo: " << x.value();
} }
// A user-defined streamable but recursivly-defined container type in
// a user namespace, it mimics therefore std::filesystem::path or
// boost::filesystem::path.
class PathLike {
public:
struct iterator
{
typedef PathLike value_type;
};
typedef iterator const_iterator;
PathLike() {}
iterator begin() const { return iterator(); }
iterator end() const { return iterator(); }
friend
::std::ostream& operator<<(::std::ostream& os, const PathLike&)
{
return os << "Streamable-PathLike";
}
};
} // namespace foo } // namespace foo
namespace testing { namespace testing {
...@@ -216,21 +244,47 @@ using ::testing::internal::UniversalTersePrintTupleFieldsToStrings; ...@@ -216,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
...@@ -1038,8 +1092,8 @@ TEST(PrintTr1TupleTest, VariousSizes) { ...@@ -1038,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));
...@@ -1098,8 +1152,8 @@ TEST(PrintStdTupleTest, VariousSizes) { ...@@ -1098,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));
...@@ -1161,6 +1215,15 @@ TEST(PrintStreamableTypeTest, TemplateTypeInUserNamespace) { ...@@ -1161,6 +1215,15 @@ TEST(PrintStreamableTypeTest, TemplateTypeInUserNamespace) {
Print(::foo::StreamableTemplateInFoo<int>())); Print(::foo::StreamableTemplateInFoo<int>()));
} }
// Tests printing a user-defined recursive container type that has a <<
// operator.
TEST(PrintStreamableTypeTest, PathLikeInUserNamespace) {
::foo::PathLike x;
EXPECT_EQ("Streamable-PathLike", Print(x));
const ::foo::PathLike cx;
EXPECT_EQ("Streamable-PathLike", Print(cx));
}
// Tests printing user-defined types that have a PrintTo() function. // Tests printing user-defined types that have a PrintTo() function.
TEST(PrintPrintableTypeTest, InUserNamespace) { TEST(PrintPrintableTypeTest, InUserNamespace) {
EXPECT_EQ("PrintableViaPrintTo: 0", EXPECT_EQ("PrintableViaPrintTo: 0",
......
...@@ -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_
......
...@@ -117,7 +117,6 @@ TEST(DISABLED_FoobarbazTest, TestA) { ...@@ -117,7 +117,6 @@ TEST(DISABLED_FoobarbazTest, TestA) {
FAIL() << "Expected failure."; FAIL() << "Expected failure.";
} }
#if GTEST_HAS_PARAM_TEST
class ParamTest : public testing::TestWithParam<int> { class ParamTest : public testing::TestWithParam<int> {
}; };
...@@ -129,7 +128,6 @@ TEST_P(ParamTest, TestY) { ...@@ -129,7 +128,6 @@ TEST_P(ParamTest, TestY) {
INSTANTIATE_TEST_CASE_P(SeqP, ParamTest, testing::Values(1, 2)); INSTANTIATE_TEST_CASE_P(SeqP, ParamTest, testing::Values(1, 2));
INSTANTIATE_TEST_CASE_P(SeqQ, ParamTest, testing::Values(5, 6)); INSTANTIATE_TEST_CASE_P(SeqQ, ParamTest, testing::Values(5, 6));
#endif // GTEST_HAS_PARAM_TEST
} // namespace } // namespace
......
...@@ -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_
...@@ -757,8 +757,6 @@ TEST(ExpectFatalFailureTest, FailsWhenStatementThrows) { ...@@ -757,8 +757,6 @@ TEST(ExpectFatalFailureTest, FailsWhenStatementThrows) {
// This #ifdef block tests the output of value-parameterized tests. // This #ifdef block tests the output of value-parameterized tests.
#if GTEST_HAS_PARAM_TEST
std::string ParamNameFunc(const testing::TestParamInfo<std::string>& info) { std::string ParamNameFunc(const testing::TestParamInfo<std::string>& info) {
return info.param; return info.param;
} }
...@@ -779,8 +777,6 @@ INSTANTIATE_TEST_CASE_P(PrintingStrings, ...@@ -779,8 +777,6 @@ INSTANTIATE_TEST_CASE_P(PrintingStrings,
testing::Values(std::string("a")), testing::Values(std::string("a")),
ParamNameFunc); ParamNameFunc);
#endif // GTEST_HAS_PARAM_TEST
// This #ifdef block tests the output of typed tests. // This #ifdef block tests the output of typed tests.
#if GTEST_HAS_TYPED_TEST #if GTEST_HAS_TYPED_TEST
......
...@@ -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:
Which is: "\"Line" kGoldenString
To be equal to: actual Which is: "\"Line"
Which is: "actual \"string\"" actual
gtest_output_test_.cc:#: Failure Which is: "actual \"string\""
Expected: golden gtest_output_test_.cc:#: Failure
Which is: "\"Line" Expected equality of these values:
To be equal to: actual golden
Which is: "actual \"string\"" Which is: "\"Line"
actual
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:
Which is: "\"Line\0 1\"\nLine 2" golden_str
To be equal to: "Line 2" Which is: "\"Line\0 1\"\nLine 2"
"Line 2"
With diff: With diff:
@@ -1,2 @@ @@ -1,2 @@
-\"Line\0 1\" -\"Line\0 1\"
...@@ -59,16 +63,18 @@ With diff: ...@@ -59,16 +63,18 @@ 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
Which is: 2 x
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
Which is: 2 x
Which is: 2
[ FAILED ] FatalFailureTest.FatalFailureInNestedSubroutine [ FAILED ] FatalFailureTest.FatalFailureInNestedSubroutine
[ RUN ] FatalFailureTest.NonfatalFailureInSubroutine [ RUN ] FatalFailureTest.NonfatalFailureInSubroutine
(expecting a failure on false) (expecting a failure on false)
...@@ -107,39 +113,44 @@ This failure is expected, and shouldn't have a trace. ...@@ -107,39 +113,44 @@ 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
Which is: 1 n
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
Which is: 2 n
Which is: 2
Google Test trace: Google Test trace:
gtest_output_test_.cc:#: i = 2 gtest_output_test_.cc:#: i = 2
[ FAILED ] SCOPED_TRACETest.WorksInLoop [ FAILED ] SCOPED_TRACETest.WorksInLoop
[ 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
Which is: 1 n
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
Which is: 2 n
Which is: 2
Google Test trace: Google Test trace:
gtest_output_test_.cc:#: n = 2 gtest_output_test_.cc:#: n = 2
[ FAILED ] SCOPED_TRACETest.WorksInSubroutine [ FAILED ] SCOPED_TRACETest.WorksInSubroutine
[ 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
Which is: 2 n
Which is: 2
Google Test trace: Google Test trace:
gtest_output_test_.cc:#: n = 2 gtest_output_test_.cc:#: n = 2
gtest_output_test_.cc:#: gtest_output_test_.cc:#:
...@@ -437,9 +448,10 @@ Expected: 1 fatal failure ...@@ -437,9 +448,10 @@ 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
Which is: 0 TypeParam()
Which is: 0
Expected failure Expected failure
[ FAILED ] TypedTest/0.Failure, where TypeParam = int [ FAILED ] TypedTest/0.Failure, where TypeParam = int
[----------] 2 tests from Unsigned/TypedTestP/0, where TypeParam = unsigned char [----------] 2 tests from Unsigned/TypedTestP/0, where TypeParam = unsigned char
...@@ -447,10 +459,11 @@ Expected failure ...@@ -447,10 +459,11 @@ 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:
Which is: 1 1U
To be equal to: TypeParam() Which is: 1
Which is: '\0' TypeParam()
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
[----------] 2 tests from Unsigned/TypedTestP/1, where TypeParam = unsigned int [----------] 2 tests from Unsigned/TypedTestP/1, where TypeParam = unsigned int
...@@ -458,10 +471,11 @@ Expected failure ...@@ -458,10 +471,11 @@ 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:
Which is: 1 1U
To be equal to: TypeParam() Which is: 1
Which is: 0 TypeParam()
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
[----------] 4 tests from ExpectFailureTest [----------] 4 tests from ExpectFailureTest
...@@ -597,18 +611,20 @@ Expected non-fatal failure. ...@@ -597,18 +611,20 @@ 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
Which is: 2 GetParam()
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
[ RUN ] PrintingStrings/ParamTest.Success/a [ RUN ] PrintingStrings/ParamTest.Success/a
[ 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"
Which is: "a" GetParam()
Which is: "a"
Expected failure Expected failure
[ FAILED ] PrintingStrings/ParamTest.Failure/a, where GetParam() = "a" [ FAILED ] PrintingStrings/ParamTest.Failure/a, where GetParam() = "a"
[----------] Global test environment tear-down [----------] Global test environment tear-down
...@@ -678,16 +694,18 @@ Expected fatal failure. ...@@ -678,16 +694,18 @@ 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
Which is: 2 x
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
Which is: 2 x
Which is: 2
[ FAILED ] FatalFailureTest.FatalFailureInNestedSubroutine (? ms) [ FAILED ] FatalFailureTest.FatalFailureInNestedSubroutine (? ms)
[ RUN ] FatalFailureTest.NonfatalFailureInSubroutine [ RUN ] FatalFailureTest.NonfatalFailureInSubroutine
(expecting a failure on false) (expecting a failure on false)
......
...@@ -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_
...@@ -119,7 +119,6 @@ TEST(BarDeathTest, ThreadSafeAndFast) { ...@@ -119,7 +119,6 @@ TEST(BarDeathTest, ThreadSafeAndFast) {
EXPECT_DEATH_IF_SUPPORTED(::testing::internal::posix::Abort(), ""); EXPECT_DEATH_IF_SUPPORTED(::testing::internal::posix::Abort(), "");
} }
#if GTEST_HAS_PARAM_TEST
int g_param_test_count = 0; int g_param_test_count = 0;
const int kNumberOfParamTests = 10; const int kNumberOfParamTests = 10;
...@@ -135,7 +134,6 @@ TEST_P(MyParamTest, ShouldPass) { ...@@ -135,7 +134,6 @@ TEST_P(MyParamTest, ShouldPass) {
INSTANTIATE_TEST_CASE_P(MyParamSequence, INSTANTIATE_TEST_CASE_P(MyParamSequence,
MyParamTest, MyParamTest,
testing::Range(0, kNumberOfParamTests)); testing::Range(0, kNumberOfParamTests));
#endif // GTEST_HAS_PARAM_TEST
// Resets the count for each test. // Resets the count for each test.
void ResetCounts() { void ResetCounts() {
...@@ -144,9 +142,7 @@ void ResetCounts() { ...@@ -144,9 +142,7 @@ void ResetCounts() {
g_should_fail_count = 0; g_should_fail_count = 0;
g_should_pass_count = 0; g_should_pass_count = 0;
g_death_test_count = 0; g_death_test_count = 0;
#if GTEST_HAS_PARAM_TEST
g_param_test_count = 0; g_param_test_count = 0;
#endif // GTEST_HAS_PARAM_TEST
} }
// Checks that the count for each test is expected. // Checks that the count for each test is expected.
...@@ -156,9 +152,7 @@ void CheckCounts(int expected) { ...@@ -156,9 +152,7 @@ void CheckCounts(int expected) {
GTEST_CHECK_INT_EQ_(expected, g_should_fail_count); GTEST_CHECK_INT_EQ_(expected, g_should_fail_count);
GTEST_CHECK_INT_EQ_(expected, g_should_pass_count); GTEST_CHECK_INT_EQ_(expected, g_should_pass_count);
GTEST_CHECK_INT_EQ_(expected, g_death_test_count); GTEST_CHECK_INT_EQ_(expected, g_death_test_count);
#if GTEST_HAS_PARAM_TEST
GTEST_CHECK_INT_EQ_(expected * kNumberOfParamTests, g_param_test_count); GTEST_CHECK_INT_EQ_(expected * kNumberOfParamTests, g_param_test_count);
#endif // GTEST_HAS_PARAM_TEST
} }
// Tests the behavior of Google Test when --gtest_repeat is not specified. // Tests the behavior of Google Test when --gtest_repeat is not specified.
...@@ -201,9 +195,7 @@ void TestRepeatWithFilterForSuccessfulTests(int repeat) { ...@@ -201,9 +195,7 @@ void TestRepeatWithFilterForSuccessfulTests(int repeat) {
GTEST_CHECK_INT_EQ_(0, g_should_fail_count); GTEST_CHECK_INT_EQ_(0, g_should_fail_count);
GTEST_CHECK_INT_EQ_(repeat, g_should_pass_count); GTEST_CHECK_INT_EQ_(repeat, g_should_pass_count);
GTEST_CHECK_INT_EQ_(repeat, g_death_test_count); GTEST_CHECK_INT_EQ_(repeat, g_death_test_count);
#if GTEST_HAS_PARAM_TEST
GTEST_CHECK_INT_EQ_(repeat * kNumberOfParamTests, g_param_test_count); GTEST_CHECK_INT_EQ_(repeat * kNumberOfParamTests, g_param_test_count);
#endif // GTEST_HAS_PARAM_TEST
} }
// Tests using --gtest_repeat when --gtest_filter specifies a set of // Tests using --gtest_repeat when --gtest_filter specifies a set of
...@@ -219,9 +211,7 @@ void TestRepeatWithFilterForFailedTests(int repeat) { ...@@ -219,9 +211,7 @@ void TestRepeatWithFilterForFailedTests(int repeat) {
GTEST_CHECK_INT_EQ_(repeat, g_should_fail_count); GTEST_CHECK_INT_EQ_(repeat, g_should_fail_count);
GTEST_CHECK_INT_EQ_(0, g_should_pass_count); GTEST_CHECK_INT_EQ_(0, g_should_pass_count);
GTEST_CHECK_INT_EQ_(0, g_death_test_count); GTEST_CHECK_INT_EQ_(0, g_death_test_count);
#if GTEST_HAS_PARAM_TEST
GTEST_CHECK_INT_EQ_(0, g_param_test_count); GTEST_CHECK_INT_EQ_(0, g_param_test_count);
#endif // GTEST_HAS_PARAM_TEST
} }
} // namespace } // namespace
......
...@@ -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.
...@@ -3115,13 +3116,13 @@ TEST(DISABLED_TestCase, DISABLED_TestShouldNotRun) { ...@@ -3115,13 +3116,13 @@ TEST(DISABLED_TestCase, DISABLED_TestShouldNotRun) {
FAIL() << "Unexpected failure: Test in disabled test case should not be run."; FAIL() << "Unexpected failure: Test in disabled test case should not be run.";
} }
// Check that when all tests in a test case are disabled, SetupTestCase() and // Check that when all tests in a test case are disabled, SetUpTestCase() and
// TearDownTestCase() are not called. // TearDownTestCase() are not called.
class DisabledTestsTest : public Test { class DisabledTestsTest : public Test {
protected: protected:
static void SetUpTestCase() { static void SetUpTestCase() {
FAIL() << "Unexpected failure: All tests disabled in test case. " FAIL() << "Unexpected failure: All tests disabled in test case. "
"SetupTestCase() should not be called."; "SetUpTestCase() should not be called.";
} }
static void TearDownTestCase() { static void TearDownTestCase() {
...@@ -3528,35 +3529,39 @@ TEST(AssertionTest, EqFailure) { ...@@ -3528,35 +3529,39 @@ 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"
" Which is: 5\n" " foo\n"
"To be equal to: bar\n" " Which is: 5\n"
" Which is: 6", " bar\n"
" Which is: 6",
msg1.c_str()); msg1.c_str());
const std::string msg2( const std::string msg2(
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"
" Which is: 5\n" " foo\n"
"To be equal to: 6", " Which is: 5\n"
" 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"
" Which is: 6", " bar\n"
" 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,10 +3569,11 @@ TEST(AssertionTest, EqFailure) { ...@@ -3564,10 +3569,11 @@ 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"
" Which is: \"x\"\n" " foo\n"
"To be equal to: bar\n" " Which is: \"x\"\n"
" Which is: \"y\"\n" " bar\n"
" Which is: \"y\"\n"
"Ignoring case", "Ignoring case",
msg5.c_str()); msg5.c_str());
} }
...@@ -3580,11 +3586,12 @@ TEST(AssertionTest, EqFailureWithDiff) { ...@@ -3580,11 +3586,12 @@ 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"
" Which is: " " left\n"
" 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",
msg1.c_str()); msg1.c_str());
...@@ -3679,9 +3686,10 @@ TEST(ExpectTest, ASSERT_EQ_Double) { ...@@ -3679,9 +3686,10 @@ 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"
" Which is: 6"); " 2*3\n"
" Which is: 6");
} }
// Tests ASSERT_EQ(NULL, pointer). // Tests ASSERT_EQ(NULL, pointer).
...@@ -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,9 +4400,10 @@ TEST(ExpectTest, ExpectFalseWithAssertionResult) { ...@@ -4390,9 +4400,10 @@ 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"
" Which is: 6"); " 2*3\n"
" 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,10 +4731,11 @@ TEST(EqAssertionTest, WideChar) { ...@@ -4720,10 +4731,11 @@ 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"
" Which is: L'\0' (0, 0x0)\n" " L'\0'\n"
"To be equal to: L'x'\n" " Which is: L'\0' (0, 0x0)\n"
" Which is: L'x' (120, 0x78)"); " L'x'\n"
" Which is: L'x' (120, 0x78)");
static wchar_t wchar; static wchar_t wchar;
wchar = L'b'; wchar = L'b';
...@@ -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,8 +4772,8 @@ TEST(EqAssertionTest, StdString) { ...@@ -4760,8 +4772,8 @@ 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\"");
} }
#if GTEST_HAS_STD_WSTRING #if GTEST_HAS_STD_WSTRING
...@@ -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
...@@ -7655,7 +7667,7 @@ TEST(NativeArrayTest, MethodsWork) { ...@@ -7655,7 +7667,7 @@ TEST(NativeArrayTest, MethodsWork) {
EXPECT_EQ(0, *it); EXPECT_EQ(0, *it);
++it; ++it;
EXPECT_EQ(1, *it); EXPECT_EQ(1, *it);
it++; ++it;
EXPECT_EQ(2, *it); EXPECT_EQ(2, *it);
++it; ++it;
EXPECT_EQ(na.end(), it); EXPECT_EQ(na.end(), it);
......
...@@ -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
set -evx
env | sort
mkdir build || true
mkdir build/$GTEST_TARGET || true
cd build/$GTEST_TARGET
cmake -Dgtest_build_samples=ON \
-Dgmock_build_samples=ON \
-Dgtest_build_tests=ON \
-Dgmock_build_tests=ON \
-DCMAKE_CXX_FLAGS=$CXX_FLAGS \
../../$GTEST_TARGET
make
CTEST_OUTPUT_ON_FAILURE=1 make test
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