From af463c43ac22279239c1b8065ded7026b9224de1 Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Tue, 13 Mar 2018 11:13:37 -0400 Subject: [PATCH 1/4] More merges, removing old dead code --- googlemock/include/gmock/gmock-actions.h | 11 ++-- googlemock/test/gmock-actions_test.cc | 4 +- .../include/gtest/internal/gtest-port.h | 14 ++--- googletest/test/gtest-printers_test.cc | 57 ------------------- 4 files changed, 14 insertions(+), 72 deletions(-) diff --git a/googlemock/include/gmock/gmock-actions.h b/googlemock/include/gmock/gmock-actions.h index 845c8232..90fd2ea6 100644 --- a/googlemock/include/gmock/gmock-actions.h +++ b/googlemock/include/gmock/gmock-actions.h @@ -46,9 +46,10 @@ #include "gmock/internal/gmock-internal-utils.h" #include "gmock/internal/gmock-port.h" -#if GTEST_HAS_STD_TYPE_TRAITS_ // Defined by gtest-port.h via gmock-port.h. +#if GTEST_LANG_CXX11 // Defined by gtest-port.h via gmock-port.h. +#include #include -#endif +#endif // GTEST_LANG_CXX11 namespace testing { @@ -96,7 +97,7 @@ struct BuiltInDefaultValueGetter { template class BuiltInDefaultValue { public: -#if GTEST_HAS_STD_TYPE_TRAITS_ +#if GTEST_LANG_CXX11 // This function returns true iff type T has a built-in default value. static bool Exists() { return ::std::is_default_constructible::value; @@ -107,7 +108,7 @@ class BuiltInDefaultValue { T, ::std::is_default_constructible::value>::Get(); } -#else // GTEST_HAS_STD_TYPE_TRAITS_ +#else // GTEST_LANG_CXX11 // This function returns true iff type T has a built-in default value. static bool Exists() { return false; @@ -117,7 +118,7 @@ class BuiltInDefaultValue { return BuiltInDefaultValueGetter::Get(); } -#endif // GTEST_HAS_STD_TYPE_TRAITS_ +#endif // GTEST_LANG_CXX11 }; // This partial specialization says that we use the same built-in diff --git a/googlemock/test/gmock-actions_test.cc b/googlemock/test/gmock-actions_test.cc index 9447c22b..01286634 100644 --- a/googlemock/test/gmock-actions_test.cc +++ b/googlemock/test/gmock-actions_test.cc @@ -218,7 +218,7 @@ class MyNonDefaultConstructible { int value_; }; -#if GTEST_HAS_STD_TYPE_TRAITS_ +#if GTEST_LANG_CXX11 TEST(BuiltInDefaultValueTest, ExistsForDefaultConstructibleType) { EXPECT_TRUE(BuiltInDefaultValue::Exists()); @@ -228,7 +228,7 @@ TEST(BuiltInDefaultValueTest, IsDefaultConstructedForDefaultConstructibleType) { EXPECT_EQ(42, BuiltInDefaultValue::Get().value()); } -#endif // GTEST_HAS_STD_TYPE_TRAITS_ +#endif // GTEST_LANG_CXX11 TEST(BuiltInDefaultValueTest, DoesNotExistForNonDefaultConstructibleType) { EXPECT_FALSE(BuiltInDefaultValue::Exists()); diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index 7a10d903..ccbdb76f 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -363,16 +363,14 @@ #if GTEST_STDLIB_CXX11 # define GTEST_HAS_STD_BEGIN_AND_END_ 1 # define GTEST_HAS_STD_FORWARD_LIST_ 1 -# if !defined(_MSC_VER) || (_MSC_FULL_VER >= 190023824) // works only with VS2015U2 and better +# if !defined(_MSC_VER) || (_MSC_FULL_VER >= 190023824) +// works only with VS2015U2 and better # define GTEST_HAS_STD_FUNCTION_ 1 # endif # define GTEST_HAS_STD_INITIALIZER_LIST_ 1 # define GTEST_HAS_STD_MOVE_ 1 -# define GTEST_HAS_STD_SHARED_PTR_ 1 -# define GTEST_HAS_STD_TYPE_TRAITS_ 1 # define GTEST_HAS_STD_UNIQUE_PTR_ 1 -# define GTEST_HAS_UNORDERED_MAP_ 1 -# define GTEST_HAS_UNORDERED_SET_ 1 +# define GTEST_HAS_STD_SHARED_PTR_ 1 #endif // C++11 specifies that provides std::tuple. @@ -982,13 +980,13 @@ using ::std::tuple_size; # endif #elif __GNUC__ >= 4 || defined(__clang__) # define GTEST_API_ __attribute__((visibility ("default"))) -#endif // _MSC_VER +#endif // _MSC_VER -#endif // GTEST_API_ +#endif // GTEST_API_ #ifndef GTEST_API_ # define GTEST_API_ -#endif // GTEST_API_ +#endif // GTEST_API_ #ifndef GTEST_DEFAULT_DEATH_TEST_STYLE # define GTEST_DEFAULT_DEATH_TEST_STYLE "fast" diff --git a/googletest/test/gtest-printers_test.cc b/googletest/test/gtest-printers_test.cc index cd7c5d34..686e62a8 100644 --- a/googletest/test/gtest-printers_test.cc +++ b/googletest/test/gtest-printers_test.cc @@ -50,19 +50,6 @@ #include "gtest/gtest.h" -// hash_map and hash_set are available under Visual C++, or on Linux. -#if GTEST_HAS_UNORDERED_MAP_ -# include // NOLINT -#elif GTEST_HAS_HASH_MAP_ -# include // NOLINT -#endif // GTEST_HAS_HASH_MAP_ - -#if GTEST_HAS_UNORDERED_SET_ -# include // NOLINT -#elif GTEST_HAS_HASH_SET_ -# include // NOLINT -#endif // GTEST_HAS_HASH_SET_ - #if GTEST_HAS_STD_FORWARD_LIST_ # include // NOLINT #endif // GTEST_HAS_STD_FORWARD_LIST_ @@ -240,50 +227,6 @@ using ::testing::internal::UniversalTersePrint; using ::testing::internal::UniversalTersePrintTupleFieldsToStrings; #endif - -// 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 ::. -#if GTEST_HAS_UNORDERED_MAP_ - -#define GTEST_HAS_HASH_MAP_ 1 -template -using hash_map = ::std::unordered_map; -template -using hash_multimap = ::std::unordered_multimap; - -#elif GTEST_HAS_HASH_MAP_ - -#ifdef _STLP_HASH_MAP // We got from STLport. -using ::std::hash_map; -using ::std::hash_multimap; -#elif _MSC_VER -using ::stdext::hash_map; -using ::stdext::hash_multimap; -#endif - -#endif - -#if GTEST_HAS_UNORDERED_SET_ - -#define GTEST_HAS_HASH_SET_ 1 -template -using hash_set = ::std::unordered_set; -template -using hash_multiset = ::std::unordered_multiset; - -#elif GTEST_HAS_HASH_SET_ - -#ifdef _STLP_HASH_MAP // We got from STLport. -using ::std::hash_map; -using ::std::hash_multimap; -#elif _MSC_VER -using ::stdext::hash_map; -using ::stdext::hash_multimap; -#endif - -#endif - // Prints a value to a string using the universal value printer. This // is a helper for testing UniversalPrinter::Print() for various types. template From a719320a3ce448dad588f0d5506e47fe84fa9d16 Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Tue, 13 Mar 2018 11:53:27 -0400 Subject: [PATCH 2/4] fixing, was removing too much --- googletest/test/gtest-printers_test.cc | 37 ++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/googletest/test/gtest-printers_test.cc b/googletest/test/gtest-printers_test.cc index 686e62a8..1584de43 100644 --- a/googletest/test/gtest-printers_test.cc +++ b/googletest/test/gtest-printers_test.cc @@ -50,6 +50,15 @@ #include "gtest/gtest.h" +// hash_set are available under Visual C++, or on Linux. +#if GTEST_HAS_HASH_MAP_ +# include // NOLINT +#endif // GTEST_HAS_HASH_MAP_ + +#if GTEST_HAS_HASH_SET_ +# include // NOLINT +#endif // GTEST_HAS_HASH_SET_ + #if GTEST_HAS_STD_FORWARD_LIST_ # include // NOLINT #endif // GTEST_HAS_STD_FORWARD_LIST_ @@ -227,6 +236,34 @@ using ::testing::internal::UniversalTersePrint; using ::testing::internal::UniversalTersePrintTupleFieldsToStrings; #endif + +// 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 ::. +#if GTEST_HAS_HASH_MAP_ + +#ifdef _STLP_HASH_MAP // We got from STLport. +using ::std::hash_map; +using ::std::hash_multimap; +#elif _MSC_VER +using ::stdext::hash_map; +using ::stdext::hash_multimap; +#endif + +#endif + +#if GTEST_HAS_HASH_SET_ + +#ifdef _STLP_HASH_MAP // We got from STLport. +using ::std::hash_map; +using ::std::hash_multimap; +#elif _MSC_VER +using ::stdext::hash_map; +using ::stdext::hash_multimap; +#endif + +#endif + // Prints a value to a string using the universal value printer. This // is a helper for testing UniversalPrinter::Print() for various types. template From 2814b4b08910d62f8516cd3e4e77ef99ee7360e9 Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Tue, 13 Mar 2018 16:02:05 -0400 Subject: [PATCH 3/4] merging, merging --- .../include/gtest/internal/gtest-port.h | 2 + googletest/test/gtest-printers_test.cc | 60 +++++++------------ 2 files changed, 23 insertions(+), 39 deletions(-) diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index ccbdb76f..3e4f7b58 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -371,6 +371,8 @@ # define GTEST_HAS_STD_MOVE_ 1 # define GTEST_HAS_STD_UNIQUE_PTR_ 1 # define GTEST_HAS_STD_SHARED_PTR_ 1 +# define GTEST_HAS_UNORDERED_MAP_ 1 +# define GTEST_HAS_UNORDERED_SET_ 1 #endif // C++11 specifies that provides std::tuple. diff --git a/googletest/test/gtest-printers_test.cc b/googletest/test/gtest-printers_test.cc index 1584de43..cf8bccee 100644 --- a/googletest/test/gtest-printers_test.cc +++ b/googletest/test/gtest-printers_test.cc @@ -50,14 +50,13 @@ #include "gtest/gtest.h" -// hash_set are available under Visual C++, or on Linux. -#if GTEST_HAS_HASH_MAP_ -# include // NOLINT -#endif // GTEST_HAS_HASH_MAP_ +#if GTEST_HAS_UNORDERED_MAP_ +# include // NOLINT +#endif // GTEST_HAS_UNORDERED_MAP_ -#if GTEST_HAS_HASH_SET_ -# include // NOLINT -#endif // GTEST_HAS_HASH_SET_ +#if GTEST_HAS_UNORDERED_SET_ +# include // NOLINT +#endif // GTEST_HAS_UNORDERED_SET_ #if GTEST_HAS_STD_FORWARD_LIST_ # include // NOLINT @@ -236,34 +235,6 @@ using ::testing::internal::UniversalTersePrint; using ::testing::internal::UniversalTersePrintTupleFieldsToStrings; #endif - -// 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 ::. -#if GTEST_HAS_HASH_MAP_ - -#ifdef _STLP_HASH_MAP // We got from STLport. -using ::std::hash_map; -using ::std::hash_multimap; -#elif _MSC_VER -using ::stdext::hash_map; -using ::stdext::hash_multimap; -#endif - -#endif - -#if GTEST_HAS_HASH_SET_ - -#ifdef _STLP_HASH_MAP // We got from STLport. -using ::std::hash_map; -using ::std::hash_multimap; -#elif _MSC_VER -using ::stdext::hash_map; -using ::stdext::hash_multimap; -#endif - -#endif - // Prints a value to a string using the universal value printer. This // is a helper for testing UniversalPrinter::Print() for various types. template @@ -848,7 +819,13 @@ TEST(PrintStlContainerTest, NonEmptyDeque) { EXPECT_EQ("{ 1, 3 }", Print(non_empty)); } -#if GTEST_HAS_HASH_MAP_ +#if GTEST_HAS_UNORDERED_MAP_ + +template +using hash_map = ::std::unordered_map; +template +using hash_multimap = ::std::unordered_multimap; + TEST(PrintStlContainerTest, OneElementHashMap) { hash_map map1; @@ -868,9 +845,14 @@ TEST(PrintStlContainerTest, HashMultiMap) { << " where Print(map1) returns \"" << result << "\"."; } -#endif // GTEST_HAS_HASH_MAP_ +#endif // GTEST_HAS_UNORDERED_MAP_ -#if GTEST_HAS_HASH_SET_ +#if GTEST_HAS_UNORDERED_SET_ + +template +using hash_set = ::std::unordered_set; +template +using hash_multiset = ::std::unordered_multiset; TEST(PrintStlContainerTest, HashSet) { hash_set set1; @@ -907,7 +889,7 @@ TEST(PrintStlContainerTest, HashMultiSet) { EXPECT_TRUE(std::equal(a, a + kSize, numbers.begin())); } -#endif // GTEST_HAS_HASH_SET_ +#endif // GTEST_HAS_UNORDERED_SET_ TEST(PrintStlContainerTest, List) { const std::string a[] = {"hello", "world"}; From 262aaf2f1dbf13df1aa0c303595b45981824fc8a Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Wed, 14 Mar 2018 10:49:18 -0400 Subject: [PATCH 4/4] erging, cont --- googletest/test/gtest-printers_test.cc | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/googletest/test/gtest-printers_test.cc b/googletest/test/gtest-printers_test.cc index cf8bccee..ccac35b4 100644 --- a/googletest/test/gtest-printers_test.cc +++ b/googletest/test/gtest-printers_test.cc @@ -821,20 +821,14 @@ TEST(PrintStlContainerTest, NonEmptyDeque) { #if GTEST_HAS_UNORDERED_MAP_ -template -using hash_map = ::std::unordered_map; -template -using hash_multimap = ::std::unordered_multimap; - - TEST(PrintStlContainerTest, OneElementHashMap) { - hash_map map1; + ::std::unordered_map map1; map1[1] = 'a'; EXPECT_EQ("{ (1, 'a' (97, 0x61)) }", Print(map1)); } TEST(PrintStlContainerTest, HashMultiMap) { - hash_multimap map1; + ::std::unordered_multimap map1; map1.insert(make_pair(5, true)); map1.insert(make_pair(5, false)); @@ -849,13 +843,8 @@ TEST(PrintStlContainerTest, HashMultiMap) { #if GTEST_HAS_UNORDERED_SET_ -template -using hash_set = ::std::unordered_set; -template -using hash_multiset = ::std::unordered_multiset; - TEST(PrintStlContainerTest, HashSet) { - hash_set set1; + ::std::unordered_set set1; set1.insert(1); EXPECT_EQ("{ 1 }", Print(set1)); } @@ -863,7 +852,7 @@ TEST(PrintStlContainerTest, HashSet) { TEST(PrintStlContainerTest, HashMultiSet) { const int kSize = 5; int a[kSize] = { 1, 1, 2, 5, 1 }; - hash_multiset set1(a, a + kSize); + ::std::unordered_multiset set1(a, a + kSize); // Elements of hash_multiset can be printed in any order. const std::string result = Print(set1);