Merge branch 'master' into hethi/issue-360-remove-GTEST_HAS_PARAM_TESTS

This commit is contained in:
Gennadiy Civil 2017-11-07 10:32:23 -08:00 committed by GitHub
commit 49eb76df47
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 136 additions and 47 deletions

12
.gitignore vendored
View File

@ -10,3 +10,15 @@ bazel-out
bazel-testlogs bazel-testlogs
# python # python
*.pyc *.pyc
# Visual Studio files
*.sdf
*.opensdf
*.VC.opendb
*.suo
*.user
_ReSharper.Caches/
Win32-Debug/
Win32-Release/
x64-Debug/
x64-Release/

View File

@ -9,7 +9,7 @@ install:
# /usr/bin/clang is 3.4, lets override with modern one. # /usr/bin/clang is 3.4, lets override with modern one.
- if [ "$CXX" = "clang++" ] && [ "$TRAVIS_OS_NAME" = "linux" ]; then export CXX="clang++-3.7" CC="clang-3.7"; ln -sf /usr/bin/ccache /$HOME/bin/$CXX; ln -sf /usr/bin/ccache /$HOME/bin/$CC; fi - if [ "$CXX" = "clang++" ] && [ "$TRAVIS_OS_NAME" = "linux" ]; then export CXX="clang++-3.7" CC="clang-3.7"; ln -sf /usr/bin/ccache /$HOME/bin/$CXX; ln -sf /usr/bin/ccache /$HOME/bin/$CC; fi
# ccache on OS X needs installation first # ccache on OS X needs installation first
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then brew install ccache; export PATH="/usr/local/opt/ccache/libexec:$PATH"; fi - if [ "$TRAVIS_OS_NAME" = "osx" ]; then brew update; brew install ccache; export PATH="/usr/local/opt/ccache/libexec:$PATH"; fi
# reset ccache statistics # reset ccache statistics
- ccache --zero-stats - ccache --zero-stats
- echo ${PATH} - echo ${PATH}

View File

@ -4,6 +4,14 @@ os: Visual Studio 2015
environment: environment:
matrix: matrix:
- compiler: msvc-15-seh
generator: "Visual Studio 15 2017"
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
- compiler: msvc-15-seh
generator: "Visual Studio 15 2017 Win64"
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
- compiler: msvc-14-seh - compiler: msvc-14-seh
generator: "Visual Studio 14 2015" generator: "Visual Studio 14 2015"

View File

@ -65,7 +65,7 @@ can specify it by appending `_WITH_CALLTYPE` to any of the macros
described in the previous two sections and supplying the calling described in the previous two sections and supplying the calling
convention as the first argument to the macro. For example, convention as the first argument to the macro. For example,
``` ```
MOCK_METHOD_1_WITH_CALLTYPE(STDMETHODCALLTYPE, Foo, bool(int n)); MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, Foo, bool(int n));
MOCK_CONST_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE, Bar, int(double x, double y)); MOCK_CONST_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE, Bar, int(double x, double y));
``` ```
where `STDMETHODCALLTYPE` is defined by `<objbase.h>` on Windows. where `STDMETHODCALLTYPE` is defined by `<objbase.h>` on Windows.

View File

@ -1376,7 +1376,8 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
// ================ // ================
// //
// To learn more about using these macros, please search for 'MATCHER' // To learn more about using these macros, please search for 'MATCHER'
// on https://github.com/google/googletest/blob/master/googlemock/docs/CookBook.md // on https://github.com/google/googletest/blob/master/googlemock/docs/
// CookBook.md
#define MATCHER(name, description)\ #define MATCHER(name, description)\
class name##Matcher {\ class name##Matcher {\
@ -1397,8 +1398,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
private:\ private:\
::testing::internal::string FormatDescription(bool negation) const {\ ::testing::internal::string FormatDescription(bool negation) const {\
const ::testing::internal::string gmock_description = (description);\ const ::testing::internal::string gmock_description = (description);\
if (!gmock_description.empty())\ if (!gmock_description.empty()) {\
return gmock_description;\ return gmock_description;\
}\
return ::testing::internal::FormatMatcherDescription(\ return ::testing::internal::FormatMatcherDescription(\
negation, #name, \ negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
@ -1446,8 +1448,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
private:\ private:\
::testing::internal::string FormatDescription(bool negation) const {\ ::testing::internal::string FormatDescription(bool negation) const {\
const ::testing::internal::string gmock_description = (description);\ const ::testing::internal::string gmock_description = (description);\
if (!gmock_description.empty())\ if (!gmock_description.empty()) {\
return gmock_description;\ return gmock_description;\
}\
return ::testing::internal::FormatMatcherDescription(\ return ::testing::internal::FormatMatcherDescription(\
negation, #name, \ negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
@ -1499,8 +1502,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
private:\ private:\
::testing::internal::string FormatDescription(bool negation) const {\ ::testing::internal::string FormatDescription(bool negation) const {\
const ::testing::internal::string gmock_description = (description);\ const ::testing::internal::string gmock_description = (description);\
if (!gmock_description.empty())\ if (!gmock_description.empty()) {\
return gmock_description;\ return gmock_description;\
}\
return ::testing::internal::FormatMatcherDescription(\ return ::testing::internal::FormatMatcherDescription(\
negation, #name, \ negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
@ -1557,8 +1561,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
private:\ private:\
::testing::internal::string FormatDescription(bool negation) const {\ ::testing::internal::string FormatDescription(bool negation) const {\
const ::testing::internal::string gmock_description = (description);\ const ::testing::internal::string gmock_description = (description);\
if (!gmock_description.empty())\ if (!gmock_description.empty()) {\
return gmock_description;\ return gmock_description;\
}\
return ::testing::internal::FormatMatcherDescription(\ return ::testing::internal::FormatMatcherDescription(\
negation, #name, \ negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
@ -1620,8 +1625,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
private:\ private:\
::testing::internal::string FormatDescription(bool negation) const {\ ::testing::internal::string FormatDescription(bool negation) const {\
const ::testing::internal::string gmock_description = (description);\ const ::testing::internal::string gmock_description = (description);\
if (!gmock_description.empty())\ if (!gmock_description.empty()) {\
return gmock_description;\ return gmock_description;\
}\
return ::testing::internal::FormatMatcherDescription(\ return ::testing::internal::FormatMatcherDescription(\
negation, #name, \ negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
@ -1691,8 +1697,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
private:\ private:\
::testing::internal::string FormatDescription(bool negation) const {\ ::testing::internal::string FormatDescription(bool negation) const {\
const ::testing::internal::string gmock_description = (description);\ const ::testing::internal::string gmock_description = (description);\
if (!gmock_description.empty())\ if (!gmock_description.empty()) {\
return gmock_description;\ return gmock_description;\
}\
return ::testing::internal::FormatMatcherDescription(\ return ::testing::internal::FormatMatcherDescription(\
negation, #name, \ negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
@ -1765,8 +1772,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
private:\ private:\
::testing::internal::string FormatDescription(bool negation) const {\ ::testing::internal::string FormatDescription(bool negation) const {\
const ::testing::internal::string gmock_description = (description);\ const ::testing::internal::string gmock_description = (description);\
if (!gmock_description.empty())\ if (!gmock_description.empty()) {\
return gmock_description;\ return gmock_description;\
}\
return ::testing::internal::FormatMatcherDescription(\ return ::testing::internal::FormatMatcherDescription(\
negation, #name, \ negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
@ -1843,8 +1851,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
private:\ private:\
::testing::internal::string FormatDescription(bool negation) const {\ ::testing::internal::string FormatDescription(bool negation) const {\
const ::testing::internal::string gmock_description = (description);\ const ::testing::internal::string gmock_description = (description);\
if (!gmock_description.empty())\ if (!gmock_description.empty()) {\
return gmock_description;\ return gmock_description;\
}\
return ::testing::internal::FormatMatcherDescription(\ return ::testing::internal::FormatMatcherDescription(\
negation, #name, \ negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
@ -1928,8 +1937,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
private:\ private:\
::testing::internal::string FormatDescription(bool negation) const {\ ::testing::internal::string FormatDescription(bool negation) const {\
const ::testing::internal::string gmock_description = (description);\ const ::testing::internal::string gmock_description = (description);\
if (!gmock_description.empty())\ if (!gmock_description.empty()) {\
return gmock_description;\ return gmock_description;\
}\
return ::testing::internal::FormatMatcherDescription(\ return ::testing::internal::FormatMatcherDescription(\
negation, #name, \ negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
@ -2019,8 +2029,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
private:\ private:\
::testing::internal::string FormatDescription(bool negation) const {\ ::testing::internal::string FormatDescription(bool negation) const {\
const ::testing::internal::string gmock_description = (description);\ const ::testing::internal::string gmock_description = (description);\
if (!gmock_description.empty())\ if (!gmock_description.empty()) {\
return gmock_description;\ return gmock_description;\
}\
return ::testing::internal::FormatMatcherDescription(\ return ::testing::internal::FormatMatcherDescription(\
negation, #name, \ negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
@ -2115,8 +2126,9 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
private:\ private:\
::testing::internal::string FormatDescription(bool negation) const {\ ::testing::internal::string FormatDescription(bool negation) const {\
const ::testing::internal::string gmock_description = (description);\ const ::testing::internal::string gmock_description = (description);\
if (!gmock_description.empty())\ if (!gmock_description.empty()) {\
return gmock_description;\ return gmock_description;\
}\
return ::testing::internal::FormatMatcherDescription(\ return ::testing::internal::FormatMatcherDescription(\
negation, #name, \ negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\

View File

@ -639,8 +639,9 @@ $var param_field_decls2 = [[$for j
private:\ private:\
::testing::internal::string FormatDescription(bool negation) const {\ ::testing::internal::string FormatDescription(bool negation) const {\
const ::testing::internal::string gmock_description = (description);\ const ::testing::internal::string gmock_description = (description);\
if (!gmock_description.empty())\ if (!gmock_description.empty()) {\
return gmock_description;\ return gmock_description;\
}\
return ::testing::internal::FormatMatcherDescription(\ return ::testing::internal::FormatMatcherDescription(\
negation, #name, \ negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\

View File

@ -120,7 +120,7 @@ TEST(ArgsTest, AcceptsOneTemplateArg) {
} }
TEST(ArgsTest, AcceptsTwoTemplateArgs) { TEST(ArgsTest, AcceptsTwoTemplateArgs) {
const tuple<short, int, long> t(4, 5, 6L); // NOLINT const tuple<short, int, long> t(static_cast<short>(4), 5, 6L); // NOLINT
EXPECT_THAT(t, (Args<0, 1>(Lt()))); EXPECT_THAT(t, (Args<0, 1>(Lt())));
EXPECT_THAT(t, (Args<1, 2>(Lt()))); EXPECT_THAT(t, (Args<1, 2>(Lt())));
@ -128,13 +128,13 @@ TEST(ArgsTest, AcceptsTwoTemplateArgs) {
} }
TEST(ArgsTest, AcceptsRepeatedTemplateArgs) { TEST(ArgsTest, AcceptsRepeatedTemplateArgs) {
const tuple<short, int, long> t(4, 5, 6L); // NOLINT const tuple<short, int, long> t(static_cast<short>(4), 5, 6L); // NOLINT
EXPECT_THAT(t, (Args<0, 0>(Eq()))); EXPECT_THAT(t, (Args<0, 0>(Eq())));
EXPECT_THAT(t, Not(Args<1, 1>(Ne()))); EXPECT_THAT(t, Not(Args<1, 1>(Ne())));
} }
TEST(ArgsTest, AcceptsDecreasingTemplateArgs) { TEST(ArgsTest, AcceptsDecreasingTemplateArgs) {
const tuple<short, int, long> t(4, 5, 6L); // NOLINT const tuple<short, int, long> t(static_cast<short>(4), 5, 6L); // NOLINT
EXPECT_THAT(t, (Args<2, 0>(Gt()))); EXPECT_THAT(t, (Args<2, 0>(Gt())));
EXPECT_THAT(t, Not(Args<2, 1>(Lt()))); EXPECT_THAT(t, Not(Args<2, 1>(Lt())));
} }
@ -159,7 +159,7 @@ TEST(ArgsTest, AcceptsMoreTemplateArgsThanArityOfOriginalTuple) {
} }
TEST(ArgsTest, CanBeNested) { TEST(ArgsTest, CanBeNested) {
const tuple<short, int, long, int> t(4, 5, 6L, 6); // NOLINT const tuple<short, int, long, int> t(static_cast<short>(4), 5, 6L, 6); // NOLINT
EXPECT_THAT(t, (Args<1, 2, 3>(Args<1, 2>(Eq())))); EXPECT_THAT(t, (Args<1, 2, 3>(Args<1, 2>(Eq()))));
EXPECT_THAT(t, (Args<0, 1, 3>(Args<0, 2>(Lt())))); EXPECT_THAT(t, (Args<0, 1, 3>(Args<0, 2>(Lt()))));
} }

View File

@ -58,6 +58,11 @@
# include <forward_list> // NOLINT # include <forward_list> // NOLINT
#endif #endif
// Disable MSVC2015 warning for std::pair: "decorated name length exceeded, name was truncated".
#if defined(_MSC_VER) && (_MSC_VER == 1900)
# pragma warning(disable:4503)
#endif
namespace testing { namespace testing {
namespace internal { namespace internal {
@ -3931,8 +3936,11 @@ TEST(ResultOfTest, WorksForFunctionReferences) {
// Tests that ResultOf(f, ...) compiles and works as expected when f is a // Tests that ResultOf(f, ...) compiles and works as expected when f is a
// function object. // function object.
struct Functor : public ::std::unary_function<int, std::string> { struct Functor {
result_type operator()(argument_type input) const { typedef std::string result_type;
typedef int argument_type;
std::string operator()(int input) const {
return IntToStringFunction(input); return IntToStringFunction(input);
} }
}; };

View File

@ -161,7 +161,8 @@ Existing build's `CMakeLists.txt`:
# Add googletest directly to our build. This defines # Add googletest directly to our build. This defines
# the gtest and gtest_main targets. # the gtest and gtest_main targets.
add_subdirectory(${CMAKE_BINARY_DIR}/googletest-src add_subdirectory(${CMAKE_BINARY_DIR}/googletest-src
${CMAKE_BINARY_DIR}/googletest-build) ${CMAKE_BINARY_DIR}/googletest-build
EXCLUDE_FROM_ALL)
# The gtest/gtest_main targets carry header search path # The gtest/gtest_main targets carry header search path
# dependencies automatically when using CMake 2.8.11 or # dependencies automatically when using CMake 2.8.11 or
@ -182,6 +183,17 @@ technique is discussed in more detail in
which also contains a link to a fully generalized implementation which also contains a link to a fully generalized implementation
of the technique. of the technique.
##### Visual Studio Dynamic vs Static Runtimes #####
By default, new Visual Studio projects link the C runtimes dynamically
but Google Test links them statically.
This will generate an error that looks something like the following:
gtest.lib(gtest-all.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj
Google Test already has a CMake option for this: `gtest_force_shared_crt`
Enabling this option will make gtest link the runtimes dynamically too,
and match the project in which it is included.
### Legacy Build Scripts ### ### Legacy Build Scripts ###

View File

@ -87,10 +87,6 @@ macro(config_compiler_and_linker)
# http://stackoverflow.com/questions/3232669 explains the issue. # http://stackoverflow.com/questions/3232669 explains the issue.
set(cxx_base_flags "${cxx_base_flags} -wd4702") set(cxx_base_flags "${cxx_base_flags} -wd4702")
endif() 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} -D_UNICODE -DUNICODE -DWIN32 -D_WIN32")
set(cxx_base_flags "${cxx_base_flags} -DSTRICT -DWIN32_LEAN_AND_MEAN") 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. # is built from the given source files with the given compiler flags.
function(cxx_executable_with_flags name cxx_flags libs) function(cxx_executable_with_flags name cxx_flags libs)
add_executable(${name} ${ARGN}) 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) if (cxx_flags)
set_target_properties(${name} set_target_properties(${name}
PROPERTIES PROPERTIES

View File

@ -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) {
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
function in parentheses: function in parentheses:
``` cpp ``` cpp
ASSERT_PRED2(*(GreaterThan<int, int>)*, 5, 0); ASSERT_PRED2((GreaterThan<int, int>), 5, 0);
``` ```

View File

@ -324,7 +324,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
@ -356,12 +356,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.
@ -659,7 +663,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
@ -2054,7 +2059,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()) {}
@ -2186,7 +2191,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) {}

View File

@ -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;
#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) {
::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) {
::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));

View File

@ -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() {