summaryrefslogtreecommitdiffstats
path: root/googletest
diff options
context:
space:
mode:
authorArkadiy Shapkin <arkady.shapkin@gmail.com>2017-05-03 10:40:33 (GMT)
committerArkady Shapkin <arkady.shapkin@gmail.com>2017-10-25 13:04:01 (GMT)
commit2641b021fc2ab12896cf868d90f19936ef4b4696 (patch)
tree94f1a3f223b38d4830d639f8b892378ff8c69443 /googletest
parent77380cddf77133b98a16b5427ac732648233de29 (diff)
downloadgoogletest-2641b021fc2ab12896cf868d90f19936ef4b4696.zip
googletest-2641b021fc2ab12896cf868d90f19936ef4b4696.tar.gz
googletest-2641b021fc2ab12896cf868d90f19936ef4b4696.tar.bz2
Fix tests with VS2015 and VS2017
Diffstat (limited to 'googletest')
-rw-r--r--googletest/cmake/internal_utils.cmake8
-rw-r--r--googletest/test/gtest-printers_test.cc51
-rw-r--r--googletest/test/gtest_catch_exceptions_test_.cc2
3 files changed, 46 insertions, 15 deletions
diff --git a/googletest/cmake/internal_utils.cmake b/googletest/cmake/internal_utils.cmake
index 9915c11..c54bc94 100644
--- a/googletest/cmake/internal_utils.cmake
+++ b/googletest/cmake/internal_utils.cmake
@@ -87,10 +87,6 @@ macro(config_compiler_and_linker)
# http://stackoverflow.com/questions/3232669 explains the issue.
set(cxx_base_flags "${cxx_base_flags} -wd4702")
endif()
- if (NOT (MSVC_VERSION GREATER 1900)) # 1900 is Visual Studio 2015
- # BigObj required for tests.
- set(cxx_base_flags "${cxx_base_flags} -bigobj")
- endif()
set(cxx_base_flags "${cxx_base_flags} -D_UNICODE -DUNICODE -DWIN32 -D_WIN32")
set(cxx_base_flags "${cxx_base_flags} -DSTRICT -DWIN32_LEAN_AND_MEAN")
@@ -187,6 +183,10 @@ endfunction()
# is built from the given source files with the given compiler flags.
function(cxx_executable_with_flags name cxx_flags libs)
add_executable(${name} ${ARGN})
+ if (MSVC AND (NOT (MSVC_VERSION LESS 1700))) # 1700 is Visual Studio 2012.
+ # BigObj required for tests.
+ set(cxx_flags "${cxx_flags} -bigobj")
+ endif()
if (cxx_flags)
set_target_properties(${name}
PROPERTIES
diff --git a/googletest/test/gtest-printers_test.cc b/googletest/test/gtest-printers_test.cc
index 487d3cb..2a6c017 100644
--- a/googletest/test/gtest-printers_test.cc
+++ b/googletest/test/gtest-printers_test.cc
@@ -51,10 +51,15 @@
#include "gtest/gtest.h"
// 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
#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
#endif // GTEST_HAS_HASH_SET_
@@ -239,21 +244,47 @@ using ::testing::internal::UniversalTersePrintTupleFieldsToStrings;
#endif
using ::testing::internal::string;
-#if GTEST_HAS_HASH_MAP_
// 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<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.
using ::std::hash_map;
-using ::std::hash_set;
using ::std::hash_multimap;
-using ::std::hash_multiset;
#elif _MSC_VER
using ::stdext::hash_map;
-using ::stdext::hash_set;
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;
#endif
+
#endif
// Prints a value to a string using the universal value printer. This
@@ -1061,8 +1092,8 @@ TEST(PrintTr1TupleTest, VariousSizes) {
::std::tr1::tuple<bool, char, short, testing::internal::Int32, // NOLINT
testing::internal::Int64, float, double, const char*, void*,
std::string>
- t10(false, 'a', 3, 4, 5, 1.5F, -2.5, str, ImplicitCast_<void*>(NULL),
- "10");
+ t10(false, 'a', static_cast<short>(3), 4, 5, 1.5F, -2.5, str,
+ ImplicitCast_<void*>(NULL), "10");
EXPECT_EQ("(false, 'a' (97, 0x61), 3, 4, 5, 1.5, -2.5, " + PrintPointer(str) +
" pointing to \"8\", NULL, \"10\")",
Print(t10));
@@ -1121,8 +1152,8 @@ TEST(PrintStdTupleTest, VariousSizes) {
::std::tuple<bool, char, short, testing::internal::Int32, // NOLINT
testing::internal::Int64, float, double, const char*, void*,
std::string>
- t10(false, 'a', 3, 4, 5, 1.5F, -2.5, str, ImplicitCast_<void*>(NULL),
- "10");
+ t10(false, 'a', static_cast<short>(3), 4, 5, 1.5F, -2.5, str,
+ ImplicitCast_<void*>(NULL), "10");
EXPECT_EQ("(false, 'a' (97, 0x61), 3, 4, 5, 1.5, -2.5, " + PrintPointer(str) +
" pointing to \"8\", NULL, \"10\")",
Print(t10));
diff --git a/googletest/test/gtest_catch_exceptions_test_.cc b/googletest/test/gtest_catch_exceptions_test_.cc
index b42637e..c6d953c 100644
--- a/googletest/test/gtest_catch_exceptions_test_.cc
+++ b/googletest/test/gtest_catch_exceptions_test_.cc
@@ -138,7 +138,7 @@ TEST_F(CxxExceptionInConstructorTest, ThrowsExceptionInConstructor) {
}
// 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 {
public:
static void TearDownTestCase() {