This commit is contained in:
Jerry Turcios 2018-10-09 20:47:38 -04:00
commit 274b39bfa0
39 changed files with 1466 additions and 4328 deletions

View File

@ -16,10 +16,8 @@ This repository is a merger of the formerly separate GoogleTest and
GoogleMock projects. These were so closely related that it makes sense to
maintain and release them together.
Please see the project page above for more information as well as the
mailing list for questions, discussions, and development. There is
also an IRC channel on [OFTC](https://webchat.oftc.net/) (irc.oftc.net) #gtest available. Please
join us!
Please the mailing list at googletestframework@googlegroups.com for questions, discussions, and development.
There is also an IRC channel on [OFTC](https://webchat.oftc.net/) (irc.oftc.net) #gtest available.
Getting started information for **Google Test** is available in the
[Google Test Primer](googletest/docs/primer.md) documentation.

View File

@ -1,126 +0,0 @@
Changes for 1.7.0:
* All new improvements in Google Test 1.7.0.
* New feature: matchers DoubleNear(), FloatNear(),
NanSensitiveDoubleNear(), NanSensitiveFloatNear(),
UnorderedElementsAre(), UnorderedElementsAreArray(), WhenSorted(),
WhenSortedBy(), IsEmpty(), and SizeIs().
* Improvement: Google Mock can now be built as a DLL.
* Improvement: when compiled by a C++11 compiler, matchers AllOf()
and AnyOf() can accept an arbitrary number of matchers.
* Improvement: when compiled by a C++11 compiler, matchers
ElementsAreArray() can accept an initializer list.
* Improvement: when exceptions are enabled, a mock method with no
default action now throws instead crashing the test.
* Improvement: added class testing::StringMatchResultListener to aid
definition of composite matchers.
* Improvement: function return types used in MOCK_METHOD*() macros can
now contain unprotected commas.
* Improvement (potentially breaking): EXPECT_THAT() and ASSERT_THAT()
are now more strict in ensuring that the value type and the matcher
type are compatible, catching potential bugs in tests.
* Improvement: Pointee() now works on an optional<T>.
* Improvement: the ElementsAreArray() matcher can now take a vector or
iterator range as input, and makes a copy of its input elements
before the conversion to a Matcher.
* Improvement: the Google Mock Generator can now generate mocks for
some class templates.
* Bug fix: mock object destruction triggerred by another mock object's
destruction no longer hangs.
* Improvement: Google Mock Doctor works better with newer Clang and
GCC now.
* Compatibility fixes.
* Bug/warning fixes.
Changes for 1.6.0:
* Compilation is much faster and uses much less memory, especially
when the constructor and destructor of a mock class are moved out of
the class body.
* New matchers: Pointwise(), Each().
* New actions: ReturnPointee() and ReturnRefOfCopy().
* CMake support.
* Project files for Visual Studio 2010.
* AllOf() and AnyOf() can handle up-to 10 arguments now.
* Google Mock doctor understands Clang error messages now.
* SetArgPointee<> now accepts string literals.
* gmock_gen.py handles storage specifier macros and template return
types now.
* Compatibility fixes.
* Bug fixes and implementation clean-ups.
* Potentially incompatible changes: disables the harmful 'make install'
command in autotools.
Potentially breaking changes:
* The description string for MATCHER*() changes from Python-style
interpolation to an ordinary C++ string expression.
* SetArgumentPointee is deprecated in favor of SetArgPointee.
* Some non-essential project files for Visual Studio 2005 are removed.
Changes for 1.5.0:
* New feature: Google Mock can be safely used in multi-threaded tests
on platforms having pthreads.
* New feature: function for printing a value of arbitrary type.
* New feature: function ExplainMatchResult() for easy definition of
composite matchers.
* The new matcher API lets user-defined matchers generate custom
explanations more directly and efficiently.
* Better failure messages all around.
* NotNull() and IsNull() now work with smart pointers.
* Field() and Property() now work when the matcher argument is a pointer
passed by reference.
* Regular expression matchers on all platforms.
* Added GCC 4.0 support for Google Mock Doctor.
* Added gmock_all_test.cc for compiling most Google Mock tests
in a single file.
* Significantly cleaned up compiler warnings.
* Bug fixes, better test coverage, and implementation clean-ups.
Potentially breaking changes:
* Custom matchers defined using MatcherInterface or MakePolymorphicMatcher()
need to be updated after upgrading to Google Mock 1.5.0; matchers defined
using MATCHER or MATCHER_P* aren't affected.
* Dropped support for 'make install'.
Changes for 1.4.0 (we skipped 1.2.* and 1.3.* to match the version of
Google Test):
* Works in more environments: Symbian and minGW, Visual C++ 7.1.
* Lighter weight: comes with our own implementation of TR1 tuple (no
more dependency on Boost!).
* New feature: --gmock_catch_leaked_mocks for detecting leaked mocks.
* New feature: ACTION_TEMPLATE for defining templatized actions.
* New feature: the .After() clause for specifying expectation order.
* New feature: the .With() clause for specifying inter-argument
constraints.
* New feature: actions ReturnArg<k>(), ReturnNew<T>(...), and
DeleteArg<k>().
* New feature: matchers Key(), Pair(), Args<...>(), AllArgs(), IsNull(),
and Contains().
* New feature: utility class MockFunction<F>, useful for checkpoints, etc.
* New feature: functions Value(x, m) and SafeMatcherCast<T>(m).
* New feature: copying a mock object is rejected at compile time.
* New feature: a script for fusing all Google Mock and Google Test
source files for easy deployment.
* Improved the Google Mock doctor to diagnose more diseases.
* Improved the Google Mock generator script.
* Compatibility fixes for Mac OS X and gcc.
* Bug fixes and implementation clean-ups.
Changes for 1.1.0:
* New feature: ability to use Google Mock with any testing framework.
* New feature: macros for easily defining new matchers
* New feature: macros for easily defining new actions.
* New feature: more container matchers.
* New feature: actions for accessing function arguments and throwing
exceptions.
* Improved the Google Mock doctor script for diagnosing compiler errors.
* Bug fixes and implementation clean-ups.
Changes for 1.0.0:
* Initial Open Source release of Google Mock

View File

@ -75,18 +75,6 @@ set(gmock_build_include_dirs
"${gtest_SOURCE_DIR}")
include_directories(${gmock_build_include_dirs})
# Summary of tuple support for Microsoft Visual Studio:
# Compiler version(MS) version(cmake) Support
# ---------- ----------- -------------- -----------------------------
# <= VS 2010 <= 10 <= 1600 Use Google Tests's own tuple.
# VS 2012 11 1700 std::tr1::tuple + _VARIADIC_MAX=10
# VS 2013 12 1800 std::tr1::tuple
# VS 2015 14 1900 std::tuple
# VS 2017 15 >= 1910 std::tuple
if (MSVC AND MSVC_VERSION EQUAL 1700)
add_definitions(/D _VARIADIC_MAX=10)
endif()
########################################################################
#
# Defines the gmock & gmock_main libraries. User tests should link
@ -199,25 +187,12 @@ $env:Path = \"$project_bin;$env:Path\"
cxx_library(gmock_main_no_rtti "${cxx_no_rtti}"
"${gtest_dir}/src/gtest-all.cc" src/gmock-all.cc src/gmock_main.cc)
if (MSVC_VERSION LESS 1600) # 1600 is Visual Studio 2010.
# Visual Studio 2010, 2012, and 2013 define symbols in std::tr1 that
# conflict with our own definitions. Therefore using our own tuple does not
# work on those compilers.
cxx_library(gmock_main_use_own_tuple "${cxx_use_own_tuple}"
"${gtest_dir}/src/gtest-all.cc" src/gmock-all.cc src/gmock_main.cc)
cxx_test_with_flags(gmock_use_own_tuple_test "${cxx_use_own_tuple}"
gmock_main_use_own_tuple test/gmock-spec-builders_test.cc)
endif()
else()
cxx_library(gmock_main_no_exception "${cxx_no_exception}" src/gmock_main.cc)
target_link_libraries(gmock_main_no_exception PUBLIC gmock)
cxx_library(gmock_main_no_rtti "${cxx_no_rtti}" src/gmock_main.cc)
target_link_libraries(gmock_main_no_rtti PUBLIC gmock)
cxx_library(gmock_main_use_own_tuple "${cxx_use_own_tuple}" src/gmock_main.cc)
target_link_libraries(gmock_main_use_own_tuple PUBLIC gmock)
endif()
cxx_test_with_flags(gmock-more-actions_no_exception_test "${cxx_no_exception}"
gmock_main_no_exception test/gmock-more-actions_test.cc)

View File

@ -439,7 +439,7 @@ class Action {
// template <typename Result, typename ArgumentTuple>
// Result Perform(const ArgumentTuple& args) const {
// // Processes the arguments and returns a result, using
// // tr1::get<N>(args) to get the N-th (0-based) argument in the tuple.
// // std::get<N>(args) to get the N-th (0-based) argument in the tuple.
// }
// ...
// };
@ -838,7 +838,7 @@ class SetArgumentPointeeAction {
template <typename Result, typename ArgumentTuple>
void Perform(const ArgumentTuple& args) const {
CompileAssertTypesEqual<void, Result>();
*::testing::get<N>(args) = value_;
*::std::get<N>(args) = value_;
}
private:
@ -861,7 +861,7 @@ class SetArgumentPointeeAction<N, Proto, true> {
template <typename Result, typename ArgumentTuple>
void Perform(const ArgumentTuple& args) const {
CompileAssertTypesEqual<void, Result>();
::testing::get<N>(args)->CopyFrom(*proto_);
::std::get<N>(args)->CopyFrom(*proto_);
}
private:

View File

@ -54,164 +54,167 @@ template <typename Result, typename ArgumentTuple>
class InvokeHelper;
template <typename R>
class InvokeHelper<R, ::testing::tuple<> > {
class InvokeHelper<R, ::std::tuple<> > {
public:
template <typename Function>
static R Invoke(Function function, const ::testing::tuple<>&) {
static R Invoke(Function function, const ::std::tuple<>&) {
return function();
}
template <class Class, typename MethodPtr>
static R InvokeMethod(Class* obj_ptr,
MethodPtr method_ptr,
const ::testing::tuple<>&) {
const ::std::tuple<>&) {
return (obj_ptr->*method_ptr)();
}
template <typename CallbackType>
static R InvokeCallback(CallbackType* callback,
const ::testing::tuple<>&) {
const ::std::tuple<>&) {
return callback->Run();
}
};
template <typename R, typename A1>
class InvokeHelper<R, ::testing::tuple<A1> > {
class InvokeHelper<R, ::std::tuple<A1> > {
public:
template <typename Function>
static R Invoke(Function function, const ::testing::tuple<A1>& args) {
return function(get<0>(args));
static R Invoke(Function function, const ::std::tuple<A1>& args) {
return function(std::get<0>(args));
}
template <class Class, typename MethodPtr>
static R InvokeMethod(Class* obj_ptr,
MethodPtr method_ptr,
const ::testing::tuple<A1>& args) {
return (obj_ptr->*method_ptr)(get<0>(args));
const ::std::tuple<A1>& args) {
return (obj_ptr->*method_ptr)(std::get<0>(args));
}
template <typename CallbackType>
static R InvokeCallback(CallbackType* callback,
const ::testing::tuple<A1>& args) {
return callback->Run(get<0>(args));
const ::std::tuple<A1>& args) {
return callback->Run(std::get<0>(args));
}
};
template <typename R, typename A1, typename A2>
class InvokeHelper<R, ::testing::tuple<A1, A2> > {
class InvokeHelper<R, ::std::tuple<A1, A2> > {
public:
template <typename Function>
static R Invoke(Function function, const ::testing::tuple<A1, A2>& args) {
return function(get<0>(args), get<1>(args));
static R Invoke(Function function, const ::std::tuple<A1, A2>& args) {
return function(std::get<0>(args), std::get<1>(args));
}
template <class Class, typename MethodPtr>
static R InvokeMethod(Class* obj_ptr,
MethodPtr method_ptr,
const ::testing::tuple<A1, A2>& args) {
return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args));
const ::std::tuple<A1, A2>& args) {
return (obj_ptr->*method_ptr)(std::get<0>(args), std::get<1>(args));
}
template <typename CallbackType>
static R InvokeCallback(CallbackType* callback,
const ::testing::tuple<A1, A2>& args) {
return callback->Run(get<0>(args), get<1>(args));
const ::std::tuple<A1, A2>& args) {
return callback->Run(std::get<0>(args), std::get<1>(args));
}
};
template <typename R, typename A1, typename A2, typename A3>
class InvokeHelper<R, ::testing::tuple<A1, A2, A3> > {
class InvokeHelper<R, ::std::tuple<A1, A2, A3> > {
public:
template <typename Function>
static R Invoke(Function function, const ::testing::tuple<A1, A2, A3>& args) {
return function(get<0>(args), get<1>(args), get<2>(args));
static R Invoke(Function function, const ::std::tuple<A1, A2, A3>& args) {
return function(std::get<0>(args), std::get<1>(args),
std::get<2>(args));
}
template <class Class, typename MethodPtr>
static R InvokeMethod(Class* obj_ptr,
MethodPtr method_ptr,
const ::testing::tuple<A1, A2, A3>& args) {
return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args),
get<2>(args));
const ::std::tuple<A1, A2, A3>& args) {
return (obj_ptr->*method_ptr)(std::get<0>(args), std::get<1>(args),
std::get<2>(args));
}
template <typename CallbackType>
static R InvokeCallback(CallbackType* callback,
const ::testing::tuple<A1, A2, A3>& args) {
return callback->Run(get<0>(args), get<1>(args), get<2>(args));
const ::std::tuple<A1, A2, A3>& args) {
return callback->Run(std::get<0>(args), std::get<1>(args),
std::get<2>(args));
}
};
template <typename R, typename A1, typename A2, typename A3, typename A4>
class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4> > {
class InvokeHelper<R, ::std::tuple<A1, A2, A3, A4> > {
public:
template <typename Function>
static R Invoke(Function function, const ::testing::tuple<A1, A2, A3,
A4>& args) {
return function(get<0>(args), get<1>(args), get<2>(args),
get<3>(args));
static R Invoke(Function function, const ::std::tuple<A1, A2, A3, A4>& args) {
return function(std::get<0>(args), std::get<1>(args),
std::get<2>(args), std::get<3>(args));
}
template <class Class, typename MethodPtr>
static R InvokeMethod(Class* obj_ptr,
MethodPtr method_ptr,
const ::testing::tuple<A1, A2, A3, A4>& args) {
return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args),
get<2>(args), get<3>(args));
const ::std::tuple<A1, A2, A3, A4>& args) {
return (obj_ptr->*method_ptr)(std::get<0>(args), std::get<1>(args),
std::get<2>(args), std::get<3>(args));
}
template <typename CallbackType>
static R InvokeCallback(CallbackType* callback,
const ::testing::tuple<A1, A2, A3, A4>& args) {
return callback->Run(get<0>(args), get<1>(args), get<2>(args),
get<3>(args));
const ::std::tuple<A1, A2, A3, A4>& args) {
return callback->Run(std::get<0>(args), std::get<1>(args),
std::get<2>(args), std::get<3>(args));
}
};
template <typename R, typename A1, typename A2, typename A3, typename A4,
typename A5>
class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5> > {
class InvokeHelper<R, ::std::tuple<A1, A2, A3, A4, A5> > {
public:
template <typename Function>
static R Invoke(Function function, const ::testing::tuple<A1, A2, A3, A4,
static R Invoke(Function function, const ::std::tuple<A1, A2, A3, A4,
A5>& args) {
return function(get<0>(args), get<1>(args), get<2>(args),
get<3>(args), get<4>(args));
return function(std::get<0>(args), std::get<1>(args),
std::get<2>(args), std::get<3>(args), std::get<4>(args));
}
template <class Class, typename MethodPtr>
static R InvokeMethod(Class* obj_ptr,
MethodPtr method_ptr,
const ::testing::tuple<A1, A2, A3, A4, A5>& args) {
return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args),
get<2>(args), get<3>(args), get<4>(args));
const ::std::tuple<A1, A2, A3, A4, A5>& args) {
return (obj_ptr->*method_ptr)(std::get<0>(args), std::get<1>(args),
std::get<2>(args), std::get<3>(args), std::get<4>(args));
}
template <typename CallbackType>
static R InvokeCallback(CallbackType* callback,
const ::testing::tuple<A1, A2, A3, A4, A5>& args) {
return callback->Run(get<0>(args), get<1>(args), get<2>(args),
get<3>(args), get<4>(args));
const ::std::tuple<A1, A2, A3, A4, A5>& args) {
return callback->Run(std::get<0>(args), std::get<1>(args),
std::get<2>(args), std::get<3>(args), std::get<4>(args));
}
};
template <typename R, typename A1, typename A2, typename A3, typename A4,
typename A5, typename A6>
class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6> > {
class InvokeHelper<R, ::std::tuple<A1, A2, A3, A4, A5, A6> > {
public:
template <typename Function>
static R Invoke(Function function, const ::testing::tuple<A1, A2, A3, A4, A5,
static R Invoke(Function function, const ::std::tuple<A1, A2, A3, A4, A5,
A6>& args) {
return function(get<0>(args), get<1>(args), get<2>(args),
get<3>(args), get<4>(args), get<5>(args));
return function(std::get<0>(args), std::get<1>(args),
std::get<2>(args), std::get<3>(args), std::get<4>(args),
std::get<5>(args));
}
template <class Class, typename MethodPtr>
static R InvokeMethod(Class* obj_ptr,
MethodPtr method_ptr,
const ::testing::tuple<A1, A2, A3, A4, A5, A6>& args) {
return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args),
get<2>(args), get<3>(args), get<4>(args), get<5>(args));
const ::std::tuple<A1, A2, A3, A4, A5, A6>& args) {
return (obj_ptr->*method_ptr)(std::get<0>(args), std::get<1>(args),
std::get<2>(args), std::get<3>(args), std::get<4>(args),
std::get<5>(args));
}
// There is no InvokeCallback() for 6-tuples
@ -219,23 +222,23 @@ class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6> > {
template <typename R, typename A1, typename A2, typename A3, typename A4,
typename A5, typename A6, typename A7>
class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6, A7> > {
class InvokeHelper<R, ::std::tuple<A1, A2, A3, A4, A5, A6, A7> > {
public:
template <typename Function>
static R Invoke(Function function, const ::testing::tuple<A1, A2, A3, A4, A5,
A6, A7>& args) {
return function(get<0>(args), get<1>(args), get<2>(args),
get<3>(args), get<4>(args), get<5>(args), get<6>(args));
static R Invoke(Function function, const ::std::tuple<A1, A2, A3, A4, A5, A6,
A7>& args) {
return function(std::get<0>(args), std::get<1>(args),
std::get<2>(args), std::get<3>(args), std::get<4>(args),
std::get<5>(args), std::get<6>(args));
}
template <class Class, typename MethodPtr>
static R InvokeMethod(Class* obj_ptr,
MethodPtr method_ptr,
const ::testing::tuple<A1, A2, A3, A4, A5, A6,
A7>& args) {
return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args),
get<2>(args), get<3>(args), get<4>(args), get<5>(args),
get<6>(args));
const ::std::tuple<A1, A2, A3, A4, A5, A6, A7>& args) {
return (obj_ptr->*method_ptr)(std::get<0>(args), std::get<1>(args),
std::get<2>(args), std::get<3>(args), std::get<4>(args),
std::get<5>(args), std::get<6>(args));
}
// There is no InvokeCallback() for 7-tuples
@ -243,24 +246,24 @@ class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6, A7> > {
template <typename R, typename A1, typename A2, typename A3, typename A4,
typename A5, typename A6, typename A7, typename A8>
class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8> > {
class InvokeHelper<R, ::std::tuple<A1, A2, A3, A4, A5, A6, A7, A8> > {
public:
template <typename Function>
static R Invoke(Function function, const ::testing::tuple<A1, A2, A3, A4, A5,
A6, A7, A8>& args) {
return function(get<0>(args), get<1>(args), get<2>(args),
get<3>(args), get<4>(args), get<5>(args), get<6>(args),
get<7>(args));
static R Invoke(Function function, const ::std::tuple<A1, A2, A3, A4, A5, A6,
A7, A8>& args) {
return function(std::get<0>(args), std::get<1>(args),
std::get<2>(args), std::get<3>(args), std::get<4>(args),
std::get<5>(args), std::get<6>(args), std::get<7>(args));
}
template <class Class, typename MethodPtr>
static R InvokeMethod(Class* obj_ptr,
MethodPtr method_ptr,
const ::testing::tuple<A1, A2, A3, A4, A5, A6, A7,
const ::std::tuple<A1, A2, A3, A4, A5, A6, A7,
A8>& args) {
return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args),
get<2>(args), get<3>(args), get<4>(args), get<5>(args),
get<6>(args), get<7>(args));
return (obj_ptr->*method_ptr)(std::get<0>(args), std::get<1>(args),
std::get<2>(args), std::get<3>(args), std::get<4>(args),
std::get<5>(args), std::get<6>(args), std::get<7>(args));
}
// There is no InvokeCallback() for 8-tuples
@ -268,24 +271,26 @@ class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8> > {
template <typename R, typename A1, typename A2, typename A3, typename A4,
typename A5, typename A6, typename A7, typename A8, typename A9>
class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9> > {
class InvokeHelper<R, ::std::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9> > {
public:
template <typename Function>
static R Invoke(Function function, const ::testing::tuple<A1, A2, A3, A4, A5,
A6, A7, A8, A9>& args) {
return function(get<0>(args), get<1>(args), get<2>(args),
get<3>(args), get<4>(args), get<5>(args), get<6>(args),
get<7>(args), get<8>(args));
static R Invoke(Function function, const ::std::tuple<A1, A2, A3, A4, A5, A6,
A7, A8, A9>& args) {
return function(std::get<0>(args), std::get<1>(args),
std::get<2>(args), std::get<3>(args), std::get<4>(args),
std::get<5>(args), std::get<6>(args), std::get<7>(args),
std::get<8>(args));
}
template <class Class, typename MethodPtr>
static R InvokeMethod(Class* obj_ptr,
MethodPtr method_ptr,
const ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8,
const ::std::tuple<A1, A2, A3, A4, A5, A6, A7, A8,
A9>& args) {
return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args),
get<2>(args), get<3>(args), get<4>(args), get<5>(args),
get<6>(args), get<7>(args), get<8>(args));
return (obj_ptr->*method_ptr)(std::get<0>(args), std::get<1>(args),
std::get<2>(args), std::get<3>(args), std::get<4>(args),
std::get<5>(args), std::get<6>(args), std::get<7>(args),
std::get<8>(args));
}
// There is no InvokeCallback() for 9-tuples
@ -294,25 +299,26 @@ class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9> > {
template <typename R, typename A1, typename A2, typename A3, typename A4,
typename A5, typename A6, typename A7, typename A8, typename A9,
typename A10>
class InvokeHelper<R, ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9,
A10> > {
class InvokeHelper<R, ::std::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10> > {
public:
template <typename Function>
static R Invoke(Function function, const ::testing::tuple<A1, A2, A3, A4, A5,
A6, A7, A8, A9, A10>& args) {
return function(get<0>(args), get<1>(args), get<2>(args),
get<3>(args), get<4>(args), get<5>(args), get<6>(args),
get<7>(args), get<8>(args), get<9>(args));
static R Invoke(Function function, const ::std::tuple<A1, A2, A3, A4, A5, A6,
A7, A8, A9, A10>& args) {
return function(std::get<0>(args), std::get<1>(args),
std::get<2>(args), std::get<3>(args), std::get<4>(args),
std::get<5>(args), std::get<6>(args), std::get<7>(args),
std::get<8>(args), std::get<9>(args));
}
template <class Class, typename MethodPtr>
static R InvokeMethod(Class* obj_ptr,
MethodPtr method_ptr,
const ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8,
A9, A10>& args) {
return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args),
get<2>(args), get<3>(args), get<4>(args), get<5>(args),
get<6>(args), get<7>(args), get<8>(args), get<9>(args));
const ::std::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9,
A10>& args) {
return (obj_ptr->*method_ptr)(std::get<0>(args), std::get<1>(args),
std::get<2>(args), std::get<3>(args), std::get<4>(args),
std::get<5>(args), std::get<6>(args), std::get<7>(args),
std::get<8>(args), std::get<9>(args));
}
// There is no InvokeCallback() for 10-tuples
@ -346,20 +352,20 @@ class InvokeCallbackAction {
// An INTERNAL macro for extracting the type of a tuple field. It's
// subject to change without notice - DO NOT USE IN USER CODE!
#define GMOCK_FIELD_(Tuple, N) \
typename ::testing::tuple_element<N, Tuple>::type
typename ::std::tuple_element<N, Tuple>::type
// SelectArgs<Result, ArgumentTuple, k1, k2, ..., k_n>::type is the
// type of an n-ary function whose i-th (1-based) argument type is the
// k{i}-th (0-based) field of ArgumentTuple, which must be a tuple
// type, and whose return type is Result. For example,
// SelectArgs<int, ::testing::tuple<bool, char, double, long>, 0, 3>::type
// SelectArgs<int, ::std::tuple<bool, char, double, long>, 0, 3>::type
// is int(bool, long).
//
// SelectArgs<Result, ArgumentTuple, k1, k2, ..., k_n>::Select(args)
// returns the selected fields (k1, k2, ..., k_n) of args as a tuple.
// For example,
// SelectArgs<int, tuple<bool, char, double>, 2, 0>::Select(
// ::testing::make_tuple(true, 'a', 2.5))
// SelectArgs<int, std::tuple<bool, char, double>, 2, 0>::Select(
// ::std::make_tuple(true, 'a', 2.5))
// returns tuple (2.5, true).
//
// The numbers in list k1, k2, ..., k_n must be >= 0, where n can be
@ -378,9 +384,10 @@ class SelectArgs {
GMOCK_FIELD_(ArgumentTuple, k10));
typedef typename Function<type>::ArgumentTuple SelectedArgs;
static SelectedArgs Select(const ArgumentTuple& args) {
return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
get<k4>(args), get<k5>(args), get<k6>(args), get<k7>(args),
get<k8>(args), get<k9>(args), get<k10>(args));
return SelectedArgs(std::get<k1>(args), std::get<k2>(args),
std::get<k3>(args), std::get<k4>(args), std::get<k5>(args),
std::get<k6>(args), std::get<k7>(args), std::get<k8>(args),
std::get<k9>(args), std::get<k10>(args));
}
};
@ -402,7 +409,7 @@ class SelectArgs<Result, ArgumentTuple,
typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1));
typedef typename Function<type>::ArgumentTuple SelectedArgs;
static SelectedArgs Select(const ArgumentTuple& args) {
return SelectedArgs(get<k1>(args));
return SelectedArgs(std::get<k1>(args));
}
};
@ -414,7 +421,7 @@ class SelectArgs<Result, ArgumentTuple,
GMOCK_FIELD_(ArgumentTuple, k2));
typedef typename Function<type>::ArgumentTuple SelectedArgs;
static SelectedArgs Select(const ArgumentTuple& args) {
return SelectedArgs(get<k1>(args), get<k2>(args));
return SelectedArgs(std::get<k1>(args), std::get<k2>(args));
}
};
@ -426,7 +433,8 @@ class SelectArgs<Result, ArgumentTuple,
GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3));
typedef typename Function<type>::ArgumentTuple SelectedArgs;
static SelectedArgs Select(const ArgumentTuple& args) {
return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args));
return SelectedArgs(std::get<k1>(args), std::get<k2>(args),
std::get<k3>(args));
}
};
@ -440,8 +448,8 @@ class SelectArgs<Result, ArgumentTuple,
GMOCK_FIELD_(ArgumentTuple, k4));
typedef typename Function<type>::ArgumentTuple SelectedArgs;
static SelectedArgs Select(const ArgumentTuple& args) {
return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
get<k4>(args));
return SelectedArgs(std::get<k1>(args), std::get<k2>(args),
std::get<k3>(args), std::get<k4>(args));
}
};
@ -455,8 +463,8 @@ class SelectArgs<Result, ArgumentTuple,
GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5));
typedef typename Function<type>::ArgumentTuple SelectedArgs;
static SelectedArgs Select(const ArgumentTuple& args) {
return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
get<k4>(args), get<k5>(args));
return SelectedArgs(std::get<k1>(args), std::get<k2>(args),
std::get<k3>(args), std::get<k4>(args), std::get<k5>(args));
}
};
@ -471,8 +479,9 @@ class SelectArgs<Result, ArgumentTuple,
GMOCK_FIELD_(ArgumentTuple, k6));
typedef typename Function<type>::ArgumentTuple SelectedArgs;
static SelectedArgs Select(const ArgumentTuple& args) {
return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
get<k4>(args), get<k5>(args), get<k6>(args));
return SelectedArgs(std::get<k1>(args), std::get<k2>(args),
std::get<k3>(args), std::get<k4>(args), std::get<k5>(args),
std::get<k6>(args));
}
};
@ -487,8 +496,9 @@ class SelectArgs<Result, ArgumentTuple,
GMOCK_FIELD_(ArgumentTuple, k6), GMOCK_FIELD_(ArgumentTuple, k7));
typedef typename Function<type>::ArgumentTuple SelectedArgs;
static SelectedArgs Select(const ArgumentTuple& args) {
return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
get<k4>(args), get<k5>(args), get<k6>(args), get<k7>(args));
return SelectedArgs(std::get<k1>(args), std::get<k2>(args),
std::get<k3>(args), std::get<k4>(args), std::get<k5>(args),
std::get<k6>(args), std::get<k7>(args));
}
};
@ -504,9 +514,9 @@ class SelectArgs<Result, ArgumentTuple,
GMOCK_FIELD_(ArgumentTuple, k8));
typedef typename Function<type>::ArgumentTuple SelectedArgs;
static SelectedArgs Select(const ArgumentTuple& args) {
return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
get<k4>(args), get<k5>(args), get<k6>(args), get<k7>(args),
get<k8>(args));
return SelectedArgs(std::get<k1>(args), std::get<k2>(args),
std::get<k3>(args), std::get<k4>(args), std::get<k5>(args),
std::get<k6>(args), std::get<k7>(args), std::get<k8>(args));
}
};
@ -522,9 +532,10 @@ class SelectArgs<Result, ArgumentTuple,
GMOCK_FIELD_(ArgumentTuple, k8), GMOCK_FIELD_(ArgumentTuple, k9));
typedef typename Function<type>::ArgumentTuple SelectedArgs;
static SelectedArgs Select(const ArgumentTuple& args) {
return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),
get<k4>(args), get<k5>(args), get<k6>(args), get<k7>(args),
get<k8>(args), get<k9>(args));
return SelectedArgs(std::get<k1>(args), std::get<k2>(args),
std::get<k3>(args), std::get<k4>(args), std::get<k5>(args),
std::get<k6>(args), std::get<k7>(args), std::get<k8>(args),
std::get<k9>(args));
}
};
@ -587,7 +598,7 @@ struct ExcessiveArg {};
template <typename Result, class Impl>
class ActionHelper {
public:
static Result Perform(Impl* impl, const ::testing::tuple<>& args) {
static Result Perform(Impl* impl, const ::std::tuple<>& args) {
return impl->template gmock_PerformImpl<>(args, ExcessiveArg(),
ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
@ -595,95 +606,96 @@ class ActionHelper {
}
template <typename A0>
static Result Perform(Impl* impl, const ::testing::tuple<A0>& args) {
return impl->template gmock_PerformImpl<A0>(args, get<0>(args),
static Result Perform(Impl* impl, const ::std::tuple<A0>& args) {
return impl->template gmock_PerformImpl<A0>(args, std::get<0>(args),
ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
ExcessiveArg());
}
template <typename A0, typename A1>
static Result Perform(Impl* impl, const ::testing::tuple<A0, A1>& args) {
return impl->template gmock_PerformImpl<A0, A1>(args, get<0>(args),
get<1>(args), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
static Result Perform(Impl* impl, const ::std::tuple<A0, A1>& args) {
return impl->template gmock_PerformImpl<A0, A1>(args, std::get<0>(args),
std::get<1>(args), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
ExcessiveArg());
}
template <typename A0, typename A1, typename A2>
static Result Perform(Impl* impl, const ::testing::tuple<A0, A1, A2>& args) {
return impl->template gmock_PerformImpl<A0, A1, A2>(args, get<0>(args),
get<1>(args), get<2>(args), ExcessiveArg(), ExcessiveArg(),
static Result Perform(Impl* impl, const ::std::tuple<A0, A1, A2>& args) {
return impl->template gmock_PerformImpl<A0, A1, A2>(args,
std::get<0>(args), std::get<1>(args), std::get<2>(args),
ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
ExcessiveArg());
ExcessiveArg(), ExcessiveArg(), ExcessiveArg());
}
template <typename A0, typename A1, typename A2, typename A3>
static Result Perform(Impl* impl, const ::testing::tuple<A0, A1, A2,
A3>& args) {
return impl->template gmock_PerformImpl<A0, A1, A2, A3>(args, get<0>(args),
get<1>(args), get<2>(args), get<3>(args), ExcessiveArg(),
ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
ExcessiveArg());
static Result Perform(Impl* impl, const ::std::tuple<A0, A1, A2, A3>& args) {
return impl->template gmock_PerformImpl<A0, A1, A2, A3>(args,
std::get<0>(args), std::get<1>(args), std::get<2>(args),
std::get<3>(args), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
ExcessiveArg(), ExcessiveArg(), ExcessiveArg());
}
template <typename A0, typename A1, typename A2, typename A3, typename A4>
static Result Perform(Impl* impl, const ::testing::tuple<A0, A1, A2, A3,
static Result Perform(Impl* impl, const ::std::tuple<A0, A1, A2, A3,
A4>& args) {
return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4>(args,
get<0>(args), get<1>(args), get<2>(args), get<3>(args), get<4>(args),
ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
ExcessiveArg());
std::get<0>(args), std::get<1>(args), std::get<2>(args),
std::get<3>(args), std::get<4>(args), ExcessiveArg(), ExcessiveArg(),
ExcessiveArg(), ExcessiveArg(), ExcessiveArg());
}
template <typename A0, typename A1, typename A2, typename A3, typename A4,
typename A5>
static Result Perform(Impl* impl, const ::testing::tuple<A0, A1, A2, A3, A4,
static Result Perform(Impl* impl, const ::std::tuple<A0, A1, A2, A3, A4,
A5>& args) {
return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5>(args,
get<0>(args), get<1>(args), get<2>(args), get<3>(args), get<4>(args),
get<5>(args), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),
ExcessiveArg());
std::get<0>(args), std::get<1>(args), std::get<2>(args),
std::get<3>(args), std::get<4>(args), std::get<5>(args),
ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg());
}
template <typename A0, typename A1, typename A2, typename A3, typename A4,
typename A5, typename A6>
static Result Perform(Impl* impl, const ::testing::tuple<A0, A1, A2, A3, A4,
A5, A6>& args) {
static Result Perform(Impl* impl, const ::std::tuple<A0, A1, A2, A3, A4, A5,
A6>& args) {
return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5, A6>(args,
get<0>(args), get<1>(args), get<2>(args), get<3>(args), get<4>(args),
get<5>(args), get<6>(args), ExcessiveArg(), ExcessiveArg(),
ExcessiveArg());
std::get<0>(args), std::get<1>(args), std::get<2>(args),
std::get<3>(args), std::get<4>(args), std::get<5>(args),
std::get<6>(args), ExcessiveArg(), ExcessiveArg(), ExcessiveArg());
}
template <typename A0, typename A1, typename A2, typename A3, typename A4,
typename A5, typename A6, typename A7>
static Result Perform(Impl* impl, const ::testing::tuple<A0, A1, A2, A3, A4,
A5, A6, A7>& args) {
static Result Perform(Impl* impl, const ::std::tuple<A0, A1, A2, A3, A4, A5,
A6, A7>& args) {
return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5, A6,
A7>(args, get<0>(args), get<1>(args), get<2>(args), get<3>(args),
get<4>(args), get<5>(args), get<6>(args), get<7>(args), ExcessiveArg(),
ExcessiveArg());
A7>(args, std::get<0>(args), std::get<1>(args), std::get<2>(args),
std::get<3>(args), std::get<4>(args), std::get<5>(args),
std::get<6>(args), std::get<7>(args), ExcessiveArg(), ExcessiveArg());
}
template <typename A0, typename A1, typename A2, typename A3, typename A4,
typename A5, typename A6, typename A7, typename A8>
static Result Perform(Impl* impl, const ::testing::tuple<A0, A1, A2, A3, A4,
A5, A6, A7, A8>& args) {
static Result Perform(Impl* impl, const ::std::tuple<A0, A1, A2, A3, A4, A5,
A6, A7, A8>& args) {
return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5, A6, A7,
A8>(args, get<0>(args), get<1>(args), get<2>(args), get<3>(args),
get<4>(args), get<5>(args), get<6>(args), get<7>(args), get<8>(args),
A8>(args, std::get<0>(args), std::get<1>(args), std::get<2>(args),
std::get<3>(args), std::get<4>(args), std::get<5>(args),
std::get<6>(args), std::get<7>(args), std::get<8>(args),
ExcessiveArg());
}
template <typename A0, typename A1, typename A2, typename A3, typename A4,
typename A5, typename A6, typename A7, typename A8, typename A9>
static Result Perform(Impl* impl, const ::testing::tuple<A0, A1, A2, A3, A4,
A5, A6, A7, A8, A9>& args) {
static Result Perform(Impl* impl, const ::std::tuple<A0, A1, A2, A3, A4, A5,
A6, A7, A8, A9>& args) {
return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5, A6, A7, A8,
A9>(args, get<0>(args), get<1>(args), get<2>(args), get<3>(args),
get<4>(args), get<5>(args), get<6>(args), get<7>(args), get<8>(args),
get<9>(args));
A9>(args, std::get<0>(args), std::get<1>(args), std::get<2>(args),
std::get<3>(args), std::get<4>(args), std::get<5>(args),
std::get<6>(args), std::get<7>(args), std::get<8>(args),
std::get<9>(args));
}
};
@ -950,8 +962,8 @@ DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
//
// MORE INFORMATION:
//
// To learn more about using these macros, please search for 'ACTION'
// on https://github.com/google/googletest/blob/master/googlemock/docs/CookBook.md
// To learn more about using these macros, please search for 'ACTION' on
// https://github.com/google/googletest/blob/master/googlemock/docs/CookBook.md
// An internal macro needed for implementing ACTION*().
#define GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_\
@ -991,7 +1003,7 @@ DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
// ACTION_TEMPLATE(DuplicateArg,
// HAS_2_TEMPLATE_PARAMS(int, k, typename, T),
// AND_1_VALUE_PARAMS(output)) {
// *output = T(::testing::get<k>(args));
// *output = T(::std::get<k>(args));
// }
// ...
// int n;
@ -2389,7 +2401,7 @@ ACTION_TEMPLATE(InvokeArgument,
using internal::invoke_argument::InvokeArgumentAdl;
return InvokeArgumentAdl<return_type>(
internal::invoke_argument::AdlTag(),
::testing::get<k>(args));
::std::get<k>(args));
}
ACTION_TEMPLATE(InvokeArgument,
@ -2398,7 +2410,7 @@ ACTION_TEMPLATE(InvokeArgument,
using internal::invoke_argument::InvokeArgumentAdl;
return InvokeArgumentAdl<return_type>(
internal::invoke_argument::AdlTag(),
::testing::get<k>(args), p0);
::std::get<k>(args), p0);
}
ACTION_TEMPLATE(InvokeArgument,
@ -2407,7 +2419,7 @@ ACTION_TEMPLATE(InvokeArgument,
using internal::invoke_argument::InvokeArgumentAdl;
return InvokeArgumentAdl<return_type>(
internal::invoke_argument::AdlTag(),
::testing::get<k>(args), p0, p1);
::std::get<k>(args), p0, p1);
}
ACTION_TEMPLATE(InvokeArgument,
@ -2416,7 +2428,7 @@ ACTION_TEMPLATE(InvokeArgument,
using internal::invoke_argument::InvokeArgumentAdl;
return InvokeArgumentAdl<return_type>(
internal::invoke_argument::AdlTag(),
::testing::get<k>(args), p0, p1, p2);
::std::get<k>(args), p0, p1, p2);
}
ACTION_TEMPLATE(InvokeArgument,
@ -2425,7 +2437,7 @@ ACTION_TEMPLATE(InvokeArgument,
using internal::invoke_argument::InvokeArgumentAdl;
return InvokeArgumentAdl<return_type>(
internal::invoke_argument::AdlTag(),
::testing::get<k>(args), p0, p1, p2, p3);
::std::get<k>(args), p0, p1, p2, p3);
}
ACTION_TEMPLATE(InvokeArgument,
@ -2434,7 +2446,7 @@ ACTION_TEMPLATE(InvokeArgument,
using internal::invoke_argument::InvokeArgumentAdl;
return InvokeArgumentAdl<return_type>(
internal::invoke_argument::AdlTag(),
::testing::get<k>(args), p0, p1, p2, p3, p4);
::std::get<k>(args), p0, p1, p2, p3, p4);
}
ACTION_TEMPLATE(InvokeArgument,
@ -2443,7 +2455,7 @@ ACTION_TEMPLATE(InvokeArgument,
using internal::invoke_argument::InvokeArgumentAdl;
return InvokeArgumentAdl<return_type>(
internal::invoke_argument::AdlTag(),
::testing::get<k>(args), p0, p1, p2, p3, p4, p5);
::std::get<k>(args), p0, p1, p2, p3, p4, p5);
}
ACTION_TEMPLATE(InvokeArgument,
@ -2452,7 +2464,7 @@ ACTION_TEMPLATE(InvokeArgument,
using internal::invoke_argument::InvokeArgumentAdl;
return InvokeArgumentAdl<return_type>(
internal::invoke_argument::AdlTag(),
::testing::get<k>(args), p0, p1, p2, p3, p4, p5, p6);
::std::get<k>(args), p0, p1, p2, p3, p4, p5, p6);
}
ACTION_TEMPLATE(InvokeArgument,
@ -2461,7 +2473,7 @@ ACTION_TEMPLATE(InvokeArgument,
using internal::invoke_argument::InvokeArgumentAdl;
return InvokeArgumentAdl<return_type>(
internal::invoke_argument::AdlTag(),
::testing::get<k>(args), p0, p1, p2, p3, p4, p5, p6, p7);
::std::get<k>(args), p0, p1, p2, p3, p4, p5, p6, p7);
}
ACTION_TEMPLATE(InvokeArgument,
@ -2470,7 +2482,7 @@ ACTION_TEMPLATE(InvokeArgument,
using internal::invoke_argument::InvokeArgumentAdl;
return InvokeArgumentAdl<return_type>(
internal::invoke_argument::AdlTag(),
::testing::get<k>(args), p0, p1, p2, p3, p4, p5, p6, p7, p8);
::std::get<k>(args), p0, p1, p2, p3, p4, p5, p6, p7, p8);
}
ACTION_TEMPLATE(InvokeArgument,
@ -2479,7 +2491,7 @@ ACTION_TEMPLATE(InvokeArgument,
using internal::invoke_argument::InvokeArgumentAdl;
return InvokeArgumentAdl<return_type>(
internal::invoke_argument::AdlTag(),
::testing::get<k>(args), p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
::std::get<k>(args), p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
}
// Various overloads for ReturnNew<T>().

View File

@ -63,19 +63,19 @@ $range j 1..i
$var types = [[$for j [[, typename A$j]]]]
$var as = [[$for j, [[A$j]]]]
$var args = [[$if i==0 [[]] $else [[ args]]]]
$var gets = [[$for j, [[get<$(j - 1)>(args)]]]]
$var gets = [[$for j, [[std::get<$(j - 1)>(args)]]]]
template <typename R$types>
class InvokeHelper<R, ::testing::tuple<$as> > {
class InvokeHelper<R, ::std::tuple<$as> > {
public:
template <typename Function>
static R Invoke(Function function, const ::testing::tuple<$as>&$args) {
static R Invoke(Function function, const ::std::tuple<$as>&$args) {
return function($gets);
}
template <class Class, typename MethodPtr>
static R InvokeMethod(Class* obj_ptr,
MethodPtr method_ptr,
const ::testing::tuple<$as>&$args) {
const ::std::tuple<$as>&$args) {
return (obj_ptr->*method_ptr)($gets);
}
@ -83,7 +83,7 @@ class InvokeHelper<R, ::testing::tuple<$as> > {
$if i <= max_callback_arity [[
template <typename CallbackType>
static R InvokeCallback(CallbackType* callback,
const ::testing::tuple<$as>&$args) {
const ::std::tuple<$as>&$args) {
return callback->Run($gets);
}
]] $else [[
@ -122,7 +122,7 @@ class InvokeCallbackAction {
// An INTERNAL macro for extracting the type of a tuple field. It's
// subject to change without notice - DO NOT USE IN USER CODE!
#define GMOCK_FIELD_(Tuple, N) \
typename ::testing::tuple_element<N, Tuple>::type
typename ::std::tuple_element<N, Tuple>::type
$range i 1..n
@ -130,14 +130,14 @@ $range i 1..n
// type of an n-ary function whose i-th (1-based) argument type is the
// k{i}-th (0-based) field of ArgumentTuple, which must be a tuple
// type, and whose return type is Result. For example,
// SelectArgs<int, ::testing::tuple<bool, char, double, long>, 0, 3>::type
// SelectArgs<int, ::std::tuple<bool, char, double, long>, 0, 3>::type
// is int(bool, long).
//
// SelectArgs<Result, ArgumentTuple, k1, k2, ..., k_n>::Select(args)
// returns the selected fields (k1, k2, ..., k_n) of args as a tuple.
// For example,
// SelectArgs<int, tuple<bool, char, double>, 2, 0>::Select(
// ::testing::make_tuple(true, 'a', 2.5))
// SelectArgs<int, std::tuple<bool, char, double>, 2, 0>::Select(
// ::std::make_tuple(true, 'a', 2.5))
// returns tuple (2.5, true).
//
// The numbers in list k1, k2, ..., k_n must be >= 0, where n can be
@ -150,7 +150,7 @@ class SelectArgs {
typedef Result type($for i, [[GMOCK_FIELD_(ArgumentTuple, k$i)]]);
typedef typename Function<type>::ArgumentTuple SelectedArgs;
static SelectedArgs Select(const ArgumentTuple& args) {
return SelectedArgs($for i, [[get<k$i>(args)]]);
return SelectedArgs($for i, [[std::get<k$i>(args)]]);
}
};
@ -166,7 +166,7 @@ class SelectArgs<Result, ArgumentTuple,
typedef typename Function<type>::ArgumentTuple SelectedArgs;
static SelectedArgs Select(const ArgumentTuple& [[]]
$if i == 1 [[/* args */]] $else [[args]]) {
return SelectedArgs($for j1, [[get<k$j1>(args)]]);
return SelectedArgs($for j1, [[std::get<k$j1>(args)]]);
}
};
@ -240,12 +240,12 @@ $range j 0..i-1
]]]]
$range j 0..i-1
$var As = [[$for j, [[A$j]]]]
$var as = [[$for j, [[get<$j>(args)]]]]
$var as = [[$for j, [[std::get<$j>(args)]]]]
$range k 1..n-i
$var eas = [[$for k, [[ExcessiveArg()]]]]
$var arg_list = [[$if (i==0) | (i==n) [[$as$eas]] $else [[$as, $eas]]]]
$template
static Result Perform(Impl* impl, const ::testing::tuple<$As>& args) {
static Result Perform(Impl* impl, const ::std::tuple<$As>& args) {
return impl->template gmock_PerformImpl<$As>(args, $arg_list);
}
@ -395,8 +395,8 @@ $range j2 2..i
//
// MORE INFORMATION:
//
// To learn more about using these macros, please search for 'ACTION'
// on https://github.com/google/googletest/blob/master/googlemock/docs/CookBook.md
// To learn more about using these macros, please search for 'ACTION' on
// https://github.com/google/googletest/blob/master/googlemock/docs/CookBook.md
$range i 0..n
$range k 0..n-1
@ -432,7 +432,7 @@ $for k [[, \
// ACTION_TEMPLATE(DuplicateArg,
// HAS_2_TEMPLATE_PARAMS(int, k, typename, T),
// AND_1_VALUE_PARAMS(output)) {
// *output = T(::testing::get<k>(args));
// *output = T(::std::get<k>(args));
// }
// ...
// int n;
@ -796,7 +796,7 @@ ACTION_TEMPLATE(InvokeArgument,
using internal::invoke_argument::InvokeArgumentAdl;
return InvokeArgumentAdl<return_type>(
internal::invoke_argument::AdlTag(),
::testing::get<k>(args)$for j [[, p$j]]);
::std::get<k>(args)$for j [[, p$j]]);
}
]]

File diff suppressed because it is too large Load Diff

View File

@ -81,7 +81,7 @@ class FunctionMocker<R($As)> : public
typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
MockSpec<F> With($matchers) {
return MockSpec<F>(this, ::testing::make_tuple($ms));
return MockSpec<F>(this, ::std::make_tuple($ms));
}
R Invoke($Aas) {
@ -194,7 +194,7 @@ $var anything_matchers = [[$for j, \
#define GMOCK_METHOD$i[[]]_(tn, constness, ct, Method, ...) \
GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
$arg_as) constness { \
GTEST_COMPILE_ASSERT_((::testing::tuple_size< \
GTEST_COMPILE_ASSERT_((::std::tuple_size< \
tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value == $i), \
this_method_does_not_take_$i[[]]_argument[[$if i != 1 [[s]]]]); \
GMOCK_MOCKER_($i, constness, Method).SetOwnerAndName(this, #Method); \

View File

@ -51,7 +51,7 @@ namespace internal {
// The type of the i-th (0-based) field of Tuple.
#define GMOCK_FIELD_TYPE_(Tuple, i) \
typename ::testing::tuple_element<i, Tuple>::type
typename ::std::tuple_element<i, Tuple>::type
// TupleFields<Tuple, k0, ..., kn> is for selecting fields from a
// tuple of type Tuple. It has two members:
@ -59,10 +59,11 @@ namespace internal {
// type: a tuple type whose i-th field is the ki-th field of Tuple.
// GetSelectedFields(t): returns fields k0, ..., and kn of t as a tuple.
//
// For example, in class TupleFields<tuple<bool, char, int>, 2, 0>, we have:
// For example, in class TupleFields<std::tuple<bool, char, int>, 2, 0>,
// we have:
//
// type is tuple<int, bool>, and
// GetSelectedFields(make_tuple(true, 'a', 42)) is (42, true).
// type is std::tuple<int, bool>, and
// GetSelectedFields(std::make_tuple(true, 'a', 42)) is (42, true).
template <class Tuple, int k0 = -1, int k1 = -1, int k2 = -1, int k3 = -1,
int k4 = -1, int k5 = -1, int k6 = -1, int k7 = -1, int k8 = -1,
@ -74,15 +75,15 @@ template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6,
int k7, int k8, int k9>
class TupleFields {
public:
typedef ::testing::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6),
GMOCK_FIELD_TYPE_(Tuple, k7), GMOCK_FIELD_TYPE_(Tuple, k8),
GMOCK_FIELD_TYPE_(Tuple, k9)> type;
typedef ::std::tuple<GMOCK_FIELD_TYPE_(Tuple, k0), GMOCK_FIELD_TYPE_(Tuple,
k1), GMOCK_FIELD_TYPE_(Tuple, k2), GMOCK_FIELD_TYPE_(Tuple, k3),
GMOCK_FIELD_TYPE_(Tuple, k4), GMOCK_FIELD_TYPE_(Tuple, k5),
GMOCK_FIELD_TYPE_(Tuple, k6), GMOCK_FIELD_TYPE_(Tuple, k7),
GMOCK_FIELD_TYPE_(Tuple, k8), GMOCK_FIELD_TYPE_(Tuple, k9)> type;
static type GetSelectedFields(const Tuple& t) {
return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
get<k5>(t), get<k6>(t), get<k7>(t), get<k8>(t), get<k9>(t));
return type(std::get<k0>(t), std::get<k1>(t), std::get<k2>(t),
std::get<k3>(t), std::get<k4>(t), std::get<k5>(t), std::get<k6>(t),
std::get<k7>(t), std::get<k8>(t), std::get<k9>(t));
}
};
@ -91,7 +92,7 @@ class TupleFields {
template <class Tuple>
class TupleFields<Tuple, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1> {
public:
typedef ::testing::tuple<> type;
typedef ::std::tuple<> type;
static type GetSelectedFields(const Tuple& /* t */) {
return type();
}
@ -100,77 +101,77 @@ class TupleFields<Tuple, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1> {
template <class Tuple, int k0>
class TupleFields<Tuple, k0, -1, -1, -1, -1, -1, -1, -1, -1, -1> {
public:
typedef ::testing::tuple<GMOCK_FIELD_TYPE_(Tuple, k0)> type;
typedef ::std::tuple<GMOCK_FIELD_TYPE_(Tuple, k0)> type;
static type GetSelectedFields(const Tuple& t) {
return type(get<k0>(t));
return type(std::get<k0>(t));
}
};
template <class Tuple, int k0, int k1>
class TupleFields<Tuple, k0, k1, -1, -1, -1, -1, -1, -1, -1, -1> {
public:
typedef ::testing::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
GMOCK_FIELD_TYPE_(Tuple, k1)> type;
typedef ::std::tuple<GMOCK_FIELD_TYPE_(Tuple, k0), GMOCK_FIELD_TYPE_(Tuple,
k1)> type;
static type GetSelectedFields(const Tuple& t) {
return type(get<k0>(t), get<k1>(t));
return type(std::get<k0>(t), std::get<k1>(t));
}
};
template <class Tuple, int k0, int k1, int k2>
class TupleFields<Tuple, k0, k1, k2, -1, -1, -1, -1, -1, -1, -1> {
public:
typedef ::testing::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2)> type;
typedef ::std::tuple<GMOCK_FIELD_TYPE_(Tuple, k0), GMOCK_FIELD_TYPE_(Tuple,
k1), GMOCK_FIELD_TYPE_(Tuple, k2)> type;
static type GetSelectedFields(const Tuple& t) {
return type(get<k0>(t), get<k1>(t), get<k2>(t));
return type(std::get<k0>(t), std::get<k1>(t), std::get<k2>(t));
}
};
template <class Tuple, int k0, int k1, int k2, int k3>
class TupleFields<Tuple, k0, k1, k2, k3, -1, -1, -1, -1, -1, -1> {
public:
typedef ::testing::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
GMOCK_FIELD_TYPE_(Tuple, k3)> type;
typedef ::std::tuple<GMOCK_FIELD_TYPE_(Tuple, k0), GMOCK_FIELD_TYPE_(Tuple,
k1), GMOCK_FIELD_TYPE_(Tuple, k2), GMOCK_FIELD_TYPE_(Tuple, k3)> type;
static type GetSelectedFields(const Tuple& t) {
return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t));
return type(std::get<k0>(t), std::get<k1>(t), std::get<k2>(t),
std::get<k3>(t));
}
};
template <class Tuple, int k0, int k1, int k2, int k3, int k4>
class TupleFields<Tuple, k0, k1, k2, k3, k4, -1, -1, -1, -1, -1> {
public:
typedef ::testing::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4)> type;
typedef ::std::tuple<GMOCK_FIELD_TYPE_(Tuple, k0), GMOCK_FIELD_TYPE_(Tuple,
k1), GMOCK_FIELD_TYPE_(Tuple, k2), GMOCK_FIELD_TYPE_(Tuple, k3),
GMOCK_FIELD_TYPE_(Tuple, k4)> type;
static type GetSelectedFields(const Tuple& t) {
return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t));
return type(std::get<k0>(t), std::get<k1>(t), std::get<k2>(t),
std::get<k3>(t), std::get<k4>(t));
}
};
template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5>
class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, -1, -1, -1, -1> {
public:
typedef ::testing::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
GMOCK_FIELD_TYPE_(Tuple, k5)> type;
typedef ::std::tuple<GMOCK_FIELD_TYPE_(Tuple, k0), GMOCK_FIELD_TYPE_(Tuple,
k1), GMOCK_FIELD_TYPE_(Tuple, k2), GMOCK_FIELD_TYPE_(Tuple, k3),
GMOCK_FIELD_TYPE_(Tuple, k4), GMOCK_FIELD_TYPE_(Tuple, k5)> type;
static type GetSelectedFields(const Tuple& t) {
return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
get<k5>(t));
return type(std::get<k0>(t), std::get<k1>(t), std::get<k2>(t),
std::get<k3>(t), std::get<k4>(t), std::get<k5>(t));
}
};
template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6>
class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, k6, -1, -1, -1> {
public:
typedef ::testing::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6)> type;
typedef ::std::tuple<GMOCK_FIELD_TYPE_(Tuple, k0), GMOCK_FIELD_TYPE_(Tuple,
k1), GMOCK_FIELD_TYPE_(Tuple, k2), GMOCK_FIELD_TYPE_(Tuple, k3),
GMOCK_FIELD_TYPE_(Tuple, k4), GMOCK_FIELD_TYPE_(Tuple, k5),
GMOCK_FIELD_TYPE_(Tuple, k6)> type;
static type GetSelectedFields(const Tuple& t) {
return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
get<k5>(t), get<k6>(t));
return type(std::get<k0>(t), std::get<k1>(t), std::get<k2>(t),
std::get<k3>(t), std::get<k4>(t), std::get<k5>(t), std::get<k6>(t));
}
};
@ -178,14 +179,14 @@ template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6,
int k7>
class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, k6, k7, -1, -1> {
public:
typedef ::testing::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6),
GMOCK_FIELD_TYPE_(Tuple, k7)> type;
typedef ::std::tuple<GMOCK_FIELD_TYPE_(Tuple, k0), GMOCK_FIELD_TYPE_(Tuple,
k1), GMOCK_FIELD_TYPE_(Tuple, k2), GMOCK_FIELD_TYPE_(Tuple, k3),
GMOCK_FIELD_TYPE_(Tuple, k4), GMOCK_FIELD_TYPE_(Tuple, k5),
GMOCK_FIELD_TYPE_(Tuple, k6), GMOCK_FIELD_TYPE_(Tuple, k7)> type;
static type GetSelectedFields(const Tuple& t) {
return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
get<k5>(t), get<k6>(t), get<k7>(t));
return type(std::get<k0>(t), std::get<k1>(t), std::get<k2>(t),
std::get<k3>(t), std::get<k4>(t), std::get<k5>(t), std::get<k6>(t),
std::get<k7>(t));
}
};
@ -193,14 +194,15 @@ template <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6,
int k7, int k8>
class TupleFields<Tuple, k0, k1, k2, k3, k4, k5, k6, k7, k8, -1> {
public:
typedef ::testing::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),
GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),
GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),
GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6),
GMOCK_FIELD_TYPE_(Tuple, k7), GMOCK_FIELD_TYPE_(Tuple, k8)> type;
typedef ::std::tuple<GMOCK_FIELD_TYPE_(Tuple, k0), GMOCK_FIELD_TYPE_(Tuple,
k1), GMOCK_FIELD_TYPE_(Tuple, k2), GMOCK_FIELD_TYPE_(Tuple, k3),
GMOCK_FIELD_TYPE_(Tuple, k4), GMOCK_FIELD_TYPE_(Tuple, k5),
GMOCK_FIELD_TYPE_(Tuple, k6), GMOCK_FIELD_TYPE_(Tuple, k7),
GMOCK_FIELD_TYPE_(Tuple, k8)> type;
static type GetSelectedFields(const Tuple& t) {
return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),
get<k5>(t), get<k6>(t), get<k7>(t), get<k8>(t));
return type(std::get<k0>(t), std::get<k1>(t), std::get<k2>(t),
std::get<k3>(t), std::get<k4>(t), std::get<k5>(t), std::get<k6>(t),
std::get<k7>(t), std::get<k8>(t));
}
};
@ -297,94 +299,6 @@ class ArgsMatcher {
GTEST_DISALLOW_ASSIGN_(ArgsMatcher);
};
// A set of metafunctions for computing the result type of AnyOf.
// AnyOf(m1, ..., mN) returns
// AnyOfResultN<decltype(m1), ..., decltype(mN)>::type.
// Although AnyOf isn't defined for one argument, AnyOfResult1 is defined
// to simplify the implementation.
template <typename M1>
struct AnyOfResult1 {
typedef M1 type;
};
template <typename M1, typename M2>
struct AnyOfResult2 {
typedef EitherOfMatcher<
typename AnyOfResult1<M1>::type,
typename AnyOfResult1<M2>::type
> type;
};
template <typename M1, typename M2, typename M3>
struct AnyOfResult3 {
typedef EitherOfMatcher<
typename AnyOfResult1<M1>::type,
typename AnyOfResult2<M2, M3>::type
> type;
};
template <typename M1, typename M2, typename M3, typename M4>
struct AnyOfResult4 {
typedef EitherOfMatcher<
typename AnyOfResult2<M1, M2>::type,
typename AnyOfResult2<M3, M4>::type
> type;
};
template <typename M1, typename M2, typename M3, typename M4, typename M5>
struct AnyOfResult5 {
typedef EitherOfMatcher<
typename AnyOfResult2<M1, M2>::type,
typename AnyOfResult3<M3, M4, M5>::type
> type;
};
template <typename M1, typename M2, typename M3, typename M4, typename M5,
typename M6>
struct AnyOfResult6 {
typedef EitherOfMatcher<
typename AnyOfResult3<M1, M2, M3>::type,
typename AnyOfResult3<M4, M5, M6>::type
> type;
};
template <typename M1, typename M2, typename M3, typename M4, typename M5,
typename M6, typename M7>
struct AnyOfResult7 {
typedef EitherOfMatcher<
typename AnyOfResult3<M1, M2, M3>::type,
typename AnyOfResult4<M4, M5, M6, M7>::type
> type;
};
template <typename M1, typename M2, typename M3, typename M4, typename M5,
typename M6, typename M7, typename M8>
struct AnyOfResult8 {
typedef EitherOfMatcher<
typename AnyOfResult4<M1, M2, M3, M4>::type,
typename AnyOfResult4<M5, M6, M7, M8>::type
> type;
};
template <typename M1, typename M2, typename M3, typename M4, typename M5,
typename M6, typename M7, typename M8, typename M9>
struct AnyOfResult9 {
typedef EitherOfMatcher<
typename AnyOfResult4<M1, M2, M3, M4>::type,
typename AnyOfResult5<M5, M6, M7, M8, M9>::type
> type;
};
template <typename M1, typename M2, typename M3, typename M4, typename M5,
typename M6, typename M7, typename M8, typename M9, typename M10>
struct AnyOfResult10 {
typedef EitherOfMatcher<
typename AnyOfResult5<M1, M2, M3, M4, M5>::type,
typename AnyOfResult5<M6, M7, M8, M9, M10>::type
> type;
};
} // namespace internal
// Args<N1, N2, ..., Nk>(a_matcher) matches a tuple if the selected
@ -466,88 +380,6 @@ Args(const InnerMatcher& matcher) {
}
// AnyOf(m1, m2, ..., mk) matches any value that matches any of the given
// sub-matchers. AnyOf is called fully qualified to prevent ADL from firing.
template <typename M1, typename M2>
inline typename internal::AnyOfResult2<M1, M2>::type
AnyOf(M1 m1, M2 m2) {
return typename internal::AnyOfResult2<M1, M2>::type(
m1,
m2);
}
template <typename M1, typename M2, typename M3>
inline typename internal::AnyOfResult3<M1, M2, M3>::type
AnyOf(M1 m1, M2 m2, M3 m3) {
return typename internal::AnyOfResult3<M1, M2, M3>::type(
m1,
::testing::AnyOf(m2, m3));
}
template <typename M1, typename M2, typename M3, typename M4>
inline typename internal::AnyOfResult4<M1, M2, M3, M4>::type
AnyOf(M1 m1, M2 m2, M3 m3, M4 m4) {
return typename internal::AnyOfResult4<M1, M2, M3, M4>::type(
::testing::AnyOf(m1, m2),
::testing::AnyOf(m3, m4));
}
template <typename M1, typename M2, typename M3, typename M4, typename M5>
inline typename internal::AnyOfResult5<M1, M2, M3, M4, M5>::type
AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5) {
return typename internal::AnyOfResult5<M1, M2, M3, M4, M5>::type(
::testing::AnyOf(m1, m2),
::testing::AnyOf(m3, m4, m5));
}
template <typename M1, typename M2, typename M3, typename M4, typename M5,
typename M6>
inline typename internal::AnyOfResult6<M1, M2, M3, M4, M5, M6>::type
AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6) {
return typename internal::AnyOfResult6<M1, M2, M3, M4, M5, M6>::type(
::testing::AnyOf(m1, m2, m3),
::testing::AnyOf(m4, m5, m6));
}
template <typename M1, typename M2, typename M3, typename M4, typename M5,
typename M6, typename M7>
inline typename internal::AnyOfResult7<M1, M2, M3, M4, M5, M6, M7>::type
AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7) {
return typename internal::AnyOfResult7<M1, M2, M3, M4, M5, M6, M7>::type(
::testing::AnyOf(m1, m2, m3),
::testing::AnyOf(m4, m5, m6, m7));
}
template <typename M1, typename M2, typename M3, typename M4, typename M5,
typename M6, typename M7, typename M8>
inline typename internal::AnyOfResult8<M1, M2, M3, M4, M5, M6, M7, M8>::type
AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8) {
return typename internal::AnyOfResult8<M1, M2, M3, M4, M5, M6, M7, M8>::type(
::testing::AnyOf(m1, m2, m3, m4),
::testing::AnyOf(m5, m6, m7, m8));
}
template <typename M1, typename M2, typename M3, typename M4, typename M5,
typename M6, typename M7, typename M8, typename M9>
inline typename internal::AnyOfResult9<M1, M2, M3, M4, M5, M6, M7, M8, M9>::type
AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9) {
return typename internal::AnyOfResult9<M1, M2, M3, M4, M5, M6, M7, M8,
M9>::type(
::testing::AnyOf(m1, m2, m3, m4),
::testing::AnyOf(m5, m6, m7, m8, m9));
}
template <typename M1, typename M2, typename M3, typename M4, typename M5,
typename M6, typename M7, typename M8, typename M9, typename M10>
inline typename internal::AnyOfResult10<M1, M2, M3, M4, M5, M6, M7, M8, M9,
M10>::type
AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
return typename internal::AnyOfResult10<M1, M2, M3, M4, M5, M6, M7, M8, M9,
M10>::type(
::testing::AnyOf(m1, m2, m3, m4, m5),
::testing::AnyOf(m6, m7, m8, m9, m10));
}
} // namespace testing
@ -795,7 +627,7 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
return ::testing::internal::FormatMatcherDescription(\
negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
::testing::tuple<>()));\
::std::tuple<>()));\
}\
};\
template <typename arg_type>\
@ -845,7 +677,7 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
return ::testing::internal::FormatMatcherDescription(\
negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
::testing::tuple<p0##_type>(p0)));\
::std::tuple<p0##_type>(p0)));\
}\
};\
template <typename arg_type>\
@ -901,7 +733,7 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
return ::testing::internal::FormatMatcherDescription(\
negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
::testing::tuple<p0##_type, p1##_type>(p0, p1)));\
::std::tuple<p0##_type, p1##_type>(p0, p1)));\
}\
};\
template <typename arg_type>\
@ -963,8 +795,7 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
return ::testing::internal::FormatMatcherDescription(\
negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
::testing::tuple<p0##_type, p1##_type, p2##_type>(p0, p1, \
p2)));\
::std::tuple<p0##_type, p1##_type, p2##_type>(p0, p1, p2)));\
}\
};\
template <typename arg_type>\
@ -1032,8 +863,8 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
return ::testing::internal::FormatMatcherDescription(\
negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
::testing::tuple<p0##_type, p1##_type, p2##_type, \
p3##_type>(p0, p1, p2, p3)));\
::std::tuple<p0##_type, p1##_type, p2##_type, p3##_type>(p0, \
p1, p2, p3)));\
}\
};\
template <typename arg_type>\
@ -1110,7 +941,7 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
return ::testing::internal::FormatMatcherDescription(\
negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
::testing::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
::std::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
p4##_type>(p0, p1, p2, p3, p4)));\
}\
};\
@ -1192,7 +1023,7 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
return ::testing::internal::FormatMatcherDescription(\
negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
::testing::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
::std::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
p4##_type, p5##_type>(p0, p1, p2, p3, p4, p5)));\
}\
};\
@ -1280,7 +1111,7 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
return ::testing::internal::FormatMatcherDescription(\
negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
::testing::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
::std::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
p4##_type, p5##_type, p6##_type>(p0, p1, p2, p3, p4, p5, \
p6)));\
}\
@ -1377,7 +1208,7 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
return ::testing::internal::FormatMatcherDescription(\
negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
::testing::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
::std::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
p4##_type, p5##_type, p6##_type, p7##_type>(p0, p1, p2, \
p3, p4, p5, p6, p7)));\
}\
@ -1480,7 +1311,7 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
return ::testing::internal::FormatMatcherDescription(\
negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
::testing::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
::std::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
p4##_type, p5##_type, p6##_type, p7##_type, \
p8##_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8)));\
}\
@ -1590,7 +1421,7 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {
return ::testing::internal::FormatMatcherDescription(\
negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
::testing::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
::std::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \
p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \
p9##_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)));\
}\

View File

@ -55,7 +55,7 @@ $range i 0..n-1
// The type of the i-th (0-based) field of Tuple.
#define GMOCK_FIELD_TYPE_(Tuple, i) \
typename ::testing::tuple_element<i, Tuple>::type
typename ::std::tuple_element<i, Tuple>::type
// TupleFields<Tuple, k0, ..., kn> is for selecting fields from a
// tuple of type Tuple. It has two members:
@ -63,10 +63,11 @@ $range i 0..n-1
// type: a tuple type whose i-th field is the ki-th field of Tuple.
// GetSelectedFields(t): returns fields k0, ..., and kn of t as a tuple.
//
// For example, in class TupleFields<tuple<bool, char, int>, 2, 0>, we have:
// For example, in class TupleFields<std::tuple<bool, char, int>, 2, 0>,
// we have:
//
// type is tuple<int, bool>, and
// GetSelectedFields(make_tuple(true, 'a', 42)) is (42, true).
// type is std::tuple<int, bool>, and
// GetSelectedFields(std::make_tuple(true, 'a', 42)) is (42, true).
template <class Tuple$for i [[, int k$i = -1]]>
class TupleFields;
@ -75,9 +76,9 @@ class TupleFields;
template <class Tuple$for i [[, int k$i]]>
class TupleFields {
public:
typedef ::testing::tuple<$for i, [[GMOCK_FIELD_TYPE_(Tuple, k$i)]]> type;
typedef ::std::tuple<$for i, [[GMOCK_FIELD_TYPE_(Tuple, k$i)]]> type;
static type GetSelectedFields(const Tuple& t) {
return type($for i, [[get<k$i>(t)]]);
return type($for i, [[std::get<k$i>(t)]]);
}
};
@ -91,9 +92,9 @@ $range k 0..n-1
template <class Tuple$for j [[, int k$j]]>
class TupleFields<Tuple, $for k, [[$if k < i [[k$k]] $else [[-1]]]]> {
public:
typedef ::testing::tuple<$for j, [[GMOCK_FIELD_TYPE_(Tuple, k$j)]]> type;
typedef ::std::tuple<$for j, [[GMOCK_FIELD_TYPE_(Tuple, k$j)]]> type;
static type GetSelectedFields(const Tuple& $if i==0 [[/* t */]] $else [[t]]) {
return type($for j, [[get<k$j>(t)]]);
return type($for j, [[std::get<k$j>(t)]]);
}
};
@ -187,36 +188,6 @@ class ArgsMatcher {
GTEST_DISALLOW_ASSIGN_(ArgsMatcher);
};
// A set of metafunctions for computing the result type of AnyOf.
// AnyOf(m1, ..., mN) returns
// AnyOfResultN<decltype(m1), ..., decltype(mN)>::type.
// Although AnyOf isn't defined for one argument, AnyOfResult1 is defined
// to simplify the implementation.
template <typename M1>
struct AnyOfResult1 {
typedef M1 type;
};
$range i 1..n
$range i 2..n
$for i [[
$range j 2..i
$var m = i/2
$range k 1..m
$range t m+1..i
template <typename M1$for j [[, typename M$j]]>
struct AnyOfResult$i {
typedef EitherOfMatcher<
typename AnyOfResult$m<$for k, [[M$k]]>::type,
typename AnyOfResult$(i-m)<$for t, [[M$t]]>::type
> type;
};
]]
} // namespace internal
// Args<N1, N2, ..., Nk>(a_matcher) matches a tuple if the selected
@ -233,26 +204,6 @@ Args(const InnerMatcher& matcher) {
}
]]
// AnyOf(m1, m2, ..., mk) matches any value that matches any of the given
// sub-matchers. AnyOf is called fully qualified to prevent ADL from firing.
$range i 2..n
$for i [[
$range j 1..i
$var m = i/2
$range k 1..m
$range t m+1..i
template <$for j, [[typename M$j]]>
inline typename internal::AnyOfResult$i<$for j, [[M$j]]>::type
AnyOf($for j, [[M$j m$j]]) {
return typename internal::AnyOfResult$i<$for j, [[M$j]]>::type(
$if m == 1 [[m1]] $else [[::testing::AnyOf($for k, [[m$k]])]],
$if m+1 == i [[m$i]] $else [[::testing::AnyOf($for t, [[m$t]])]]);
}
]]
} // namespace testing
@ -534,7 +485,7 @@ $var param_field_decls2 = [[$for j
return ::testing::internal::FormatMatcherDescription(\
negation, #name, \
::testing::internal::UniversalTersePrintTupleFieldsToStrings(\
::testing::tuple<$for j, [[p$j##_type]]>($for j, [[p$j]])));\
::std::tuple<$for j, [[p$j##_type]]>($for j, [[p$j]])));\
}\
};\
template <typename arg_type>\

View File

@ -905,8 +905,8 @@ class TuplePrefix {
template <typename MatcherTuple, typename ValueTuple>
static bool Matches(const MatcherTuple& matcher_tuple,
const ValueTuple& value_tuple) {
return TuplePrefix<N - 1>::Matches(matcher_tuple, value_tuple)
&& get<N - 1>(matcher_tuple).Matches(get<N - 1>(value_tuple));
return TuplePrefix<N - 1>::Matches(matcher_tuple, value_tuple) &&
std::get<N - 1>(matcher_tuple).Matches(std::get<N - 1>(value_tuple));
}
// TuplePrefix<N>::ExplainMatchFailuresTo(matchers, values, os)
@ -922,16 +922,16 @@ class TuplePrefix {
// Then describes the failure (if any) in the (N - 1)-th (0-based)
// field.
typename tuple_element<N - 1, MatcherTuple>::type matcher =
get<N - 1>(matchers);
typedef typename tuple_element<N - 1, ValueTuple>::type Value;
GTEST_REFERENCE_TO_CONST_(Value) value = get<N - 1>(values);
typename std::tuple_element<N - 1, MatcherTuple>::type matcher =
std::get<N - 1>(matchers);
typedef typename std::tuple_element<N - 1, ValueTuple>::type Value;
GTEST_REFERENCE_TO_CONST_(Value) value = std::get<N - 1>(values);
StringMatchResultListener listener;
if (!matcher.MatchAndExplain(value, &listener)) {
// FIXME: include in the message the name of the parameter
// as used in MOCK_METHOD*() when possible.
*os << " Expected arg #" << N - 1 << ": ";
get<N - 1>(matchers).DescribeTo(os);
std::get<N - 1>(matchers).DescribeTo(os);
*os << "\n Actual: ";
// We remove the reference in type Value to prevent the
// universal printer from printing the address of value, which
@ -971,11 +971,11 @@ bool TupleMatches(const MatcherTuple& matcher_tuple,
const ValueTuple& value_tuple) {
// Makes sure that matcher_tuple and value_tuple have the same
// number of fields.
GTEST_COMPILE_ASSERT_(tuple_size<MatcherTuple>::value ==
tuple_size<ValueTuple>::value,
GTEST_COMPILE_ASSERT_(std::tuple_size<MatcherTuple>::value ==
std::tuple_size<ValueTuple>::value,
matcher_and_value_have_different_numbers_of_fields);
return TuplePrefix<tuple_size<ValueTuple>::value>::
Matches(matcher_tuple, value_tuple);
return TuplePrefix<std::tuple_size<ValueTuple>::value>::Matches(matcher_tuple,
value_tuple);
}
// Describes failures in matching matchers against values. If there
@ -984,7 +984,7 @@ template <typename MatcherTuple, typename ValueTuple>
void ExplainMatchFailureTupleTo(const MatcherTuple& matchers,
const ValueTuple& values,
::std::ostream* os) {
TuplePrefix<tuple_size<MatcherTuple>::value>::ExplainMatchFailuresTo(
TuplePrefix<std::tuple_size<MatcherTuple>::value>::ExplainMatchFailuresTo(
matchers, values, os);
}
@ -995,7 +995,7 @@ void ExplainMatchFailureTupleTo(const MatcherTuple& matchers,
template <typename Tuple, typename Func, typename OutIter>
class TransformTupleValuesHelper {
private:
typedef ::testing::tuple_size<Tuple> TupleSize;
typedef ::std::tuple_size<Tuple> TupleSize;
public:
// For each member of tuple 't', taken in order, evaluates '*out++ = f(t)'.
@ -1008,7 +1008,7 @@ class TransformTupleValuesHelper {
template <typename Tup, size_t kRemainingSize>
struct IterateOverTuple {
OutIter operator() (Func f, const Tup& t, OutIter out) const {
*out++ = f(::testing::get<TupleSize::value - kRemainingSize>(t));
*out++ = f(::std::get<TupleSize::value - kRemainingSize>(t));
return IterateOverTuple<Tup, kRemainingSize - 1>()(f, t, out);
}
};
@ -1597,19 +1597,19 @@ class MatchesRegexMatcher {
// compared don't have to have the same type.
//
// The matcher defined here is polymorphic (for example, Eq() can be
// used to match a tuple<int, short>, a tuple<const long&, double>,
// used to match a std::tuple<int, short>, a std::tuple<const long&, double>,
// etc). Therefore we use a template type conversion operator in the
// implementation.
template <typename D, typename Op>
class PairMatchBase {
public:
template <typename T1, typename T2>
operator Matcher< ::testing::tuple<T1, T2> >() const {
return MakeMatcher(new Impl< ::testing::tuple<T1, T2> >);
operator Matcher<::std::tuple<T1, T2>>() const {
return MakeMatcher(new Impl<::std::tuple<T1, T2>>);
}
template <typename T1, typename T2>
operator Matcher<const ::testing::tuple<T1, T2>&>() const {
return MakeMatcher(new Impl<const ::testing::tuple<T1, T2>&>);
operator Matcher<const ::std::tuple<T1, T2>&>() const {
return MakeMatcher(new Impl<const ::std::tuple<T1, T2>&>);
}
private:
@ -1623,7 +1623,7 @@ class PairMatchBase {
virtual bool MatchAndExplain(
Tuple args,
MatchResultListener* /* listener */) const {
return Op()(::testing::get<0>(args), ::testing::get<1>(args));
return Op()(::std::get<0>(args), ::std::get<1>(args));
}
virtual void DescribeTo(::std::ostream* os) const {
*os << "are " << GetDesc;
@ -1807,7 +1807,7 @@ class VariadicMatcher {
std::vector<Matcher<T> >*,
std::integral_constant<size_t, sizeof...(Args)>) const {}
tuple<Args...> matchers_;
std::tuple<Args...> matchers_;
GTEST_DISALLOW_ASSIGN_(VariadicMatcher);
};
@ -1815,32 +1815,6 @@ class VariadicMatcher {
template <typename... Args>
using AllOfMatcher = VariadicMatcher<AllOfMatcherImpl, Args...>;
// Used for implementing the AllOf(m_1, ..., m_n) matcher, which
// matches a value that matches all of the matchers m_1, ..., and m_n.
template <typename Matcher1, typename Matcher2>
class BothOfMatcher {
public:
BothOfMatcher(Matcher1 matcher1, Matcher2 matcher2)
: matcher1_(matcher1), matcher2_(matcher2) {}
// This template type conversion operator allows a
// BothOfMatcher<Matcher1, Matcher2> object to match any type that
// both Matcher1 and Matcher2 can match.
template <typename T>
operator Matcher<T>() const {
std::vector<Matcher<T> > values;
values.push_back(SafeMatcherCast<T>(matcher1_));
values.push_back(SafeMatcherCast<T>(matcher2_));
return Matcher<T>(new AllOfMatcherImpl<T>(internal::move(values)));
}
private:
Matcher1 matcher1_;
Matcher2 matcher2_;
GTEST_DISALLOW_ASSIGN_(BothOfMatcher);
};
// Implements the AnyOf(m1, m2) matcher for a particular argument type
// T. We do not nest it inside the AnyOfMatcher class template, as
// that will prevent different instantiations of AnyOfMatcher from
@ -1905,40 +1879,10 @@ class AnyOfMatcherImpl
GTEST_DISALLOW_ASSIGN_(AnyOfMatcherImpl);
};
#if GTEST_LANG_CXX11
// AnyOfMatcher is used for the variadic implementation of AnyOf(m_1, m_2, ...).
template <typename... Args>
using AnyOfMatcher = VariadicMatcher<AnyOfMatcherImpl, Args...>;
#endif // GTEST_LANG_CXX11
// Used for implementing the AnyOf(m_1, ..., m_n) matcher, which
// matches a value that matches at least one of the matchers m_1, ...,
// and m_n.
template <typename Matcher1, typename Matcher2>
class EitherOfMatcher {
public:
EitherOfMatcher(Matcher1 matcher1, Matcher2 matcher2)
: matcher1_(matcher1), matcher2_(matcher2) {}
// This template type conversion operator allows a
// EitherOfMatcher<Matcher1, Matcher2> object to match any type that
// both Matcher1 and Matcher2 can match.
template <typename T>
operator Matcher<T>() const {
std::vector<Matcher<T> > values;
values.push_back(SafeMatcherCast<T>(matcher1_));
values.push_back(SafeMatcherCast<T>(matcher2_));
return Matcher<T>(new AnyOfMatcherImpl<T>(internal::move(values)));
}
private:
Matcher1 matcher1_;
Matcher2 matcher2_;
GTEST_DISALLOW_ASSIGN_(EitherOfMatcher);
};
// Used for implementing Truly(pred), which turns a predicate into a
// matcher.
template <typename Predicate>
@ -2246,14 +2190,14 @@ class FloatingEq2Matcher {
}
template <typename T1, typename T2>
operator Matcher< ::testing::tuple<T1, T2> >() const {
operator Matcher<::std::tuple<T1, T2>>() const {
return MakeMatcher(
new Impl< ::testing::tuple<T1, T2> >(max_abs_error_, nan_eq_nan_));
new Impl<::std::tuple<T1, T2>>(max_abs_error_, nan_eq_nan_));
}
template <typename T1, typename T2>
operator Matcher<const ::testing::tuple<T1, T2>&>() const {
operator Matcher<const ::std::tuple<T1, T2>&>() const {
return MakeMatcher(
new Impl<const ::testing::tuple<T1, T2>&>(max_abs_error_, nan_eq_nan_));
new Impl<const ::std::tuple<T1, T2>&>(max_abs_error_, nan_eq_nan_));
}
private:
@ -2271,14 +2215,14 @@ class FloatingEq2Matcher {
virtual bool MatchAndExplain(Tuple args,
MatchResultListener* listener) const {
if (max_abs_error_ == -1) {
FloatingEqMatcher<FloatType> fm(::testing::get<0>(args), nan_eq_nan_);
return static_cast<Matcher<FloatType> >(fm).MatchAndExplain(
::testing::get<1>(args), listener);
FloatingEqMatcher<FloatType> fm(::std::get<0>(args), nan_eq_nan_);
return static_cast<Matcher<FloatType>>(fm).MatchAndExplain(
::std::get<1>(args), listener);
} else {
FloatingEqMatcher<FloatType> fm(::testing::get<0>(args), nan_eq_nan_,
FloatingEqMatcher<FloatType> fm(::std::get<0>(args), nan_eq_nan_,
max_abs_error_);
return static_cast<Matcher<FloatType> >(fm).MatchAndExplain(
::testing::get<1>(args), listener);
return static_cast<Matcher<FloatType>>(fm).MatchAndExplain(
::std::get<1>(args), listener);
}
}
virtual void DescribeTo(::std::ostream* os) const {
@ -2982,7 +2926,7 @@ class WhenSortedByMatcher {
};
// Implements Pointwise(tuple_matcher, rhs_container). tuple_matcher
// must be able to be safely cast to Matcher<tuple<const T1&, const
// must be able to be safely cast to Matcher<std::tuple<const T1&, const
// T2&> >, where T1 and T2 are the types of elements in the LHS
// container and the RHS container respectively.
template <typename TupleMatcher, typename RhsContainer>
@ -3027,7 +2971,7 @@ class PointwiseMatcher {
// reference, as they may be expensive to copy. We must use tuple
// instead of pair here, as a pair cannot hold references (C++ 98,
// 20.2.2 [lib.pairs]).
typedef ::testing::tuple<const LhsValue&, const RhsValue&> InnerMatcherArg;
typedef ::std::tuple<const LhsValue&, const RhsValue&> InnerMatcherArg;
Impl(const TupleMatcher& tuple_matcher, const RhsStlContainer& rhs)
// mono_tuple_matcher_ holds a monomorphic version of the tuple matcher.
@ -3826,7 +3770,7 @@ class UnorderedElementsAreMatcher {
typedef typename View::value_type Element;
typedef ::std::vector<Matcher<const Element&> > MatcherVec;
MatcherVec matchers;
matchers.reserve(::testing::tuple_size<MatcherTuple>::value);
matchers.reserve(::std::tuple_size<MatcherTuple>::value);
TransformTupleValues(CastAndAppendTransform<const Element&>(), matchers_,
::std::back_inserter(matchers));
return MakeMatcher(new UnorderedElementsAreMatcherImpl<Container>(
@ -3848,7 +3792,7 @@ class ElementsAreMatcher {
operator Matcher<Container>() const {
GTEST_COMPILE_ASSERT_(
!IsHashTable<GTEST_REMOVE_REFERENCE_AND_CONST_(Container)>::value ||
::testing::tuple_size<MatcherTuple>::value < 2,
::std::tuple_size<MatcherTuple>::value < 2,
use_UnorderedElementsAre_with_hash_tables);
typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;
@ -3856,7 +3800,7 @@ class ElementsAreMatcher {
typedef typename View::value_type Element;
typedef ::std::vector<Matcher<const Element&> > MatcherVec;
MatcherVec matchers;
matchers.reserve(::testing::tuple_size<MatcherTuple>::value);
matchers.reserve(::std::tuple_size<MatcherTuple>::value);
TransformTupleValues(CastAndAppendTransform<const Element&>(), matchers_,
::std::back_inserter(matchers));
return MakeMatcher(new ElementsAreMatcherImpl<Container>(
@ -3949,7 +3893,7 @@ class BoundSecondMatcher {
template <typename T>
class Impl : public MatcherInterface<T> {
public:
typedef ::testing::tuple<T, Second> ArgTuple;
typedef ::std::tuple<T, Second> ArgTuple;
Impl(const Tuple2Matcher& tm, const Second& second)
: mono_tuple2_matcher_(SafeMatcherCast<const ArgTuple&>(tm)),
@ -4069,6 +4013,7 @@ class VariantMatcher {
template <typename Variant>
bool MatchAndExplain(const Variant& value,
::testing::MatchResultListener* listener) const {
using std::get;
if (!listener->IsInterested()) {
return holds_alternative<T>(value) && matcher_.Matches(get<T>(value));
}
@ -4843,7 +4788,7 @@ WhenSorted(const ContainerMatcher& container_matcher) {
// Matches an STL-style container or a native array that contains the
// same number of elements as in rhs, where its i-th element and rhs's
// i-th element (as a pair) satisfy the given pair matcher, for all i.
// TupleMatcher must be able to be safely cast to Matcher<tuple<const
// TupleMatcher must be able to be safely cast to Matcher<std::tuple<const
// T1&, const T2&> >, where T1 and T2 are the types of elements in the
// LHS container and the RHS container respectively.
template <typename TupleMatcher, typename Container>
@ -4874,7 +4819,7 @@ inline internal::PointwiseMatcher<TupleMatcher, std::vector<T> > Pointwise(
// elements as in rhs, where in some permutation of the container, its
// i-th element and rhs's i-th element (as a pair) satisfy the given
// pair matcher, for all i. Tuple2Matcher must be able to be safely
// cast to Matcher<tuple<const T1&, const T2&> >, where T1 and T2 are
// cast to Matcher<std::tuple<const T1&, const T2&> >, where T1 and T2 are
// the types of elements in the LHS container and the RHS container
// respectively.
//
@ -5166,20 +5111,21 @@ std::string DescribeMatcher(const M& matcher, bool negation = false) {
}
template <typename... Args>
internal::ElementsAreMatcher<tuple<typename std::decay<const Args&>::type...>>
internal::ElementsAreMatcher<
std::tuple<typename std::decay<const Args&>::type...>>
ElementsAre(const Args&... matchers) {
return internal::ElementsAreMatcher<
tuple<typename std::decay<const Args&>::type...>>(
make_tuple(matchers...));
std::tuple<typename std::decay<const Args&>::type...>>(
std::make_tuple(matchers...));
}
template <typename... Args>
internal::UnorderedElementsAreMatcher<
tuple<typename std::decay<const Args&>::type...>>
std::tuple<typename std::decay<const Args&>::type...>>
UnorderedElementsAre(const Args&... matchers) {
return internal::UnorderedElementsAreMatcher<
tuple<typename std::decay<const Args&>::type...>>(
make_tuple(matchers...));
std::tuple<typename std::decay<const Args&>::type...>>(
std::make_tuple(matchers...));
}
// Define variadic matcher versions.

View File

@ -162,7 +162,7 @@ WithArg(const InnerAction& action) {
ACTION_TEMPLATE(ReturnArg,
HAS_1_TEMPLATE_PARAMS(int, k),
AND_0_VALUE_PARAMS()) {
return ::testing::get<k>(args);
return ::std::get<k>(args);
}
// Action SaveArg<k>(pointer) saves the k-th (0-based) argument of the
@ -170,7 +170,7 @@ ACTION_TEMPLATE(ReturnArg,
ACTION_TEMPLATE(SaveArg,
HAS_1_TEMPLATE_PARAMS(int, k),
AND_1_VALUE_PARAMS(pointer)) {
*pointer = ::testing::get<k>(args);
*pointer = ::std::get<k>(args);
}
// Action SaveArgPointee<k>(pointer) saves the value pointed to
@ -178,7 +178,7 @@ ACTION_TEMPLATE(SaveArg,
ACTION_TEMPLATE(SaveArgPointee,
HAS_1_TEMPLATE_PARAMS(int, k),
AND_1_VALUE_PARAMS(pointer)) {
*pointer = *::testing::get<k>(args);
*pointer = *::std::get<k>(args);
}
// Action SetArgReferee<k>(value) assigns 'value' to the variable
@ -186,13 +186,13 @@ ACTION_TEMPLATE(SaveArgPointee,
ACTION_TEMPLATE(SetArgReferee,
HAS_1_TEMPLATE_PARAMS(int, k),
AND_1_VALUE_PARAMS(value)) {
typedef typename ::testing::tuple_element<k, args_type>::type argk_type;
typedef typename ::std::tuple_element<k, args_type>::type argk_type;
// Ensures that argument #k is a reference. If you get a compiler
// error on the next line, you are using SetArgReferee<k>(value) in
// a mock function whose k-th (0-based) argument is not a reference.
GTEST_COMPILE_ASSERT_(internal::is_reference<argk_type>::value,
SetArgReferee_must_be_used_with_a_reference_argument);
::testing::get<k>(args) = value;
::std::get<k>(args) = value;
}
// Action SetArrayArgument<k>(first, last) copies the elements in
@ -205,9 +205,9 @@ ACTION_TEMPLATE(SetArrayArgument,
AND_2_VALUE_PARAMS(first, last)) {
// Visual Studio deprecates ::std::copy, so we use our own copy in that case.
#ifdef _MSC_VER
internal::CopyElements(first, last, ::testing::get<k>(args));
internal::CopyElements(first, last, ::std::get<k>(args));
#else
::std::copy(first, last, ::testing::get<k>(args));
::std::copy(first, last, ::std::get<k>(args));
#endif
}
@ -216,7 +216,7 @@ ACTION_TEMPLATE(SetArrayArgument,
ACTION_TEMPLATE(DeleteArg,
HAS_1_TEMPLATE_PARAMS(int, k),
AND_0_VALUE_PARAMS()) {
delete ::testing::get<k>(args);
delete ::std::get<k>(args);
}
// This action returns the value pointed to by 'pointer'.

View File

@ -70,79 +70,71 @@ template <typename Tuple>
struct MatcherTuple;
template <>
struct MatcherTuple< ::testing::tuple<> > {
typedef ::testing::tuple< > type;
struct MatcherTuple< ::std::tuple<> > {
typedef ::std::tuple< > type;
};
template <typename A1>
struct MatcherTuple< ::testing::tuple<A1> > {
typedef ::testing::tuple<Matcher<A1> > type;
struct MatcherTuple< ::std::tuple<A1> > {
typedef ::std::tuple<Matcher<A1> > type;
};
template <typename A1, typename A2>
struct MatcherTuple< ::testing::tuple<A1, A2> > {
typedef ::testing::tuple<Matcher<A1>, Matcher<A2> > type;
struct MatcherTuple< ::std::tuple<A1, A2> > {
typedef ::std::tuple<Matcher<A1>, Matcher<A2> > type;
};
template <typename A1, typename A2, typename A3>
struct MatcherTuple< ::testing::tuple<A1, A2, A3> > {
typedef ::testing::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3> > type;
struct MatcherTuple< ::std::tuple<A1, A2, A3> > {
typedef ::std::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3> > type;
};
template <typename A1, typename A2, typename A3, typename A4>
struct MatcherTuple< ::testing::tuple<A1, A2, A3, A4> > {
typedef ::testing::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4> >
type;
struct MatcherTuple< ::std::tuple<A1, A2, A3, A4> > {
typedef ::std::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>,
Matcher<A4> > type;
};
template <typename A1, typename A2, typename A3, typename A4, typename A5>
struct MatcherTuple< ::testing::tuple<A1, A2, A3, A4, A5> > {
typedef ::testing::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
Matcher<A5> >
type;
struct MatcherTuple< ::std::tuple<A1, A2, A3, A4, A5> > {
typedef ::std::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
Matcher<A5> > type;
};
template <typename A1, typename A2, typename A3, typename A4, typename A5,
typename A6>
struct MatcherTuple< ::testing::tuple<A1, A2, A3, A4, A5, A6> > {
typedef ::testing::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
Matcher<A5>, Matcher<A6> >
type;
struct MatcherTuple< ::std::tuple<A1, A2, A3, A4, A5, A6> > {
typedef ::std::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
Matcher<A5>, Matcher<A6> > type;
};
template <typename A1, typename A2, typename A3, typename A4, typename A5,
typename A6, typename A7>
struct MatcherTuple< ::testing::tuple<A1, A2, A3, A4, A5, A6, A7> > {
typedef ::testing::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
Matcher<A5>, Matcher<A6>, Matcher<A7> >
type;
struct MatcherTuple< ::std::tuple<A1, A2, A3, A4, A5, A6, A7> > {
typedef ::std::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
Matcher<A5>, Matcher<A6>, Matcher<A7> > type;
};
template <typename A1, typename A2, typename A3, typename A4, typename A5,
typename A6, typename A7, typename A8>
struct MatcherTuple< ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8> > {
typedef ::testing::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
Matcher<A5>, Matcher<A6>, Matcher<A7>, Matcher<A8> >
type;
struct MatcherTuple< ::std::tuple<A1, A2, A3, A4, A5, A6, A7, A8> > {
typedef ::std::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
Matcher<A5>, Matcher<A6>, Matcher<A7>, Matcher<A8> > type;
};
template <typename A1, typename A2, typename A3, typename A4, typename A5,
typename A6, typename A7, typename A8, typename A9>
struct MatcherTuple< ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9> > {
typedef ::testing::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
Matcher<A5>, Matcher<A6>, Matcher<A7>, Matcher<A8>,
Matcher<A9> >
type;
struct MatcherTuple< ::std::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9> > {
typedef ::std::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
Matcher<A5>, Matcher<A6>, Matcher<A7>, Matcher<A8>, Matcher<A9> > type;
};
template <typename A1, typename A2, typename A3, typename A4, typename A5,
typename A6, typename A7, typename A8, typename A9, typename A10>
struct MatcherTuple< ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9,
A10> > {
typedef ::testing::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
Matcher<A5>, Matcher<A6>, Matcher<A7>, Matcher<A8>,
Matcher<A9>, Matcher<A10> >
type;
struct MatcherTuple< ::std::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10> > {
typedef ::std::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,
Matcher<A5>, Matcher<A6>, Matcher<A7>, Matcher<A8>, Matcher<A9>,
Matcher<A10> > type;
};
// Template struct Function<F>, where F must be a function type, contains
@ -164,7 +156,7 @@ struct Function;
template <typename R>
struct Function<R()> {
typedef R Result;
typedef ::testing::tuple<> ArgumentTuple;
typedef ::std::tuple<> ArgumentTuple;
typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
typedef void MakeResultVoid();
typedef IgnoredValue MakeResultIgnoredValue();
@ -174,7 +166,7 @@ template <typename R, typename A1>
struct Function<R(A1)>
: Function<R()> {
typedef A1 Argument1;
typedef ::testing::tuple<A1> ArgumentTuple;
typedef ::std::tuple<A1> ArgumentTuple;
typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
typedef void MakeResultVoid(A1);
typedef IgnoredValue MakeResultIgnoredValue(A1);
@ -184,7 +176,7 @@ template <typename R, typename A1, typename A2>
struct Function<R(A1, A2)>
: Function<R(A1)> {
typedef A2 Argument2;
typedef ::testing::tuple<A1, A2> ArgumentTuple;
typedef ::std::tuple<A1, A2> ArgumentTuple;
typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
typedef void MakeResultVoid(A1, A2);
typedef IgnoredValue MakeResultIgnoredValue(A1, A2);
@ -194,7 +186,7 @@ template <typename R, typename A1, typename A2, typename A3>
struct Function<R(A1, A2, A3)>
: Function<R(A1, A2)> {
typedef A3 Argument3;
typedef ::testing::tuple<A1, A2, A3> ArgumentTuple;
typedef ::std::tuple<A1, A2, A3> ArgumentTuple;
typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
typedef void MakeResultVoid(A1, A2, A3);
typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3);
@ -204,7 +196,7 @@ template <typename R, typename A1, typename A2, typename A3, typename A4>
struct Function<R(A1, A2, A3, A4)>
: Function<R(A1, A2, A3)> {
typedef A4 Argument4;
typedef ::testing::tuple<A1, A2, A3, A4> ArgumentTuple;
typedef ::std::tuple<A1, A2, A3, A4> ArgumentTuple;
typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
typedef void MakeResultVoid(A1, A2, A3, A4);
typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4);
@ -215,7 +207,7 @@ template <typename R, typename A1, typename A2, typename A3, typename A4,
struct Function<R(A1, A2, A3, A4, A5)>
: Function<R(A1, A2, A3, A4)> {
typedef A5 Argument5;
typedef ::testing::tuple<A1, A2, A3, A4, A5> ArgumentTuple;
typedef ::std::tuple<A1, A2, A3, A4, A5> ArgumentTuple;
typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
typedef void MakeResultVoid(A1, A2, A3, A4, A5);
typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5);
@ -226,7 +218,7 @@ template <typename R, typename A1, typename A2, typename A3, typename A4,
struct Function<R(A1, A2, A3, A4, A5, A6)>
: Function<R(A1, A2, A3, A4, A5)> {
typedef A6 Argument6;
typedef ::testing::tuple<A1, A2, A3, A4, A5, A6> ArgumentTuple;
typedef ::std::tuple<A1, A2, A3, A4, A5, A6> ArgumentTuple;
typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6);
typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6);
@ -237,7 +229,7 @@ template <typename R, typename A1, typename A2, typename A3, typename A4,
struct Function<R(A1, A2, A3, A4, A5, A6, A7)>
: Function<R(A1, A2, A3, A4, A5, A6)> {
typedef A7 Argument7;
typedef ::testing::tuple<A1, A2, A3, A4, A5, A6, A7> ArgumentTuple;
typedef ::std::tuple<A1, A2, A3, A4, A5, A6, A7> ArgumentTuple;
typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6, A7);
typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6, A7);
@ -248,7 +240,7 @@ template <typename R, typename A1, typename A2, typename A3, typename A4,
struct Function<R(A1, A2, A3, A4, A5, A6, A7, A8)>
: Function<R(A1, A2, A3, A4, A5, A6, A7)> {
typedef A8 Argument8;
typedef ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8> ArgumentTuple;
typedef ::std::tuple<A1, A2, A3, A4, A5, A6, A7, A8> ArgumentTuple;
typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6, A7, A8);
typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6, A7, A8);
@ -259,7 +251,7 @@ template <typename R, typename A1, typename A2, typename A3, typename A4,
struct Function<R(A1, A2, A3, A4, A5, A6, A7, A8, A9)>
: Function<R(A1, A2, A3, A4, A5, A6, A7, A8)> {
typedef A9 Argument9;
typedef ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9> ArgumentTuple;
typedef ::std::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9> ArgumentTuple;
typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6, A7, A8, A9);
typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6, A7, A8,
@ -272,8 +264,7 @@ template <typename R, typename A1, typename A2, typename A3, typename A4,
struct Function<R(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)>
: Function<R(A1, A2, A3, A4, A5, A6, A7, A8, A9)> {
typedef A10 Argument10;
typedef ::testing::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9,
A10> ArgumentTuple;
typedef ::std::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10> ArgumentTuple;
typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10);
typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6, A7, A8,

View File

@ -78,8 +78,8 @@ $var typename_As = [[$for j, [[typename A$j]]]]
$var As = [[$for j, [[A$j]]]]
$var matcher_As = [[$for j, [[Matcher<A$j>]]]]
template <$typename_As>
struct MatcherTuple< ::testing::tuple<$As> > {
typedef ::testing::tuple<$matcher_As > type;
struct MatcherTuple< ::std::tuple<$As> > {
typedef ::std::tuple<$matcher_As > type;
};
@ -103,7 +103,7 @@ struct Function;
template <typename R>
struct Function<R()> {
typedef R Result;
typedef ::testing::tuple<> ArgumentTuple;
typedef ::std::tuple<> ArgumentTuple;
typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
typedef void MakeResultVoid();
typedef IgnoredValue MakeResultIgnoredValue();
@ -122,7 +122,7 @@ template <typename R$typename_As>
struct Function<R($As)>
: Function<R($prev_As)> {
typedef A$i Argument$i;
typedef ::testing::tuple<$As> ArgumentTuple;
typedef ::std::tuple<$As> ArgumentTuple;
typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;
typedef void MakeResultVoid($As);
typedef IgnoredValue MakeResultIgnoredValue($As);

View File

@ -493,7 +493,7 @@ class StlContainerView<Element[N]> {
// This specialization is used when RawContainer is a native array
// represented as a (pointer, size) tuple.
template <typename ElementPointer, typename Size>
class StlContainerView< ::testing::tuple<ElementPointer, Size> > {
class StlContainerView< ::std::tuple<ElementPointer, Size> > {
public:
typedef GTEST_REMOVE_CONST_(
typename internal::PointeeOf<ElementPointer>::type) RawElement;
@ -501,11 +501,12 @@ class StlContainerView< ::testing::tuple<ElementPointer, Size> > {
typedef const type const_reference;
static const_reference ConstReference(
const ::testing::tuple<ElementPointer, Size>& array) {
return type(get<0>(array), get<1>(array), RelationToSourceReference());
const ::std::tuple<ElementPointer, Size>& array) {
return type(std::get<0>(array), std::get<1>(array),
RelationToSourceReference());
}
static type Copy(const ::testing::tuple<ElementPointer, Size>& array) {
return type(get<0>(array), get<1>(array), RelationToSourceCopy());
static type Copy(const ::std::tuple<ElementPointer, Size>& array) {
return type(std::get<0>(array), std::get<1>(array), RelationToSourceCopy());
}
};

View File

@ -75,13 +75,9 @@ using testing::SetArgPointee;
using testing::SetArgumentPointee;
using testing::Unused;
using testing::_;
using testing::get;
using testing::internal::BuiltInDefaultValue;
using testing::internal::Int64;
using testing::internal::UInt64;
using testing::make_tuple;
using testing::tuple;
using testing::tuple_element;
#if !GTEST_OS_WINDOWS_MOBILE
using testing::SetErrnoAndReturn;
@ -382,8 +378,8 @@ typedef int MyGlobalFunction(bool, int);
class MyActionImpl : public ActionInterface<MyGlobalFunction> {
public:
virtual int Perform(const tuple<bool, int>& args) {
return get<0>(args) ? get<1>(args) : 0;
virtual int Perform(const std::tuple<bool, int>& args) {
return std::get<0>(args) ? std::get<1>(args) : 0;
}
};
@ -399,8 +395,8 @@ TEST(ActionInterfaceTest, MakeAction) {
// it a tuple whose size and type are compatible with F's argument
// types. For example, if F is int(), then Perform() takes a
// 0-tuple; if F is void(bool, int), then Perform() takes a
// tuple<bool, int>, and so on.
EXPECT_EQ(5, action.Perform(make_tuple(true, 5)));
// std::tuple<bool, int>, and so on.
EXPECT_EQ(5, action.Perform(std::make_tuple(true, 5)));
}
// Tests that Action<F> can be contructed from a pointer to
@ -413,8 +409,8 @@ TEST(ActionTest, CanBeConstructedFromActionInterface) {
TEST(ActionTest, DelegatesWorkToActionInterface) {
const Action<MyGlobalFunction> action(new MyActionImpl);
EXPECT_EQ(5, action.Perform(make_tuple(true, 5)));
EXPECT_EQ(0, action.Perform(make_tuple(false, 1)));
EXPECT_EQ(5, action.Perform(std::make_tuple(true, 5)));
EXPECT_EQ(0, action.Perform(std::make_tuple(false, 1)));
}
// Tests that Action<F> can be copied.
@ -423,22 +419,22 @@ TEST(ActionTest, IsCopyable) {
Action<MyGlobalFunction> a2(a1); // Tests the copy constructor.
// a1 should continue to work after being copied from.
EXPECT_EQ(5, a1.Perform(make_tuple(true, 5)));
EXPECT_EQ(0, a1.Perform(make_tuple(false, 1)));
EXPECT_EQ(5, a1.Perform(std::make_tuple(true, 5)));
EXPECT_EQ(0, a1.Perform(std::make_tuple(false, 1)));
// a2 should work like the action it was copied from.
EXPECT_EQ(5, a2.Perform(make_tuple(true, 5)));
EXPECT_EQ(0, a2.Perform(make_tuple(false, 1)));
EXPECT_EQ(5, a2.Perform(std::make_tuple(true, 5)));
EXPECT_EQ(0, a2.Perform(std::make_tuple(false, 1)));
a2 = a1; // Tests the assignment operator.
// a1 should continue to work after being copied from.
EXPECT_EQ(5, a1.Perform(make_tuple(true, 5)));
EXPECT_EQ(0, a1.Perform(make_tuple(false, 1)));
EXPECT_EQ(5, a1.Perform(std::make_tuple(true, 5)));
EXPECT_EQ(0, a1.Perform(std::make_tuple(false, 1)));
// a2 should work like the action it was copied from.
EXPECT_EQ(5, a2.Perform(make_tuple(true, 5)));
EXPECT_EQ(0, a2.Perform(make_tuple(false, 1)));
EXPECT_EQ(5, a2.Perform(std::make_tuple(true, 5)));
EXPECT_EQ(0, a2.Perform(std::make_tuple(false, 1)));
}
// Tests that an Action<From> object can be converted to a
@ -446,8 +442,8 @@ TEST(ActionTest, IsCopyable) {
class IsNotZero : public ActionInterface<bool(int)> { // NOLINT
public:
virtual bool Perform(const tuple<int>& arg) {
return get<0>(arg) != 0;
virtual bool Perform(const std::tuple<int>& arg) {
return std::get<0>(arg) != 0;
}
};
@ -460,8 +456,8 @@ class IsNotZero : public ActionInterface<bool(int)> { // NOLINT
TEST(ActionTest, CanBeConvertedToOtherActionType) {
const Action<bool(int)> a1(new IsNotZero); // NOLINT
const Action<int(char)> a2 = Action<int(char)>(a1); // NOLINT
EXPECT_EQ(1, a2.Perform(make_tuple('a')));
EXPECT_EQ(0, a2.Perform(make_tuple('\0')));
EXPECT_EQ(1, a2.Perform(std::make_tuple('a')));
EXPECT_EQ(0, a2.Perform(std::make_tuple('\0')));
}
#endif // !GTEST_OS_SYMBIAN
@ -475,7 +471,9 @@ class ReturnSecondArgumentAction {
// polymorphic action whose Perform() method template is either
// const or not. This lets us verify the non-const case.
template <typename Result, typename ArgumentTuple>
Result Perform(const ArgumentTuple& args) { return get<1>(args); }
Result Perform(const ArgumentTuple& args) {
return std::get<1>(args);
}
};
// Implements a polymorphic action that can be used in a nullary
@ -490,7 +488,9 @@ class ReturnZeroFromNullaryFunctionAction {
// polymorphic action whose Perform() method template is either
// const or not. This lets us verify the const case.
template <typename Result>
Result Perform(const tuple<>&) const { return 0; }
Result Perform(const std::tuple<>&) const {
return 0;
}
};
// These functions verify that MakePolymorphicAction() returns a
@ -509,42 +509,42 @@ ReturnZeroFromNullaryFunction() {
// implementation class into a polymorphic action.
TEST(MakePolymorphicActionTest, ConstructsActionFromImpl) {
Action<int(bool, int, double)> a1 = ReturnSecondArgument(); // NOLINT
EXPECT_EQ(5, a1.Perform(make_tuple(false, 5, 2.0)));
EXPECT_EQ(5, a1.Perform(std::make_tuple(false, 5, 2.0)));
}
// Tests that MakePolymorphicAction() works when the implementation
// class' Perform() method template has only one template parameter.
TEST(MakePolymorphicActionTest, WorksWhenPerformHasOneTemplateParameter) {
Action<int()> a1 = ReturnZeroFromNullaryFunction();
EXPECT_EQ(0, a1.Perform(make_tuple()));
EXPECT_EQ(0, a1.Perform(std::make_tuple()));
Action<void*()> a2 = ReturnZeroFromNullaryFunction();
EXPECT_TRUE(a2.Perform(make_tuple()) == nullptr);
EXPECT_TRUE(a2.Perform(std::make_tuple()) == nullptr);
}
// Tests that Return() works as an action for void-returning
// functions.
TEST(ReturnTest, WorksForVoid) {
const Action<void(int)> ret = Return(); // NOLINT
return ret.Perform(make_tuple(1));
return ret.Perform(std::make_tuple(1));
}
// Tests that Return(v) returns v.
TEST(ReturnTest, ReturnsGivenValue) {
Action<int()> ret = Return(1); // NOLINT
EXPECT_EQ(1, ret.Perform(make_tuple()));
EXPECT_EQ(1, ret.Perform(std::make_tuple()));
ret = Return(-5);
EXPECT_EQ(-5, ret.Perform(make_tuple()));
EXPECT_EQ(-5, ret.Perform(std::make_tuple()));
}
// Tests that Return("string literal") works.
TEST(ReturnTest, AcceptsStringLiteral) {
Action<const char*()> a1 = Return("Hello");
EXPECT_STREQ("Hello", a1.Perform(make_tuple()));
EXPECT_STREQ("Hello", a1.Perform(std::make_tuple()));
Action<std::string()> a2 = Return("world");
EXPECT_EQ("world", a2.Perform(make_tuple()));
EXPECT_EQ("world", a2.Perform(std::make_tuple()));
}
// Test struct which wraps a vector of integers. Used in
@ -563,7 +563,7 @@ TEST(ReturnTest, SupportsWrapperReturnType) {
// Return() called with 'v' as argument. The Action will return the same data
// as 'v' (copy) but it will be wrapped in an IntegerVectorWrapper.
Action<IntegerVectorWrapper()> a = Return(v);
const std::vector<int>& result = *(a.Perform(make_tuple()).v);
const std::vector<int>& result = *(a.Perform(std::make_tuple()).v);
EXPECT_THAT(result, ::testing::ElementsAre(0, 1, 2, 3, 4));
}
@ -581,10 +581,10 @@ TEST(ReturnTest, IsCovariant) {
Base base;
Derived derived;
Action<Base*()> ret = Return(&base);
EXPECT_EQ(&base, ret.Perform(make_tuple()));
EXPECT_EQ(&base, ret.Perform(std::make_tuple()));
ret = Return(&derived);
EXPECT_EQ(&derived, ret.Perform(make_tuple()));
EXPECT_EQ(&derived, ret.Perform(std::make_tuple()));
}
// Tests that the type of the value passed into Return is converted into T
@ -615,7 +615,7 @@ TEST(ReturnTest, ConvertsArgumentWhenConverted) {
EXPECT_TRUE(converted) << "Return must convert its argument in its own "
<< "conversion operator.";
converted = false;
action.Perform(tuple<>());
action.Perform(std::tuple<>());
EXPECT_FALSE(converted) << "Action must NOT convert its argument "
<< "when performed.";
}
@ -636,10 +636,10 @@ TEST(ReturnTest, CanConvertArgumentUsingNonConstTypeCastOperator) {
// Tests that ReturnNull() returns NULL in a pointer-returning function.
TEST(ReturnNullTest, WorksInPointerReturningFunction) {
const Action<int*()> a1 = ReturnNull();
EXPECT_TRUE(a1.Perform(make_tuple()) == nullptr);
EXPECT_TRUE(a1.Perform(std::make_tuple()) == nullptr);
const Action<const char*(bool)> a2 = ReturnNull(); // NOLINT
EXPECT_TRUE(a2.Perform(make_tuple(true)) == nullptr);
EXPECT_TRUE(a2.Perform(std::make_tuple(true)) == nullptr);
}
#if GTEST_HAS_STD_UNIQUE_PTR_
@ -647,10 +647,10 @@ TEST(ReturnNullTest, WorksInPointerReturningFunction) {
// functions.
TEST(ReturnNullTest, WorksInSmartPointerReturningFunction) {
const Action<std::unique_ptr<const int>()> a1 = ReturnNull();
EXPECT_TRUE(a1.Perform(make_tuple()) == nullptr);
EXPECT_TRUE(a1.Perform(std::make_tuple()) == nullptr);
const Action<std::shared_ptr<int>(std::string)> a2 = ReturnNull();
EXPECT_TRUE(a2.Perform(make_tuple("foo")) == nullptr);
EXPECT_TRUE(a2.Perform(std::make_tuple("foo")) == nullptr);
}
#endif // GTEST_HAS_STD_UNIQUE_PTR_
@ -659,7 +659,7 @@ TEST(ReturnRefTest, WorksForReference) {
const int n = 0;
const Action<const int&(bool)> ret = ReturnRef(n); // NOLINT
EXPECT_EQ(&n, &ret.Perform(make_tuple(true)));
EXPECT_EQ(&n, &ret.Perform(std::make_tuple(true)));
}
// Tests that ReturnRef(v) is covariant.
@ -667,10 +667,10 @@ TEST(ReturnRefTest, IsCovariant) {
Base base;
Derived derived;
Action<Base&()> a = ReturnRef(base);
EXPECT_EQ(&base, &a.Perform(make_tuple()));
EXPECT_EQ(&base, &a.Perform(std::make_tuple()));
a = ReturnRef(derived);
EXPECT_EQ(&derived, &a.Perform(make_tuple()));
EXPECT_EQ(&derived, &a.Perform(std::make_tuple()));
}
// Tests that ReturnRefOfCopy(v) works for reference types.
@ -678,12 +678,12 @@ TEST(ReturnRefOfCopyTest, WorksForReference) {
int n = 42;
const Action<const int&()> ret = ReturnRefOfCopy(n);
EXPECT_NE(&n, &ret.Perform(make_tuple()));
EXPECT_EQ(42, ret.Perform(make_tuple()));
EXPECT_NE(&n, &ret.Perform(std::make_tuple()));
EXPECT_EQ(42, ret.Perform(std::make_tuple()));
n = 43;
EXPECT_NE(&n, &ret.Perform(make_tuple()));
EXPECT_EQ(42, ret.Perform(make_tuple()));
EXPECT_NE(&n, &ret.Perform(std::make_tuple()));
EXPECT_EQ(42, ret.Perform(std::make_tuple()));
}
// Tests that ReturnRefOfCopy(v) is covariant.
@ -691,10 +691,10 @@ TEST(ReturnRefOfCopyTest, IsCovariant) {
Base base;
Derived derived;
Action<Base&()> a = ReturnRefOfCopy(base);
EXPECT_NE(&base, &a.Perform(make_tuple()));
EXPECT_NE(&base, &a.Perform(std::make_tuple()));
a = ReturnRefOfCopy(derived);
EXPECT_NE(&derived, &a.Perform(make_tuple()));
EXPECT_NE(&derived, &a.Perform(std::make_tuple()));
}
// Tests that DoDefault() does the default action for the mock method.
@ -800,14 +800,14 @@ TEST(SetArgPointeeTest, SetsTheNthPointee) {
int n = 0;
char ch = '\0';
a.Perform(make_tuple(true, &n, &ch));
a.Perform(std::make_tuple(true, &n, &ch));
EXPECT_EQ(2, n);
EXPECT_EQ('\0', ch);
a = SetArgPointee<2>('a');
n = 0;
ch = '\0';
a.Perform(make_tuple(true, &n, &ch));
a.Perform(std::make_tuple(true, &n, &ch));
EXPECT_EQ(0, n);
EXPECT_EQ('a', ch);
}
@ -820,13 +820,13 @@ TEST(SetArgPointeeTest, AcceptsStringLiteral) {
Action<MyFunction> a = SetArgPointee<0>("hi");
std::string str;
const char* ptr = nullptr;
a.Perform(make_tuple(&str, &ptr));
a.Perform(std::make_tuple(&str, &ptr));
EXPECT_EQ("hi", str);
EXPECT_TRUE(ptr == nullptr);
a = SetArgPointee<1>("world");
str = "";
a.Perform(make_tuple(&str, &ptr));
a.Perform(std::make_tuple(&str, &ptr));
EXPECT_EQ("", str);
EXPECT_STREQ("world", ptr);
}
@ -835,7 +835,7 @@ TEST(SetArgPointeeTest, AcceptsWideStringLiteral) {
typedef void MyFunction(const wchar_t**);
Action<MyFunction> a = SetArgPointee<0>(L"world");
const wchar_t* ptr = nullptr;
a.Perform(make_tuple(&ptr));
a.Perform(std::make_tuple(&ptr));
EXPECT_STREQ(L"world", ptr);
# if GTEST_HAS_STD_WSTRING
@ -843,7 +843,7 @@ TEST(SetArgPointeeTest, AcceptsWideStringLiteral) {
typedef void MyStringFunction(std::wstring*);
Action<MyStringFunction> a2 = SetArgPointee<0>(L"world");
std::wstring str = L"";
a2.Perform(make_tuple(&str));
a2.Perform(std::make_tuple(&str));
EXPECT_EQ(L"world", str);
# endif
@ -857,7 +857,7 @@ TEST(SetArgPointeeTest, AcceptsCharPointer) {
Action<MyFunction> a = SetArgPointee<1>(hi);
std::string str;
const char* ptr = nullptr;
a.Perform(make_tuple(true, &str, &ptr));
a.Perform(std::make_tuple(true, &str, &ptr));
EXPECT_EQ("hi", str);
EXPECT_TRUE(ptr == nullptr);
@ -865,7 +865,7 @@ TEST(SetArgPointeeTest, AcceptsCharPointer) {
char* const world = world_array;
a = SetArgPointee<2>(world);
str = "";
a.Perform(make_tuple(true, &str, &ptr));
a.Perform(std::make_tuple(true, &str, &ptr));
EXPECT_EQ("", str);
EXPECT_EQ(world, ptr);
}
@ -875,7 +875,7 @@ TEST(SetArgPointeeTest, AcceptsWideCharPointer) {
const wchar_t* const hi = L"hi";
Action<MyFunction> a = SetArgPointee<1>(hi);
const wchar_t* ptr = nullptr;
a.Perform(make_tuple(true, &ptr));
a.Perform(std::make_tuple(true, &ptr));
EXPECT_EQ(hi, ptr);
# if GTEST_HAS_STD_WSTRING
@ -885,7 +885,7 @@ TEST(SetArgPointeeTest, AcceptsWideCharPointer) {
wchar_t* const world = world_array;
Action<MyStringFunction> a2 = SetArgPointee<1>(world);
std::wstring str;
a2.Perform(make_tuple(true, &str));
a2.Perform(std::make_tuple(true, &str));
EXPECT_EQ(world_array, str);
# endif
}
@ -898,14 +898,14 @@ TEST(SetArgumentPointeeTest, SetsTheNthPointee) {
int n = 0;
char ch = '\0';
a.Perform(make_tuple(true, &n, &ch));
a.Perform(std::make_tuple(true, &n, &ch));
EXPECT_EQ(2, n);
EXPECT_EQ('\0', ch);
a = SetArgumentPointee<2>('a');
n = 0;
ch = '\0';
a.Perform(make_tuple(true, &n, &ch));
a.Perform(std::make_tuple(true, &n, &ch));
EXPECT_EQ(0, n);
EXPECT_EQ('a', ch);
}
@ -940,16 +940,16 @@ class Foo {
TEST(InvokeWithoutArgsTest, Function) {
// As an action that takes one argument.
Action<int(int)> a = InvokeWithoutArgs(Nullary); // NOLINT
EXPECT_EQ(1, a.Perform(make_tuple(2)));
EXPECT_EQ(1, a.Perform(std::make_tuple(2)));
// As an action that takes two arguments.
Action<int(int, double)> a2 = InvokeWithoutArgs(Nullary); // NOLINT
EXPECT_EQ(1, a2.Perform(make_tuple(2, 3.5)));
EXPECT_EQ(1, a2.Perform(std::make_tuple(2, 3.5)));
// As an action that returns void.
Action<void(int)> a3 = InvokeWithoutArgs(VoidNullary); // NOLINT
g_done = false;
a3.Perform(make_tuple(1));
a3.Perform(std::make_tuple(1));
EXPECT_TRUE(g_done);
}
@ -957,17 +957,17 @@ TEST(InvokeWithoutArgsTest, Function) {
TEST(InvokeWithoutArgsTest, Functor) {
// As an action that takes no argument.
Action<int()> a = InvokeWithoutArgs(NullaryFunctor()); // NOLINT
EXPECT_EQ(2, a.Perform(make_tuple()));
EXPECT_EQ(2, a.Perform(std::make_tuple()));
// As an action that takes three arguments.
Action<int(int, double, char)> a2 = // NOLINT
InvokeWithoutArgs(NullaryFunctor());
EXPECT_EQ(2, a2.Perform(make_tuple(3, 3.5, 'a')));
EXPECT_EQ(2, a2.Perform(std::make_tuple(3, 3.5, 'a')));
// As an action that returns void.
Action<void()> a3 = InvokeWithoutArgs(VoidNullaryFunctor());
g_done = false;
a3.Perform(make_tuple());
a3.Perform(std::make_tuple());
EXPECT_TRUE(g_done);
}
@ -976,13 +976,13 @@ TEST(InvokeWithoutArgsTest, Method) {
Foo foo;
Action<int(bool, char)> a = // NOLINT
InvokeWithoutArgs(&foo, &Foo::Nullary);
EXPECT_EQ(123, a.Perform(make_tuple(true, 'a')));
EXPECT_EQ(123, a.Perform(std::make_tuple(true, 'a')));
}
// Tests using IgnoreResult() on a polymorphic action.
TEST(IgnoreResultTest, PolymorphicAction) {
Action<void(int)> a = IgnoreResult(Return(5)); // NOLINT
a.Perform(make_tuple(1));
a.Perform(std::make_tuple(1));
}
// Tests using IgnoreResult() on a monomorphic action.
@ -995,7 +995,7 @@ int ReturnOne() {
TEST(IgnoreResultTest, MonomorphicAction) {
g_done = false;
Action<void()> a = IgnoreResult(Invoke(ReturnOne));
a.Perform(make_tuple());
a.Perform(std::make_tuple());
EXPECT_TRUE(g_done);
}
@ -1010,28 +1010,28 @@ TEST(IgnoreResultTest, ActionReturningClass) {
g_done = false;
Action<void(int)> a =
IgnoreResult(Invoke(ReturnMyNonDefaultConstructible)); // NOLINT
a.Perform(make_tuple(2));
a.Perform(std::make_tuple(2));
EXPECT_TRUE(g_done);
}
TEST(AssignTest, Int) {
int x = 0;
Action<void(int)> a = Assign(&x, 5);
a.Perform(make_tuple(0));
a.Perform(std::make_tuple(0));
EXPECT_EQ(5, x);
}
TEST(AssignTest, String) {
::std::string x;
Action<void(void)> a = Assign(&x, "Hello, world");
a.Perform(make_tuple());
a.Perform(std::make_tuple());
EXPECT_EQ("Hello, world", x);
}
TEST(AssignTest, CompatibleTypes) {
double x = 0;
Action<void(int)> a = Assign(&x, 5);
a.Perform(make_tuple(0));
a.Perform(std::make_tuple(0));
EXPECT_DOUBLE_EQ(5, x);
}
@ -1045,20 +1045,20 @@ class SetErrnoAndReturnTest : public testing::Test {
TEST_F(SetErrnoAndReturnTest, Int) {
Action<int(void)> a = SetErrnoAndReturn(ENOTTY, -5);
EXPECT_EQ(-5, a.Perform(make_tuple()));
EXPECT_EQ(-5, a.Perform(std::make_tuple()));
EXPECT_EQ(ENOTTY, errno);
}
TEST_F(SetErrnoAndReturnTest, Ptr) {
int x;
Action<int*(void)> a = SetErrnoAndReturn(ENOTTY, &x);
EXPECT_EQ(&x, a.Perform(make_tuple()));
EXPECT_EQ(&x, a.Perform(std::make_tuple()));
EXPECT_EQ(ENOTTY, errno);
}
TEST_F(SetErrnoAndReturnTest, CompatibleTypes) {
Action<double()> a = SetErrnoAndReturn(EINVAL, 5);
EXPECT_DOUBLE_EQ(5.0, a.Perform(make_tuple()));
EXPECT_DOUBLE_EQ(5.0, a.Perform(std::make_tuple()));
EXPECT_EQ(EINVAL, errno);
}
@ -1298,47 +1298,47 @@ TEST(FunctorActionTest, ActionFromFunction) {
TEST(FunctorActionTest, ActionFromLambda) {
Action<int(bool, int)> a1 = [](bool b, int i) { return b ? i : 0; };
EXPECT_EQ(5, a1.Perform(make_tuple(true, 5)));
EXPECT_EQ(0, a1.Perform(make_tuple(false, 5)));
EXPECT_EQ(5, a1.Perform(std::make_tuple(true, 5)));
EXPECT_EQ(0, a1.Perform(std::make_tuple(false, 5)));
std::unique_ptr<int> saved;
Action<void(std::unique_ptr<int>)> a2 = [&saved](std::unique_ptr<int> p) {
saved = std::move(p);
};
a2.Perform(make_tuple(UniqueInt(5)));
a2.Perform(std::make_tuple(UniqueInt(5)));
EXPECT_EQ(5, *saved);
}
TEST(FunctorActionTest, PolymorphicFunctor) {
Action<int(int)> ai = Double();
EXPECT_EQ(2, ai.Perform(make_tuple(1)));
EXPECT_EQ(2, ai.Perform(std::make_tuple(1)));
Action<double(double)> ad = Double(); // Double? Double double!
EXPECT_EQ(3.0, ad.Perform(make_tuple(1.5)));
EXPECT_EQ(3.0, ad.Perform(std::make_tuple(1.5)));
}
TEST(FunctorActionTest, TypeConversion) {
// Numeric promotions are allowed.
const Action<bool(int)> a1 = [](int i) { return i > 1; };
const Action<int(bool)> a2 = Action<int(bool)>(a1);
EXPECT_EQ(1, a1.Perform(make_tuple(42)));
EXPECT_EQ(0, a2.Perform(make_tuple(42)));
EXPECT_EQ(1, a1.Perform(std::make_tuple(42)));
EXPECT_EQ(0, a2.Perform(std::make_tuple(42)));
// Implicit constructors are allowed.
const Action<bool(std::string)> s1 = [](std::string s) { return !s.empty(); };
const Action<int(const char*)> s2 = Action<int(const char*)>(s1);
EXPECT_EQ(0, s2.Perform(make_tuple("")));
EXPECT_EQ(1, s2.Perform(make_tuple("hello")));
EXPECT_EQ(0, s2.Perform(std::make_tuple("")));
EXPECT_EQ(1, s2.Perform(std::make_tuple("hello")));
// Also between the lambda and the action itself.
const Action<bool(std::string)> x = [](Unused) { return 42; };
EXPECT_TRUE(x.Perform(make_tuple("hello")));
EXPECT_TRUE(x.Perform(std::make_tuple("hello")));
}
TEST(FunctorActionTest, UnusedArguments) {
// Verify that users can ignore uninteresting arguments.
Action<int(int, double y, double z)> a =
[](int i, Unused, Unused) { return 2 * i; };
tuple<int, double, double> dummy = make_tuple(3, 7.3, 9.44);
std::tuple<int, double, double> dummy = std::make_tuple(3, 7.3, 9.44);
EXPECT_EQ(6, a.Perform(dummy));
}
@ -1349,14 +1349,14 @@ TEST(FunctorActionTest, UnusedArguments) {
// so maybe it's better to make users use lambdas instead.
TEST(MoveOnlyArgumentsTest, ReturningActions) {
Action<int(std::unique_ptr<int>)> a = Return(1);
EXPECT_EQ(1, a.Perform(make_tuple(nullptr)));
EXPECT_EQ(1, a.Perform(std::make_tuple(nullptr)));
a = testing::WithoutArgs([]() { return 7; });
EXPECT_EQ(7, a.Perform(make_tuple(nullptr)));
EXPECT_EQ(7, a.Perform(std::make_tuple(nullptr)));
Action<void(std::unique_ptr<int>, int*)> a2 = testing::SetArgPointee<1>(3);
int x = 0;
a2.Perform(make_tuple(nullptr, &x));
a2.Perform(std::make_tuple(nullptr, &x));
EXPECT_EQ(x, 3);
}

View File

@ -45,10 +45,6 @@ namespace gmock_generated_actions_test {
using ::std::plus;
using ::std::string;
using testing::get;
using testing::make_tuple;
using testing::tuple;
using testing::tuple_element;
using testing::_;
using testing::Action;
using testing::ActionInterface;
@ -168,41 +164,41 @@ inline const char* CharPtr(const char* s) { return s; }
// Tests using InvokeArgument with a nullary function.
TEST(InvokeArgumentTest, Function0) {
Action<int(int, int(*)())> a = InvokeArgument<1>(); // NOLINT
EXPECT_EQ(1, a.Perform(make_tuple(2, &Nullary)));
EXPECT_EQ(1, a.Perform(std::make_tuple(2, &Nullary)));
}
// Tests using InvokeArgument with a unary function.
TEST(InvokeArgumentTest, Functor1) {
Action<int(UnaryFunctor)> a = InvokeArgument<0>(true); // NOLINT
EXPECT_EQ(1, a.Perform(make_tuple(UnaryFunctor())));
EXPECT_EQ(1, a.Perform(std::make_tuple(UnaryFunctor())));
}
// Tests using InvokeArgument with a 5-ary function.
TEST(InvokeArgumentTest, Function5) {
Action<int(int(*)(int, int, int, int, int))> a = // NOLINT
InvokeArgument<0>(10000, 2000, 300, 40, 5);
EXPECT_EQ(12345, a.Perform(make_tuple(&SumOf5)));
EXPECT_EQ(12345, a.Perform(std::make_tuple(&SumOf5)));
}
// Tests using InvokeArgument with a 5-ary functor.
TEST(InvokeArgumentTest, Functor5) {
Action<int(SumOf5Functor)> a = // NOLINT
InvokeArgument<0>(10000, 2000, 300, 40, 5);
EXPECT_EQ(12345, a.Perform(make_tuple(SumOf5Functor())));
EXPECT_EQ(12345, a.Perform(std::make_tuple(SumOf5Functor())));
}
// Tests using InvokeArgument with a 6-ary function.
TEST(InvokeArgumentTest, Function6) {
Action<int(int(*)(int, int, int, int, int, int))> a = // NOLINT
InvokeArgument<0>(100000, 20000, 3000, 400, 50, 6);
EXPECT_EQ(123456, a.Perform(make_tuple(&SumOf6)));
EXPECT_EQ(123456, a.Perform(std::make_tuple(&SumOf6)));
}
// Tests using InvokeArgument with a 6-ary functor.
TEST(InvokeArgumentTest, Functor6) {
Action<int(SumOf6Functor)> a = // NOLINT
InvokeArgument<0>(100000, 20000, 3000, 400, 50, 6);
EXPECT_EQ(123456, a.Perform(make_tuple(SumOf6Functor())));
EXPECT_EQ(123456, a.Perform(std::make_tuple(SumOf6Functor())));
}
// Tests using InvokeArgument with a 7-ary function.
@ -211,7 +207,7 @@ TEST(InvokeArgumentTest, Function7) {
const char*, const char*, const char*,
const char*))>
a = InvokeArgument<0>("1", "2", "3", "4", "5", "6", "7");
EXPECT_EQ("1234567", a.Perform(make_tuple(&Concat7)));
EXPECT_EQ("1234567", a.Perform(std::make_tuple(&Concat7)));
}
// Tests using InvokeArgument with a 8-ary function.
@ -220,7 +216,7 @@ TEST(InvokeArgumentTest, Function8) {
const char*, const char*, const char*,
const char*, const char*))>
a = InvokeArgument<0>("1", "2", "3", "4", "5", "6", "7", "8");
EXPECT_EQ("12345678", a.Perform(make_tuple(&Concat8)));
EXPECT_EQ("12345678", a.Perform(std::make_tuple(&Concat8)));
}
// Tests using InvokeArgument with a 9-ary function.
@ -229,7 +225,7 @@ TEST(InvokeArgumentTest, Function9) {
const char*, const char*, const char*,
const char*, const char*, const char*))>
a = InvokeArgument<0>("1", "2", "3", "4", "5", "6", "7", "8", "9");
EXPECT_EQ("123456789", a.Perform(make_tuple(&Concat9)));
EXPECT_EQ("123456789", a.Perform(std::make_tuple(&Concat9)));
}
// Tests using InvokeArgument with a 10-ary function.
@ -238,14 +234,14 @@ TEST(InvokeArgumentTest, Function10) {
const char*, const char*, const char*, const char*, const char*,
const char*, const char*, const char*, const char*, const char*))>
a = InvokeArgument<0>("1", "2", "3", "4", "5", "6", "7", "8", "9", "0");
EXPECT_EQ("1234567890", a.Perform(make_tuple(&Concat10)));
EXPECT_EQ("1234567890", a.Perform(std::make_tuple(&Concat10)));
}
// Tests using InvokeArgument with a function that takes a pointer argument.
TEST(InvokeArgumentTest, ByPointerFunction) {
Action<const char*(const char*(*)(const char* input, short n))> a = // NOLINT
InvokeArgument<0>(static_cast<const char*>("Hi"), Short(1));
EXPECT_STREQ("i", a.Perform(make_tuple(&Binary)));
EXPECT_STREQ("i", a.Perform(std::make_tuple(&Binary)));
}
// Tests using InvokeArgument with a function that takes a const char*
@ -253,7 +249,7 @@ TEST(InvokeArgumentTest, ByPointerFunction) {
TEST(InvokeArgumentTest, FunctionWithCStringLiteral) {
Action<const char*(const char*(*)(const char* input, short n))> a = // NOLINT
InvokeArgument<0>("Hi", Short(1));
EXPECT_STREQ("i", a.Perform(make_tuple(&Binary)));
EXPECT_STREQ("i", a.Perform(std::make_tuple(&Binary)));
}
// Tests using InvokeArgument with a function that takes a const reference.
@ -263,7 +259,7 @@ TEST(InvokeArgumentTest, ByConstReferenceFunction) {
// When action 'a' is constructed, it makes a copy of the temporary
// string object passed to it, so it's OK to use 'a' later, when the
// temporary object has already died.
EXPECT_TRUE(a.Perform(make_tuple(&ByConstRef)));
EXPECT_TRUE(a.Perform(std::make_tuple(&ByConstRef)));
}
// Tests using InvokeArgument with ByRef() and a function that takes a
@ -272,18 +268,18 @@ TEST(InvokeArgumentTest, ByExplicitConstReferenceFunction) {
Action<bool(bool(*)(const double& x))> a = // NOLINT
InvokeArgument<0>(ByRef(g_double));
// The above line calls ByRef() on a const value.
EXPECT_TRUE(a.Perform(make_tuple(&ReferencesGlobalDouble)));
EXPECT_TRUE(a.Perform(std::make_tuple(&ReferencesGlobalDouble)));
double x = 0;
a = InvokeArgument<0>(ByRef(x)); // This calls ByRef() on a non-const.
EXPECT_FALSE(a.Perform(make_tuple(&ReferencesGlobalDouble)));
EXPECT_FALSE(a.Perform(std::make_tuple(&ReferencesGlobalDouble)));
}
// Tests using WithArgs and with an action that takes 1 argument.
TEST(WithArgsTest, OneArg) {
Action<bool(double x, int n)> a = WithArgs<1>(Invoke(Unary)); // NOLINT
EXPECT_TRUE(a.Perform(make_tuple(1.5, -1)));
EXPECT_FALSE(a.Perform(make_tuple(1.5, 1)));
EXPECT_TRUE(a.Perform(std::make_tuple(1.5, -1)));
EXPECT_FALSE(a.Perform(std::make_tuple(1.5, 1)));
}
// Tests using WithArgs with an action that takes 2 arguments.
@ -291,14 +287,14 @@ TEST(WithArgsTest, TwoArgs) {
Action<const char*(const char* s, double x, short n)> a =
WithArgs<0, 2>(Invoke(Binary));
const char s[] = "Hello";
EXPECT_EQ(s + 2, a.Perform(make_tuple(CharPtr(s), 0.5, Short(2))));
EXPECT_EQ(s + 2, a.Perform(std::make_tuple(CharPtr(s), 0.5, Short(2))));
}
// Tests using WithArgs with an action that takes 3 arguments.
TEST(WithArgsTest, ThreeArgs) {
Action<int(int, double, char, short)> a = // NOLINT
WithArgs<0, 2, 3>(Invoke(Ternary));
EXPECT_EQ(123, a.Perform(make_tuple(100, 6.5, Char(20), Short(3))));
EXPECT_EQ(123, a.Perform(std::make_tuple(100, 6.5, Char(20), Short(3))));
}
// Tests using WithArgs with an action that takes 4 arguments.
@ -306,8 +302,8 @@ TEST(WithArgsTest, FourArgs) {
Action<std::string(const char*, const char*, double, const char*,
const char*)>
a = WithArgs<4, 3, 1, 0>(Invoke(Concat4));
EXPECT_EQ("4310", a.Perform(make_tuple(CharPtr("0"), CharPtr("1"), 2.5,
CharPtr("3"), CharPtr("4"))));
EXPECT_EQ("4310", a.Perform(std::make_tuple(CharPtr("0"), CharPtr("1"), 2.5,
CharPtr("3"), CharPtr("4"))));
}
// Tests using WithArgs with an action that takes 5 arguments.
@ -316,34 +312,32 @@ TEST(WithArgsTest, FiveArgs) {
const char*)>
a = WithArgs<4, 3, 2, 1, 0>(Invoke(Concat5));
EXPECT_EQ("43210",
a.Perform(make_tuple(CharPtr("0"), CharPtr("1"), CharPtr("2"),
CharPtr("3"), CharPtr("4"))));
a.Perform(std::make_tuple(CharPtr("0"), CharPtr("1"), CharPtr("2"),
CharPtr("3"), CharPtr("4"))));
}
// Tests using WithArgs with an action that takes 6 arguments.
TEST(WithArgsTest, SixArgs) {
Action<std::string(const char*, const char*, const char*)> a =
WithArgs<0, 1, 2, 2, 1, 0>(Invoke(Concat6));
EXPECT_EQ("012210",
a.Perform(make_tuple(CharPtr("0"), CharPtr("1"), CharPtr("2"))));
EXPECT_EQ("012210", a.Perform(std::make_tuple(CharPtr("0"), CharPtr("1"),
CharPtr("2"))));
}
// Tests using WithArgs with an action that takes 7 arguments.
TEST(WithArgsTest, SevenArgs) {
Action<std::string(const char*, const char*, const char*, const char*)> a =
WithArgs<0, 1, 2, 3, 2, 1, 0>(Invoke(Concat7));
EXPECT_EQ("0123210",
a.Perform(make_tuple(CharPtr("0"), CharPtr("1"), CharPtr("2"),
CharPtr("3"))));
EXPECT_EQ("0123210", a.Perform(std::make_tuple(CharPtr("0"), CharPtr("1"),
CharPtr("2"), CharPtr("3"))));
}
// Tests using WithArgs with an action that takes 8 arguments.
TEST(WithArgsTest, EightArgs) {
Action<std::string(const char*, const char*, const char*, const char*)> a =
WithArgs<0, 1, 2, 3, 0, 1, 2, 3>(Invoke(Concat8));
EXPECT_EQ("01230123",
a.Perform(make_tuple(CharPtr("0"), CharPtr("1"), CharPtr("2"),
CharPtr("3"))));
EXPECT_EQ("01230123", a.Perform(std::make_tuple(CharPtr("0"), CharPtr("1"),
CharPtr("2"), CharPtr("3"))));
}
// Tests using WithArgs with an action that takes 9 arguments.
@ -351,8 +345,8 @@ TEST(WithArgsTest, NineArgs) {
Action<std::string(const char*, const char*, const char*, const char*)> a =
WithArgs<0, 1, 2, 3, 1, 2, 3, 2, 3>(Invoke(Concat9));
EXPECT_EQ("012312323",
a.Perform(make_tuple(CharPtr("0"), CharPtr("1"), CharPtr("2"),
CharPtr("3"))));
a.Perform(std::make_tuple(CharPtr("0"), CharPtr("1"), CharPtr("2"),
CharPtr("3"))));
}
// Tests using WithArgs with an action that takes 10 arguments.
@ -360,22 +354,23 @@ TEST(WithArgsTest, TenArgs) {
Action<std::string(const char*, const char*, const char*, const char*)> a =
WithArgs<0, 1, 2, 3, 2, 1, 0, 1, 2, 3>(Invoke(Concat10));
EXPECT_EQ("0123210123",
a.Perform(make_tuple(CharPtr("0"), CharPtr("1"), CharPtr("2"),
CharPtr("3"))));
a.Perform(std::make_tuple(CharPtr("0"), CharPtr("1"), CharPtr("2"),
CharPtr("3"))));
}
// Tests using WithArgs with an action that is not Invoke().
class SubstractAction : public ActionInterface<int(int, int)> { // NOLINT
public:
virtual int Perform(const tuple<int, int>& args) {
return get<0>(args) - get<1>(args);
virtual int Perform(const std::tuple<int, int>& args) {
return std::get<0>(args) - std::get<1>(args);
}
};
TEST(WithArgsTest, NonInvokeAction) {
Action<int(const std::string&, int, int)> a = // NOLINT
WithArgs<2, 1>(MakeAction(new SubstractAction));
tuple<std::string, int, int> dummy = make_tuple(std::string("hi"), 2, 10);
std::tuple<std::string, int, int> dummy =
std::make_tuple(std::string("hi"), 2, 10);
EXPECT_EQ(8, a.Perform(dummy));
}
@ -383,14 +378,14 @@ TEST(WithArgsTest, NonInvokeAction) {
TEST(WithArgsTest, Identity) {
Action<int(int x, char y, short z)> a = // NOLINT
WithArgs<0, 1, 2>(Invoke(Ternary));
EXPECT_EQ(123, a.Perform(make_tuple(100, Char(20), Short(3))));
EXPECT_EQ(123, a.Perform(std::make_tuple(100, Char(20), Short(3))));
}
// Tests using WithArgs with repeated arguments.
TEST(WithArgsTest, RepeatedArguments) {
Action<int(bool, int m, int n)> a = // NOLINT
WithArgs<1, 1, 1, 1>(Invoke(SumOf4));
EXPECT_EQ(4, a.Perform(make_tuple(false, 1, 10)));
EXPECT_EQ(4, a.Perform(std::make_tuple(false, 1, 10)));
}
// Tests using WithArgs with reversed argument order.
@ -398,21 +393,22 @@ TEST(WithArgsTest, ReversedArgumentOrder) {
Action<const char*(short n, const char* input)> a = // NOLINT
WithArgs<1, 0>(Invoke(Binary));
const char s[] = "Hello";
EXPECT_EQ(s + 2, a.Perform(make_tuple(Short(2), CharPtr(s))));
EXPECT_EQ(s + 2, a.Perform(std::make_tuple(Short(2), CharPtr(s))));
}
// Tests using WithArgs with compatible, but not identical, argument types.
TEST(WithArgsTest, ArgsOfCompatibleTypes) {
Action<long(short x, char y, double z, char c)> a = // NOLINT
WithArgs<0, 1, 3>(Invoke(Ternary));
EXPECT_EQ(123, a.Perform(make_tuple(Short(100), Char(20), 5.6, Char(3))));
EXPECT_EQ(123,
a.Perform(std::make_tuple(Short(100), Char(20), 5.6, Char(3))));
}
// Tests using WithArgs with an action that returns void.
TEST(WithArgsTest, VoidAction) {
Action<void(double x, char c, int n)> a = WithArgs<2, 1>(Invoke(VoidBinary));
g_done = false;
a.Perform(make_tuple(1.5, 'a', 3));
a.Perform(std::make_tuple(1.5, 'a', 3));
EXPECT_TRUE(g_done);
}
@ -421,7 +417,7 @@ TEST(DoAllTest, TwoActions) {
int n = 0;
Action<int(int*)> a = DoAll(SetArgPointee<0>(1), // NOLINT
Return(2));
EXPECT_EQ(2, a.Perform(make_tuple(&n)));
EXPECT_EQ(2, a.Perform(std::make_tuple(&n)));
EXPECT_EQ(1, n);
}
@ -431,7 +427,7 @@ TEST(DoAllTest, ThreeActions) {
Action<int(int*, int*)> a = DoAll(SetArgPointee<0>(1), // NOLINT
SetArgPointee<1>(2),
Return(3));
EXPECT_EQ(3, a.Perform(make_tuple(&m, &n)));
EXPECT_EQ(3, a.Perform(std::make_tuple(&m, &n)));
EXPECT_EQ(1, m);
EXPECT_EQ(2, n);
}
@ -445,7 +441,7 @@ TEST(DoAllTest, FourActions) {
SetArgPointee<1>(2),
SetArgPointee<2>('a'),
Return(3));
EXPECT_EQ(3, a.Perform(make_tuple(&m, &n, &ch)));
EXPECT_EQ(3, a.Perform(std::make_tuple(&m, &n, &ch)));
EXPECT_EQ(1, m);
EXPECT_EQ(2, n);
EXPECT_EQ('a', ch);
@ -461,7 +457,7 @@ TEST(DoAllTest, FiveActions) {
SetArgPointee<2>('a'),
SetArgPointee<3>('b'),
Return(3));
EXPECT_EQ(3, action.Perform(make_tuple(&m, &n, &a, &b)));
EXPECT_EQ(3, action.Perform(std::make_tuple(&m, &n, &a, &b)));
EXPECT_EQ(1, m);
EXPECT_EQ(2, n);
EXPECT_EQ('a', a);
@ -479,7 +475,7 @@ TEST(DoAllTest, SixActions) {
SetArgPointee<3>('b'),
SetArgPointee<4>('c'),
Return(3));
EXPECT_EQ(3, action.Perform(make_tuple(&m, &n, &a, &b, &c)));
EXPECT_EQ(3, action.Perform(std::make_tuple(&m, &n, &a, &b, &c)));
EXPECT_EQ(1, m);
EXPECT_EQ(2, n);
EXPECT_EQ('a', a);
@ -499,7 +495,7 @@ TEST(DoAllTest, SevenActions) {
SetArgPointee<4>('c'),
SetArgPointee<5>('d'),
Return(3));
EXPECT_EQ(3, action.Perform(make_tuple(&m, &n, &a, &b, &c, &d)));
EXPECT_EQ(3, action.Perform(std::make_tuple(&m, &n, &a, &b, &c, &d)));
EXPECT_EQ(1, m);
EXPECT_EQ(2, n);
EXPECT_EQ('a', a);
@ -522,7 +518,7 @@ TEST(DoAllTest, EightActions) {
SetArgPointee<5>('d'),
SetArgPointee<6>('e'),
Return(3));
EXPECT_EQ(3, action.Perform(make_tuple(&m, &n, &a, &b, &c, &d, &e)));
EXPECT_EQ(3, action.Perform(std::make_tuple(&m, &n, &a, &b, &c, &d, &e)));
EXPECT_EQ(1, m);
EXPECT_EQ(2, n);
EXPECT_EQ('a', a);
@ -547,7 +543,7 @@ TEST(DoAllTest, NineActions) {
SetArgPointee<6>('e'),
SetArgPointee<7>('f'),
Return(3));
EXPECT_EQ(3, action.Perform(make_tuple(&m, &n, &a, &b, &c, &d, &e, &f)));
EXPECT_EQ(3, action.Perform(std::make_tuple(&m, &n, &a, &b, &c, &d, &e, &f)));
EXPECT_EQ(1, m);
EXPECT_EQ(2, n);
EXPECT_EQ('a', a);
@ -575,7 +571,8 @@ TEST(DoAllTest, TenActions) {
SetArgPointee<7>('f'),
SetArgPointee<8>('g'),
Return(3));
EXPECT_EQ(3, action.Perform(make_tuple(&m, &n, &a, &b, &c, &d, &e, &f, &g)));
EXPECT_EQ(
3, action.Perform(std::make_tuple(&m, &n, &a, &b, &c, &d, &e, &f, &g)));
EXPECT_EQ(1, m);
EXPECT_EQ(2, n);
EXPECT_EQ('a', a);
@ -605,10 +602,10 @@ ACTION(Return5) { return 5; }
TEST(ActionMacroTest, WorksWhenNotReferencingArguments) {
Action<double()> a1 = Return5();
EXPECT_DOUBLE_EQ(5, a1.Perform(make_tuple()));
EXPECT_DOUBLE_EQ(5, a1.Perform(std::make_tuple()));
Action<int(double, bool)> a2 = Return5();
EXPECT_EQ(5, a2.Perform(make_tuple(1, true)));
EXPECT_EQ(5, a2.Perform(std::make_tuple(1, true)));
}
// Tests that ACTION() can define an action that returns void.
@ -617,7 +614,7 @@ ACTION(IncrementArg1) { (*arg1)++; }
TEST(ActionMacroTest, WorksWhenReturningVoid) {
Action<void(int, int*)> a1 = IncrementArg1();
int n = 0;
a1.Perform(make_tuple(5, &n));
a1.Perform(std::make_tuple(5, &n));
EXPECT_EQ(1, n);
}
@ -632,22 +629,22 @@ ACTION(IncrementArg2) {
TEST(ActionMacroTest, CanReferenceArgumentType) {
Action<void(int, bool, int*)> a1 = IncrementArg2();
int n = 0;
a1.Perform(make_tuple(5, false, &n));
a1.Perform(std::make_tuple(5, false, &n));
EXPECT_EQ(1, n);
}
// Tests that the body of ACTION() can reference the argument tuple
// via args_type and args.
ACTION(Sum2) {
StaticAssertTypeEq<tuple<int, char, int*>, args_type>();
StaticAssertTypeEq<std::tuple<int, char, int*>, args_type>();
args_type args_copy = args;
return get<0>(args_copy) + get<1>(args_copy);
return std::get<0>(args_copy) + std::get<1>(args_copy);
}
TEST(ActionMacroTest, CanReferenceArgumentTuple) {
Action<int(int, char, int*)> a1 = Sum2();
int dummy = 0;
EXPECT_EQ(11, a1.Perform(make_tuple(5, Char(6), &dummy)));
EXPECT_EQ(11, a1.Perform(std::make_tuple(5, Char(6), &dummy)));
}
// Tests that the body of ACTION() can reference the mock function
@ -662,8 +659,8 @@ ACTION(InvokeDummy) {
TEST(ActionMacroTest, CanReferenceMockFunctionType) {
Action<int(bool)> a1 = InvokeDummy();
EXPECT_EQ(1, a1.Perform(make_tuple(true)));
EXPECT_EQ(1, a1.Perform(make_tuple(false)));
EXPECT_EQ(1, a1.Perform(std::make_tuple(true)));
EXPECT_EQ(1, a1.Perform(std::make_tuple(false)));
}
// Tests that the body of ACTION() can reference the mock function's
@ -676,8 +673,8 @@ ACTION(InvokeDummy2) {
TEST(ActionMacroTest, CanReferenceMockFunctionReturnType) {
Action<int(bool)> a1 = InvokeDummy2();
EXPECT_EQ(1, a1.Perform(make_tuple(true)));
EXPECT_EQ(1, a1.Perform(make_tuple(false)));
EXPECT_EQ(1, a1.Perform(std::make_tuple(true)));
EXPECT_EQ(1, a1.Perform(std::make_tuple(false)));
}
// Tests that ACTION() works for arguments passed by const reference.
@ -689,7 +686,7 @@ ACTION(ReturnAddrOfConstBoolReferenceArg) {
TEST(ActionMacroTest, WorksForConstReferenceArg) {
Action<const bool*(int, const bool&)> a = ReturnAddrOfConstBoolReferenceArg();
const bool b = false;
EXPECT_EQ(&b, a.Perform(tuple<int, const bool&>(0, b)));
EXPECT_EQ(&b, a.Perform(std::tuple<int, const bool&>(0, b)));
}
// Tests that ACTION() works for arguments passed by non-const reference.
@ -701,7 +698,7 @@ ACTION(ReturnAddrOfIntReferenceArg) {
TEST(ActionMacroTest, WorksForNonConstReferenceArg) {
Action<int*(int&, bool, int)> a = ReturnAddrOfIntReferenceArg();
int n = 0;
EXPECT_EQ(&n, a.Perform(tuple<int&, bool, int>(n, true, 1)));
EXPECT_EQ(&n, a.Perform(std::tuple<int&, bool, int>(n, true, 1)));
}
// Tests that ACTION() can be used in a namespace.
@ -711,7 +708,7 @@ ACTION(Sum) { return arg0 + arg1; }
TEST(ActionMacroTest, WorksInNamespace) {
Action<int(int, int)> a1 = action_test::Sum();
EXPECT_EQ(3, a1.Perform(make_tuple(1, 2)));
EXPECT_EQ(3, a1.Perform(std::make_tuple(1, 2)));
}
// Tests that the same ACTION definition works for mock functions with
@ -720,11 +717,11 @@ ACTION(PlusTwo) { return arg0 + 2; }
TEST(ActionMacroTest, WorksForDifferentArgumentNumbers) {
Action<int(int)> a1 = PlusTwo();
EXPECT_EQ(4, a1.Perform(make_tuple(2)));
EXPECT_EQ(4, a1.Perform(std::make_tuple(2)));
Action<double(float, void*)> a2 = PlusTwo();
int dummy;
EXPECT_DOUBLE_EQ(6, a2.Perform(make_tuple(4.0f, &dummy)));
EXPECT_DOUBLE_EQ(6, a2.Perform(std::make_tuple(4.0f, &dummy)));
}
// Tests that ACTION_P can define a parameterized action.
@ -732,7 +729,7 @@ ACTION_P(Plus, n) { return arg0 + n; }
TEST(ActionPMacroTest, DefinesParameterizedAction) {
Action<int(int m, bool t)> a1 = Plus(9);
EXPECT_EQ(10, a1.Perform(make_tuple(1, true)));
EXPECT_EQ(10, a1.Perform(std::make_tuple(1, true)));
}
// Tests that the body of ACTION_P can reference the argument types
@ -745,7 +742,7 @@ ACTION_P(TypedPlus, n) {
TEST(ActionPMacroTest, CanReferenceArgumentAndParameterTypes) {
Action<int(char m, bool t)> a1 = TypedPlus(9);
EXPECT_EQ(10, a1.Perform(make_tuple(Char(1), true)));
EXPECT_EQ(10, a1.Perform(std::make_tuple(Char(1), true)));
}
// Tests that a parameterized action can be used in any mock function
@ -753,7 +750,7 @@ TEST(ActionPMacroTest, CanReferenceArgumentAndParameterTypes) {
TEST(ActionPMacroTest, WorksInCompatibleMockFunction) {
Action<std::string(const std::string& s)> a1 = Plus("tail");
const std::string re = "re";
tuple<const std::string> dummy = make_tuple(re);
std::tuple<const std::string> dummy = std::make_tuple(re);
EXPECT_EQ("retail", a1.Perform(dummy));
}
@ -774,16 +771,16 @@ TEST(ActionMacroTest, CanDefineOverloadedActions) {
typedef Action<const char*(bool, const char*)> MyAction;
const MyAction a1 = OverloadedAction();
EXPECT_STREQ("hello", a1.Perform(make_tuple(false, CharPtr("world"))));
EXPECT_STREQ("world", a1.Perform(make_tuple(true, CharPtr("world"))));
EXPECT_STREQ("hello", a1.Perform(std::make_tuple(false, CharPtr("world"))));
EXPECT_STREQ("world", a1.Perform(std::make_tuple(true, CharPtr("world"))));
const MyAction a2 = OverloadedAction("hi");
EXPECT_STREQ("hi", a2.Perform(make_tuple(false, CharPtr("world"))));
EXPECT_STREQ("world", a2.Perform(make_tuple(true, CharPtr("world"))));
EXPECT_STREQ("hi", a2.Perform(std::make_tuple(false, CharPtr("world"))));
EXPECT_STREQ("world", a2.Perform(std::make_tuple(true, CharPtr("world"))));
const MyAction a3 = OverloadedAction("hi", "you");
EXPECT_STREQ("hi", a3.Perform(make_tuple(true, CharPtr("world"))));
EXPECT_STREQ("you", a3.Perform(make_tuple(false, CharPtr("world"))));
EXPECT_STREQ("hi", a3.Perform(std::make_tuple(true, CharPtr("world"))));
EXPECT_STREQ("you", a3.Perform(std::make_tuple(false, CharPtr("world"))));
}
// Tests ACTION_Pn where n >= 3.
@ -792,11 +789,11 @@ ACTION_P3(Plus, m, n, k) { return arg0 + m + n + k; }
TEST(ActionPnMacroTest, WorksFor3Parameters) {
Action<double(int m, bool t)> a1 = Plus(100, 20, 3.4);
EXPECT_DOUBLE_EQ(3123.4, a1.Perform(make_tuple(3000, true)));
EXPECT_DOUBLE_EQ(3123.4, a1.Perform(std::make_tuple(3000, true)));
Action<std::string(const std::string& s)> a2 = Plus("tail", "-", ">");
const std::string re = "re";
tuple<const std::string> dummy = make_tuple(re);
std::tuple<const std::string> dummy = std::make_tuple(re);
EXPECT_EQ("retail->", a2.Perform(dummy));
}
@ -804,14 +801,14 @@ ACTION_P4(Plus, p0, p1, p2, p3) { return arg0 + p0 + p1 + p2 + p3; }
TEST(ActionPnMacroTest, WorksFor4Parameters) {
Action<int(int)> a1 = Plus(1, 2, 3, 4);
EXPECT_EQ(10 + 1 + 2 + 3 + 4, a1.Perform(make_tuple(10)));
EXPECT_EQ(10 + 1 + 2 + 3 + 4, a1.Perform(std::make_tuple(10)));
}
ACTION_P5(Plus, p0, p1, p2, p3, p4) { return arg0 + p0 + p1 + p2 + p3 + p4; }
TEST(ActionPnMacroTest, WorksFor5Parameters) {
Action<int(int)> a1 = Plus(1, 2, 3, 4, 5);
EXPECT_EQ(10 + 1 + 2 + 3 + 4 + 5, a1.Perform(make_tuple(10)));
EXPECT_EQ(10 + 1 + 2 + 3 + 4 + 5, a1.Perform(std::make_tuple(10)));
}
ACTION_P6(Plus, p0, p1, p2, p3, p4, p5) {
@ -820,7 +817,7 @@ ACTION_P6(Plus, p0, p1, p2, p3, p4, p5) {
TEST(ActionPnMacroTest, WorksFor6Parameters) {
Action<int(int)> a1 = Plus(1, 2, 3, 4, 5, 6);
EXPECT_EQ(10 + 1 + 2 + 3 + 4 + 5 + 6, a1.Perform(make_tuple(10)));
EXPECT_EQ(10 + 1 + 2 + 3 + 4 + 5 + 6, a1.Perform(std::make_tuple(10)));
}
ACTION_P7(Plus, p0, p1, p2, p3, p4, p5, p6) {
@ -829,7 +826,7 @@ ACTION_P7(Plus, p0, p1, p2, p3, p4, p5, p6) {
TEST(ActionPnMacroTest, WorksFor7Parameters) {
Action<int(int)> a1 = Plus(1, 2, 3, 4, 5, 6, 7);
EXPECT_EQ(10 + 1 + 2 + 3 + 4 + 5 + 6 + 7, a1.Perform(make_tuple(10)));
EXPECT_EQ(10 + 1 + 2 + 3 + 4 + 5 + 6 + 7, a1.Perform(std::make_tuple(10)));
}
ACTION_P8(Plus, p0, p1, p2, p3, p4, p5, p6, p7) {
@ -838,7 +835,8 @@ ACTION_P8(Plus, p0, p1, p2, p3, p4, p5, p6, p7) {
TEST(ActionPnMacroTest, WorksFor8Parameters) {
Action<int(int)> a1 = Plus(1, 2, 3, 4, 5, 6, 7, 8);
EXPECT_EQ(10 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8, a1.Perform(make_tuple(10)));
EXPECT_EQ(10 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8,
a1.Perform(std::make_tuple(10)));
}
ACTION_P9(Plus, p0, p1, p2, p3, p4, p5, p6, p7, p8) {
@ -847,7 +845,8 @@ ACTION_P9(Plus, p0, p1, p2, p3, p4, p5, p6, p7, p8) {
TEST(ActionPnMacroTest, WorksFor9Parameters) {
Action<int(int)> a1 = Plus(1, 2, 3, 4, 5, 6, 7, 8, 9);
EXPECT_EQ(10 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9, a1.Perform(make_tuple(10)));
EXPECT_EQ(10 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9,
a1.Perform(std::make_tuple(10)));
}
ACTION_P10(Plus, p0, p1, p2, p3, p4, p5, p6, p7, p8, last_param) {
@ -859,7 +858,7 @@ ACTION_P10(Plus, p0, p1, p2, p3, p4, p5, p6, p7, p8, last_param) {
TEST(ActionPnMacroTest, WorksFor10Parameters) {
Action<int(int)> a1 = Plus(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
EXPECT_EQ(10 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10,
a1.Perform(make_tuple(10)));
a1.Perform(std::make_tuple(10)));
}
// Tests that the action body can promote the parameter types.
@ -876,8 +875,8 @@ TEST(ActionPnMacroTest, SimpleTypePromotion) {
PadArgument(std::string("foo"), 'r');
Action<std::string(const char*)> promo =
PadArgument("foo", static_cast<int>('r'));
EXPECT_EQ("foobar", no_promo.Perform(make_tuple(CharPtr("ba"))));
EXPECT_EQ("foobar", promo.Perform(make_tuple(CharPtr("ba"))));
EXPECT_EQ("foobar", no_promo.Perform(std::make_tuple(CharPtr("ba"))));
EXPECT_EQ("foobar", promo.Perform(std::make_tuple(CharPtr("ba"))));
}
// Tests that we can partially restrict parameter types using a
@ -926,10 +925,10 @@ Concat(T1 a, int b, T2 c) {
TEST(ActionPnMacroTest, CanPartiallyRestrictParameterTypes) {
Action<const std::string()> a1 = Concat("Hello", "1", 2);
EXPECT_EQ("Hello12", a1.Perform(make_tuple()));
EXPECT_EQ("Hello12", a1.Perform(std::make_tuple()));
a1 = Concat(1, 2, 3);
EXPECT_EQ("123", a1.Perform(make_tuple()));
EXPECT_EQ("123", a1.Perform(std::make_tuple()));
}
// Verifies the type of an ACTION*.
@ -987,7 +986,7 @@ ACTION_P10(Plus10, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9) {
TEST(ActionPnMacroTest, CanExplicitlyInstantiateWithReferenceTypes) {
int x = 1, y = 2, z = 3;
const tuple<> empty = make_tuple();
const std::tuple<> empty = std::make_tuple();
Action<int()> a = Plus1<int&>(x);
EXPECT_EQ(1, a.Perform(empty));
@ -1014,7 +1013,7 @@ class NullaryConstructorClass {
// Tests using ReturnNew() with a nullary constructor.
TEST(ReturnNewTest, NoArgs) {
Action<NullaryConstructorClass*()> a = ReturnNew<NullaryConstructorClass>();
NullaryConstructorClass* c = a.Perform(make_tuple());
NullaryConstructorClass* c = a.Perform(std::make_tuple());
EXPECT_EQ(123, c->value_);
delete c;
}
@ -1028,7 +1027,7 @@ class UnaryConstructorClass {
// Tests using ReturnNew() with a unary constructor.
TEST(ReturnNewTest, Unary) {
Action<UnaryConstructorClass*()> a = ReturnNew<UnaryConstructorClass>(4000);
UnaryConstructorClass* c = a.Perform(make_tuple());
UnaryConstructorClass* c = a.Perform(std::make_tuple());
EXPECT_EQ(4000, c->value_);
delete c;
}
@ -1036,7 +1035,7 @@ TEST(ReturnNewTest, Unary) {
TEST(ReturnNewTest, UnaryWorksWhenMockMethodHasArgs) {
Action<UnaryConstructorClass*(bool, int)> a =
ReturnNew<UnaryConstructorClass>(4000);
UnaryConstructorClass* c = a.Perform(make_tuple(false, 5));
UnaryConstructorClass* c = a.Perform(std::make_tuple(false, 5));
EXPECT_EQ(4000, c->value_);
delete c;
}
@ -1044,7 +1043,7 @@ TEST(ReturnNewTest, UnaryWorksWhenMockMethodHasArgs) {
TEST(ReturnNewTest, UnaryWorksWhenMockMethodReturnsPointerToConst) {
Action<const UnaryConstructorClass*()> a =
ReturnNew<UnaryConstructorClass>(4000);
const UnaryConstructorClass* c = a.Perform(make_tuple());
const UnaryConstructorClass* c = a.Perform(std::make_tuple());
EXPECT_EQ(4000, c->value_);
delete c;
}
@ -1064,7 +1063,7 @@ TEST(ReturnNewTest, ConstructorThatTakes10Arguments) {
ReturnNew<TenArgConstructorClass>(1000000000, 200000000, 30000000,
4000000, 500000, 60000,
7000, 800, 90, 0);
TenArgConstructorClass* c = a.Perform(make_tuple());
TenArgConstructorClass* c = a.Perform(std::make_tuple());
EXPECT_EQ(1234567890, c->value_);
delete c;
}
@ -1078,7 +1077,7 @@ ACTION_TEMPLATE(CreateNew,
TEST(ActionTemplateTest, WorksWithoutValueParam) {
const Action<int*()> a = CreateNew<int>();
int* p = a.Perform(make_tuple());
int* p = a.Perform(std::make_tuple());
delete p;
}
@ -1091,7 +1090,7 @@ ACTION_TEMPLATE(CreateNew,
TEST(ActionTemplateTest, WorksWithValueParams) {
const Action<int*()> a = CreateNew<int>(42);
int* p = a.Perform(make_tuple());
int* p = a.Perform(std::make_tuple());
EXPECT_EQ(42, *p);
delete p;
}
@ -1100,7 +1099,7 @@ TEST(ActionTemplateTest, WorksWithValueParams) {
ACTION_TEMPLATE(MyDeleteArg,
HAS_1_TEMPLATE_PARAMS(int, k),
AND_0_VALUE_PARAMS()) {
delete get<k>(args);
delete std::get<k>(args);
}
// Resets a bool variable in the destructor.
@ -1117,7 +1116,7 @@ TEST(ActionTemplateTest, WorksForIntegralTemplateParams) {
int n = 0;
bool b = true;
BoolResetter* resetter = new BoolResetter(&b);
a.Perform(make_tuple(&n, resetter));
a.Perform(std::make_tuple(&n, resetter));
EXPECT_FALSE(b); // Verifies that resetter is deleted.
}
@ -1132,7 +1131,7 @@ ACTION_TEMPLATE(ReturnSmartPointer,
TEST(ActionTemplateTest, WorksForTemplateTemplateParameters) {
using ::testing::internal::linked_ptr;
const Action<linked_ptr<int>()> a = ReturnSmartPointer<linked_ptr>(42);
linked_ptr<int> p = a.Perform(make_tuple());
linked_ptr<int> p = a.Perform(std::make_tuple());
EXPECT_EQ(42, *p);
}
@ -1167,7 +1166,7 @@ TEST(ActionTemplateTest, WorksFor10TemplateParameters) {
true, 6, char, unsigned, int> Giant;
const Action<Giant()> a = ReturnGiant<
int, bool, double, 5, true, 6, char, unsigned, int, linked_ptr>(42);
Giant giant = a.Perform(make_tuple());
Giant giant = a.Perform(std::make_tuple());
EXPECT_EQ(42, giant.value);
}
@ -1180,7 +1179,7 @@ ACTION_TEMPLATE(ReturnSum,
TEST(ActionTemplateTest, WorksFor10ValueParameters) {
const Action<int()> a = ReturnSum<int>(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
EXPECT_EQ(55, a.Perform(make_tuple()));
EXPECT_EQ(55, a.Perform(std::make_tuple()));
}
// Tests that ACTION_TEMPLATE and ACTION/ACTION_P* can be overloaded
@ -1214,11 +1213,11 @@ TEST(ActionTemplateTest, CanBeOverloadedOnNumberOfValueParameters) {
const Action<int()> a2 = ReturnSum<int>(1, 2);
const Action<int()> a3 = ReturnSum<int>(1, 2, 3);
const Action<int()> a4 = ReturnSum<int, 10000>(2000, 300, 40, 5);
EXPECT_EQ(0, a0.Perform(make_tuple()));
EXPECT_EQ(1, a1.Perform(make_tuple()));
EXPECT_EQ(3, a2.Perform(make_tuple()));
EXPECT_EQ(6, a3.Perform(make_tuple()));
EXPECT_EQ(12345, a4.Perform(make_tuple()));
EXPECT_EQ(0, a0.Perform(std::make_tuple()));
EXPECT_EQ(1, a1.Perform(std::make_tuple()));
EXPECT_EQ(3, a2.Perform(std::make_tuple()));
EXPECT_EQ(6, a3.Perform(std::make_tuple()));
EXPECT_EQ(12345, a4.Perform(std::make_tuple()));
}
#ifdef _MSC_VER

View File

@ -38,7 +38,6 @@
namespace {
using ::testing::tuple;
using ::testing::Matcher;
using ::testing::internal::CompileAssertTypesEqual;
using ::testing::internal::MatcherTuple;
@ -48,24 +47,24 @@ using ::testing::internal::IgnoredValue;
// Tests the MatcherTuple template struct.
TEST(MatcherTupleTest, ForSize0) {
CompileAssertTypesEqual<tuple<>, MatcherTuple<tuple<> >::type>();
CompileAssertTypesEqual<std::tuple<>, MatcherTuple<std::tuple<> >::type>();
}
TEST(MatcherTupleTest, ForSize1) {
CompileAssertTypesEqual<tuple<Matcher<int> >,
MatcherTuple<tuple<int> >::type>();
CompileAssertTypesEqual<std::tuple<Matcher<int> >,
MatcherTuple<std::tuple<int> >::type>();
}
TEST(MatcherTupleTest, ForSize2) {
CompileAssertTypesEqual<tuple<Matcher<int>, Matcher<char> >,
MatcherTuple<tuple<int, char> >::type>();
CompileAssertTypesEqual<std::tuple<Matcher<int>, Matcher<char> >,
MatcherTuple<std::tuple<int, char> >::type>();
}
TEST(MatcherTupleTest, ForSize5) {
CompileAssertTypesEqual<
tuple<Matcher<int>, Matcher<char>, Matcher<bool>, Matcher<double>,
Matcher<char*> >,
MatcherTuple<tuple<int, char, bool, double, char*> >::type>();
std::tuple<Matcher<int>, Matcher<char>, Matcher<bool>, Matcher<double>,
Matcher<char*> >,
MatcherTuple<std::tuple<int, char, bool, double, char*> >::type>();
}
// Tests the Function template struct.
@ -73,8 +72,8 @@ TEST(MatcherTupleTest, ForSize5) {
TEST(FunctionTest, Nullary) {
typedef Function<int()> F; // NOLINT
CompileAssertTypesEqual<int, F::Result>();
CompileAssertTypesEqual<tuple<>, F::ArgumentTuple>();
CompileAssertTypesEqual<tuple<>, F::ArgumentMatcherTuple>();
CompileAssertTypesEqual<std::tuple<>, F::ArgumentTuple>();
CompileAssertTypesEqual<std::tuple<>, F::ArgumentMatcherTuple>();
CompileAssertTypesEqual<void(), F::MakeResultVoid>();
CompileAssertTypesEqual<IgnoredValue(), F::MakeResultIgnoredValue>();
}
@ -83,8 +82,9 @@ TEST(FunctionTest, Unary) {
typedef Function<int(bool)> F; // NOLINT
CompileAssertTypesEqual<int, F::Result>();
CompileAssertTypesEqual<bool, F::Argument1>();
CompileAssertTypesEqual<tuple<bool>, F::ArgumentTuple>();
CompileAssertTypesEqual<tuple<Matcher<bool> >, F::ArgumentMatcherTuple>();
CompileAssertTypesEqual<std::tuple<bool>, F::ArgumentTuple>();
CompileAssertTypesEqual<std::tuple<Matcher<bool> >,
F::ArgumentMatcherTuple>();
CompileAssertTypesEqual<void(bool), F::MakeResultVoid>(); // NOLINT
CompileAssertTypesEqual<IgnoredValue(bool), // NOLINT
F::MakeResultIgnoredValue>();
@ -95,9 +95,10 @@ TEST(FunctionTest, Binary) {
CompileAssertTypesEqual<int, F::Result>();
CompileAssertTypesEqual<bool, F::Argument1>();
CompileAssertTypesEqual<const long&, F::Argument2>(); // NOLINT
CompileAssertTypesEqual<tuple<bool, const long&>, F::ArgumentTuple>(); // NOLINT
CompileAssertTypesEqual<std::tuple<bool, const long&>, // NOLINT
F::ArgumentTuple>();
CompileAssertTypesEqual<
tuple<Matcher<bool>, Matcher<const long&> >, // NOLINT
std::tuple<Matcher<bool>, Matcher<const long&> >, // NOLINT
F::ArgumentMatcherTuple>();
CompileAssertTypesEqual<void(bool, const long&), F::MakeResultVoid>(); // NOLINT
CompileAssertTypesEqual<IgnoredValue(bool, const long&), // NOLINT
@ -112,11 +113,12 @@ TEST(FunctionTest, LongArgumentList) {
CompileAssertTypesEqual<char*, F::Argument3>();
CompileAssertTypesEqual<int&, F::Argument4>();
CompileAssertTypesEqual<const long&, F::Argument5>(); // NOLINT
CompileAssertTypesEqual<tuple<bool, int, char*, int&, const long&>, // NOLINT
F::ArgumentTuple>();
CompileAssertTypesEqual<
tuple<Matcher<bool>, Matcher<int>, Matcher<char*>, Matcher<int&>,
Matcher<const long&> >, // NOLINT
std::tuple<bool, int, char*, int&, const long&>, // NOLINT
F::ArgumentTuple>();
CompileAssertTypesEqual<
std::tuple<Matcher<bool>, Matcher<int>, Matcher<char*>, Matcher<int&>,
Matcher<const long&> >, // NOLINT
F::ArgumentMatcherTuple>();
CompileAssertTypesEqual<void(bool, int, char*, int&, const long&), // NOLINT
F::MakeResultVoid>();

View File

@ -62,9 +62,6 @@ using std::pair;
using std::set;
using std::stringstream;
using std::vector;
using testing::get;
using testing::make_tuple;
using testing::tuple;
using testing::_;
using testing::AllOf;
using testing::AnyOf;
@ -118,20 +115,20 @@ std::string Explain(const MatcherType& m, const Value& x) {
// Tests Args<k0, ..., kn>(m).
TEST(ArgsTest, AcceptsZeroTemplateArg) {
const tuple<int, bool> t(5, true);
EXPECT_THAT(t, Args<>(Eq(tuple<>())));
EXPECT_THAT(t, Not(Args<>(Ne(tuple<>()))));
const std::tuple<int, bool> t(5, true);
EXPECT_THAT(t, Args<>(Eq(std::tuple<>())));
EXPECT_THAT(t, Not(Args<>(Ne(std::tuple<>()))));
}
TEST(ArgsTest, AcceptsOneTemplateArg) {
const tuple<int, bool> t(5, true);
EXPECT_THAT(t, Args<0>(Eq(make_tuple(5))));
EXPECT_THAT(t, Args<1>(Eq(make_tuple(true))));
EXPECT_THAT(t, Not(Args<1>(Eq(make_tuple(false)))));
const std::tuple<int, bool> t(5, true);
EXPECT_THAT(t, Args<0>(Eq(std::make_tuple(5))));
EXPECT_THAT(t, Args<1>(Eq(std::make_tuple(true))));
EXPECT_THAT(t, Not(Args<1>(Eq(std::make_tuple(false)))));
}
TEST(ArgsTest, AcceptsTwoTemplateArgs) {
const tuple<short, int, long> t(4, 5, 6L); // NOLINT
const std::tuple<short, int, long> t(4, 5, 6L); // NOLINT
EXPECT_THAT(t, (Args<0, 1>(Lt())));
EXPECT_THAT(t, (Args<1, 2>(Lt())));
@ -139,13 +136,13 @@ TEST(ArgsTest, AcceptsTwoTemplateArgs) {
}
TEST(ArgsTest, AcceptsRepeatedTemplateArgs) {
const tuple<short, int, long> t(4, 5, 6L); // NOLINT
const std::tuple<short, int, long> t(4, 5, 6L); // NOLINT
EXPECT_THAT(t, (Args<0, 0>(Eq())));
EXPECT_THAT(t, Not(Args<1, 1>(Ne())));
}
TEST(ArgsTest, AcceptsDecreasingTemplateArgs) {
const tuple<short, int, long> t(4, 5, 6L); // NOLINT
const std::tuple<short, int, long> t(4, 5, 6L); // NOLINT
EXPECT_THAT(t, (Args<2, 0>(Gt())));
EXPECT_THAT(t, Not(Args<2, 1>(Lt())));
}
@ -161,29 +158,29 @@ TEST(ArgsTest, AcceptsDecreasingTemplateArgs) {
#endif
MATCHER(SumIsZero, "") {
return get<0>(arg) + get<1>(arg) + get<2>(arg) == 0;
return std::get<0>(arg) + std::get<1>(arg) + std::get<2>(arg) == 0;
}
TEST(ArgsTest, AcceptsMoreTemplateArgsThanArityOfOriginalTuple) {
EXPECT_THAT(make_tuple(-1, 2), (Args<0, 0, 1>(SumIsZero())));
EXPECT_THAT(make_tuple(1, 2), Not(Args<0, 0, 1>(SumIsZero())));
EXPECT_THAT(std::make_tuple(-1, 2), (Args<0, 0, 1>(SumIsZero())));
EXPECT_THAT(std::make_tuple(1, 2), Not(Args<0, 0, 1>(SumIsZero())));
}
TEST(ArgsTest, CanBeNested) {
const tuple<short, int, long, int> t(4, 5, 6L, 6); // NOLINT
const std::tuple<short, int, long, int> t(4, 5, 6L, 6); // NOLINT
EXPECT_THAT(t, (Args<1, 2, 3>(Args<1, 2>(Eq()))));
EXPECT_THAT(t, (Args<0, 1, 3>(Args<0, 2>(Lt()))));
}
TEST(ArgsTest, CanMatchTupleByValue) {
typedef tuple<char, int, int> Tuple3;
typedef std::tuple<char, int, int> Tuple3;
const Matcher<Tuple3> m = Args<1, 2>(Lt());
EXPECT_TRUE(m.Matches(Tuple3('a', 1, 2)));
EXPECT_FALSE(m.Matches(Tuple3('b', 2, 2)));
}
TEST(ArgsTest, CanMatchTupleByReference) {
typedef tuple<char, char, int> Tuple3;
typedef std::tuple<char, char, int> Tuple3;
const Matcher<const Tuple3&> m = Args<0, 1>(Lt());
EXPECT_TRUE(m.Matches(Tuple3('a', 'b', 2)));
EXPECT_FALSE(m.Matches(Tuple3('b', 'b', 2)));
@ -195,23 +192,23 @@ MATCHER_P(PrintsAs, str, "") {
}
TEST(ArgsTest, AcceptsTenTemplateArgs) {
EXPECT_THAT(make_tuple(0, 1L, 2, 3L, 4, 5, 6, 7, 8, 9),
EXPECT_THAT(std::make_tuple(0, 1L, 2, 3L, 4, 5, 6, 7, 8, 9),
(Args<9, 8, 7, 6, 5, 4, 3, 2, 1, 0>(
PrintsAs("(9, 8, 7, 6, 5, 4, 3, 2, 1, 0)"))));
EXPECT_THAT(make_tuple(0, 1L, 2, 3L, 4, 5, 6, 7, 8, 9),
EXPECT_THAT(std::make_tuple(0, 1L, 2, 3L, 4, 5, 6, 7, 8, 9),
Not(Args<9, 8, 7, 6, 5, 4, 3, 2, 1, 0>(
PrintsAs("(0, 8, 7, 6, 5, 4, 3, 2, 1, 0)"))));
PrintsAs("(0, 8, 7, 6, 5, 4, 3, 2, 1, 0)"))));
}
TEST(ArgsTest, DescirbesSelfCorrectly) {
const Matcher<tuple<int, bool, char> > m = Args<2, 0>(Lt());
const Matcher<std::tuple<int, bool, char> > m = Args<2, 0>(Lt());
EXPECT_EQ("are a tuple whose fields (#2, #0) are a pair where "
"the first < the second",
Describe(m));
}
TEST(ArgsTest, DescirbesNestedArgsCorrectly) {
const Matcher<const tuple<int, bool, char, int>&> m =
const Matcher<const std::tuple<int, bool, char, int>&> m =
Args<0, 2, 3>(Args<2, 0>(Lt()));
EXPECT_EQ("are a tuple whose fields (#0, #2, #3) are a tuple "
"whose fields (#2, #0) are a pair where the first < the second",
@ -219,28 +216,28 @@ TEST(ArgsTest, DescirbesNestedArgsCorrectly) {
}
TEST(ArgsTest, DescribesNegationCorrectly) {
const Matcher<tuple<int, char> > m = Args<1, 0>(Gt());
const Matcher<std::tuple<int, char> > m = Args<1, 0>(Gt());
EXPECT_EQ("are a tuple whose fields (#1, #0) aren't a pair "
"where the first > the second",
DescribeNegation(m));
}
TEST(ArgsTest, ExplainsMatchResultWithoutInnerExplanation) {
const Matcher<tuple<bool, int, int> > m = Args<1, 2>(Eq());
const Matcher<std::tuple<bool, int, int> > m = Args<1, 2>(Eq());
EXPECT_EQ("whose fields (#1, #2) are (42, 42)",
Explain(m, make_tuple(false, 42, 42)));
Explain(m, std::make_tuple(false, 42, 42)));
EXPECT_EQ("whose fields (#1, #2) are (42, 43)",
Explain(m, make_tuple(false, 42, 43)));
Explain(m, std::make_tuple(false, 42, 43)));
}
// For testing Args<>'s explanation.
class LessThanMatcher : public MatcherInterface<tuple<char, int> > {
class LessThanMatcher : public MatcherInterface<std::tuple<char, int> > {
public:
virtual void DescribeTo(::std::ostream* os) const {}
virtual bool MatchAndExplain(tuple<char, int> value,
virtual bool MatchAndExplain(std::tuple<char, int> value,
MatchResultListener* listener) const {
const int diff = get<0>(value) - get<1>(value);
const int diff = std::get<0>(value) - std::get<1>(value);
if (diff > 0) {
*listener << "where the first value is " << diff
<< " more than the second";
@ -249,17 +246,18 @@ class LessThanMatcher : public MatcherInterface<tuple<char, int> > {
}
};
Matcher<tuple<char, int> > LessThan() {
Matcher<std::tuple<char, int> > LessThan() {
return MakeMatcher(new LessThanMatcher);
}
TEST(ArgsTest, ExplainsMatchResultWithInnerExplanation) {
const Matcher<tuple<char, int, int> > m = Args<0, 2>(LessThan());
EXPECT_EQ("whose fields (#0, #2) are ('a' (97, 0x61), 42), "
"where the first value is 55 more than the second",
Explain(m, make_tuple('a', 42, 42)));
const Matcher<std::tuple<char, int, int> > m = Args<0, 2>(LessThan());
EXPECT_EQ(
"whose fields (#0, #2) are ('a' (97, 0x61), 42), "
"where the first value is 55 more than the second",
Explain(m, std::make_tuple('a', 42, 42)));
EXPECT_EQ("whose fields (#0, #2) are ('\\0', 43)",
Explain(m, make_tuple('\0', 42, 43)));
Explain(m, std::make_tuple('\0', 42, 43)));
}
// For testing ExplainMatchResultTo().
@ -517,7 +515,7 @@ class NativeArrayPassedAsPointerAndSize {
TEST(ElementsAreTest, WorksWithNativeArrayPassedAsPointerAndSize) {
int array[] = { 0, 1 };
::testing::tuple<int*, size_t> array_as_tuple(array, 2);
::std::tuple<int*, size_t> array_as_tuple(array, 2);
EXPECT_THAT(array_as_tuple, ElementsAre(0, 1));
EXPECT_THAT(array_as_tuple, Not(ElementsAre(0)));
@ -571,8 +569,8 @@ TEST(ElementsAreTest, MakesCopyOfArguments) {
int x = 1;
int y = 2;
// This should make a copy of x and y.
::testing::internal::ElementsAreMatcher<testing::tuple<int, int> >
polymorphic_matcher = ElementsAre(x, y);
::testing::internal::ElementsAreMatcher<std::tuple<int, int> >
polymorphic_matcher = ElementsAre(x, y);
// Changing x and y now shouldn't affect the meaning of the above matcher.
x = y = 0;
const int array1[] = { 1, 2 };
@ -1235,8 +1233,8 @@ TEST(ContainsTest, AcceptsMatcher) {
TEST(ContainsTest, WorksForNativeArrayAsTuple) {
const int a[] = { 1, 2 };
const int* const pointer = a;
EXPECT_THAT(make_tuple(pointer, 2), Contains(1));
EXPECT_THAT(make_tuple(pointer, 2), Not(Contains(Gt(3))));
EXPECT_THAT(std::make_tuple(pointer, 2), Contains(1));
EXPECT_THAT(std::make_tuple(pointer, 2), Not(Contains(Gt(3))));
}
TEST(ContainsTest, WorksForTwoDimensionalNativeArray) {

View File

@ -308,26 +308,23 @@ TEST(LosslessArithmeticConvertibleTest, FloatingPointToFloatingPoint) {
// Tests the TupleMatches() template function.
TEST(TupleMatchesTest, WorksForSize0) {
tuple<> matchers;
tuple<> values;
std::tuple<> matchers;
std::tuple<> values;
EXPECT_TRUE(TupleMatches(matchers, values));
}
TEST(TupleMatchesTest, WorksForSize1) {
tuple<Matcher<int> > matchers(Eq(1));
tuple<int> values1(1),
values2(2);
std::tuple<Matcher<int> > matchers(Eq(1));
std::tuple<int> values1(1), values2(2);
EXPECT_TRUE(TupleMatches(matchers, values1));
EXPECT_FALSE(TupleMatches(matchers, values2));
}
TEST(TupleMatchesTest, WorksForSize2) {
tuple<Matcher<int>, Matcher<char> > matchers(Eq(1), Eq('a'));
tuple<int, char> values1(1, 'a'),
values2(1, 'b'),
values3(2, 'a'),
std::tuple<Matcher<int>, Matcher<char> > matchers(Eq(1), Eq('a'));
std::tuple<int, char> values1(1, 'a'), values2(1, 'b'), values3(2, 'a'),
values4(2, 'b');
EXPECT_TRUE(TupleMatches(matchers, values1));
@ -337,10 +334,11 @@ TEST(TupleMatchesTest, WorksForSize2) {
}
TEST(TupleMatchesTest, WorksForSize5) {
tuple<Matcher<int>, Matcher<char>, Matcher<bool>, Matcher<long>, // NOLINT
Matcher<std::string> >
std::tuple<Matcher<int>, Matcher<char>, Matcher<bool>,
Matcher<long>, // NOLINT
Matcher<std::string> >
matchers(Eq(1), Eq('a'), Eq(true), Eq(2L), Eq("hi"));
tuple<int, char, bool, long, std::string> // NOLINT
std::tuple<int, char, bool, long, std::string> // NOLINT
values1(1, 'a', true, 2L, "hi"), values2(1, 'a', true, 2L, "hello"),
values3(2, 'a', true, 2L, "hi");
@ -686,22 +684,25 @@ TEST(StlContainerViewTest, WorksForStaticNativeArray) {
TEST(StlContainerViewTest, WorksForDynamicNativeArray) {
StaticAssertTypeEq<NativeArray<int>,
StlContainerView<tuple<const int*, size_t> >::type>();
StaticAssertTypeEq<NativeArray<double>,
StlContainerView<tuple<linked_ptr<double>, int> >::type>();
StlContainerView<std::tuple<const int*, size_t> >::type>();
StaticAssertTypeEq<
NativeArray<double>,
StlContainerView<std::tuple<linked_ptr<double>, int> >::type>();
StaticAssertTypeEq<const NativeArray<int>,
StlContainerView<tuple<const int*, int> >::const_reference>();
StaticAssertTypeEq<
const NativeArray<int>,
StlContainerView<std::tuple<const int*, int> >::const_reference>();
int a1[3] = { 0, 1, 2 };
const int* const p1 = a1;
NativeArray<int> a2 = StlContainerView<tuple<const int*, int> >::
ConstReference(make_tuple(p1, 3));
NativeArray<int> a2 =
StlContainerView<std::tuple<const int*, int> >::ConstReference(
std::make_tuple(p1, 3));
EXPECT_EQ(3U, a2.size());
EXPECT_EQ(a1, a2.begin());
const NativeArray<int> a3 = StlContainerView<tuple<int*, size_t> >::
Copy(make_tuple(static_cast<int*>(a1), 3));
const NativeArray<int> a3 = StlContainerView<std::tuple<int*, size_t> >::Copy(
std::make_tuple(static_cast<int*>(a1), 3));
ASSERT_EQ(3U, a3.size());
EXPECT_EQ(0, a3.begin()[0]);
EXPECT_EQ(1, a3.begin()[1]);

View File

@ -136,7 +136,6 @@ using testing::Value;
using testing::WhenSorted;
using testing::WhenSortedBy;
using testing::_;
using testing::get;
using testing::internal::DummyMatchResultListener;
using testing::internal::ElementMatcherPair;
using testing::internal::ElementMatcherPairs;
@ -153,8 +152,6 @@ using testing::internal::Strings;
using testing::internal::linked_ptr;
using testing::internal::scoped_ptr;
using testing::internal::string;
using testing::make_tuple;
using testing::tuple;
// For testing ExplainMatchResultTo().
class GreaterThanMatcher : public MatcherInterface<int> {
@ -2239,8 +2236,7 @@ TEST(GlobalWideEndsWithTest, CanDescribeSelf) {
#endif // GTEST_HAS_GLOBAL_WSTRING
typedef ::testing::tuple<long, int> Tuple2; // NOLINT
typedef ::std::tuple<long, int> Tuple2; // NOLINT
// Tests that Eq() matches a 2-tuple where the first field == the
// second field.
@ -2334,7 +2330,7 @@ TEST(Ne2Test, CanDescribeSelf) {
// Tests that FloatEq() matches a 2-tuple where
// FloatEq(first field) matches the second field.
TEST(FloatEq2Test, MatchesEqualArguments) {
typedef ::testing::tuple<float, float> Tpl;
typedef ::std::tuple<float, float> Tpl;
Matcher<const Tpl&> m = FloatEq();
EXPECT_TRUE(m.Matches(Tpl(1.0f, 1.0f)));
EXPECT_TRUE(m.Matches(Tpl(0.3f, 0.1f + 0.1f + 0.1f)));
@ -2343,14 +2339,14 @@ TEST(FloatEq2Test, MatchesEqualArguments) {
// Tests that FloatEq() describes itself properly.
TEST(FloatEq2Test, CanDescribeSelf) {
Matcher<const ::testing::tuple<float, float>&> m = FloatEq();
Matcher<const ::std::tuple<float, float>&> m = FloatEq();
EXPECT_EQ("are an almost-equal pair", Describe(m));
}
// Tests that NanSensitiveFloatEq() matches a 2-tuple where
// NanSensitiveFloatEq(first field) matches the second field.
TEST(NanSensitiveFloatEqTest, MatchesEqualArgumentsWithNaN) {
typedef ::testing::tuple<float, float> Tpl;
typedef ::std::tuple<float, float> Tpl;
Matcher<const Tpl&> m = NanSensitiveFloatEq();
EXPECT_TRUE(m.Matches(Tpl(1.0f, 1.0f)));
EXPECT_TRUE(m.Matches(Tpl(std::numeric_limits<float>::quiet_NaN(),
@ -2362,14 +2358,14 @@ TEST(NanSensitiveFloatEqTest, MatchesEqualArgumentsWithNaN) {
// Tests that NanSensitiveFloatEq() describes itself properly.
TEST(NanSensitiveFloatEqTest, CanDescribeSelfWithNaNs) {
Matcher<const ::testing::tuple<float, float>&> m = NanSensitiveFloatEq();
Matcher<const ::std::tuple<float, float>&> m = NanSensitiveFloatEq();
EXPECT_EQ("are an almost-equal pair", Describe(m));
}
// Tests that DoubleEq() matches a 2-tuple where
// DoubleEq(first field) matches the second field.
TEST(DoubleEq2Test, MatchesEqualArguments) {
typedef ::testing::tuple<double, double> Tpl;
typedef ::std::tuple<double, double> Tpl;
Matcher<const Tpl&> m = DoubleEq();
EXPECT_TRUE(m.Matches(Tpl(1.0, 1.0)));
EXPECT_TRUE(m.Matches(Tpl(0.3, 0.1 + 0.1 + 0.1)));
@ -2378,14 +2374,14 @@ TEST(DoubleEq2Test, MatchesEqualArguments) {
// Tests that DoubleEq() describes itself properly.
TEST(DoubleEq2Test, CanDescribeSelf) {
Matcher<const ::testing::tuple<double, double>&> m = DoubleEq();
Matcher<const ::std::tuple<double, double>&> m = DoubleEq();
EXPECT_EQ("are an almost-equal pair", Describe(m));
}
// Tests that NanSensitiveDoubleEq() matches a 2-tuple where
// NanSensitiveDoubleEq(first field) matches the second field.
TEST(NanSensitiveDoubleEqTest, MatchesEqualArgumentsWithNaN) {
typedef ::testing::tuple<double, double> Tpl;
typedef ::std::tuple<double, double> Tpl;
Matcher<const Tpl&> m = NanSensitiveDoubleEq();
EXPECT_TRUE(m.Matches(Tpl(1.0f, 1.0f)));
EXPECT_TRUE(m.Matches(Tpl(std::numeric_limits<double>::quiet_NaN(),
@ -2397,14 +2393,14 @@ TEST(NanSensitiveDoubleEqTest, MatchesEqualArgumentsWithNaN) {
// Tests that DoubleEq() describes itself properly.
TEST(NanSensitiveDoubleEqTest, CanDescribeSelfWithNaNs) {
Matcher<const ::testing::tuple<double, double>&> m = NanSensitiveDoubleEq();
Matcher<const ::std::tuple<double, double>&> m = NanSensitiveDoubleEq();
EXPECT_EQ("are an almost-equal pair", Describe(m));
}
// Tests that FloatEq() matches a 2-tuple where
// FloatNear(first field, max_abs_error) matches the second field.
TEST(FloatNear2Test, MatchesEqualArguments) {
typedef ::testing::tuple<float, float> Tpl;
typedef ::std::tuple<float, float> Tpl;
Matcher<const Tpl&> m = FloatNear(0.5f);
EXPECT_TRUE(m.Matches(Tpl(1.0f, 1.0f)));
EXPECT_TRUE(m.Matches(Tpl(1.3f, 1.0f)));
@ -2413,14 +2409,14 @@ TEST(FloatNear2Test, MatchesEqualArguments) {
// Tests that FloatNear() describes itself properly.
TEST(FloatNear2Test, CanDescribeSelf) {
Matcher<const ::testing::tuple<float, float>&> m = FloatNear(0.5f);
Matcher<const ::std::tuple<float, float>&> m = FloatNear(0.5f);
EXPECT_EQ("are an almost-equal pair", Describe(m));
}
// Tests that NanSensitiveFloatNear() matches a 2-tuple where
// NanSensitiveFloatNear(first field) matches the second field.
TEST(NanSensitiveFloatNearTest, MatchesNearbyArgumentsWithNaN) {
typedef ::testing::tuple<float, float> Tpl;
typedef ::std::tuple<float, float> Tpl;
Matcher<const Tpl&> m = NanSensitiveFloatNear(0.5f);
EXPECT_TRUE(m.Matches(Tpl(1.0f, 1.0f)));
EXPECT_TRUE(m.Matches(Tpl(1.1f, 1.0f)));
@ -2433,15 +2429,14 @@ TEST(NanSensitiveFloatNearTest, MatchesNearbyArgumentsWithNaN) {
// Tests that NanSensitiveFloatNear() describes itself properly.
TEST(NanSensitiveFloatNearTest, CanDescribeSelfWithNaNs) {
Matcher<const ::testing::tuple<float, float>&> m =
NanSensitiveFloatNear(0.5f);
Matcher<const ::std::tuple<float, float>&> m = NanSensitiveFloatNear(0.5f);
EXPECT_EQ("are an almost-equal pair", Describe(m));
}
// Tests that FloatEq() matches a 2-tuple where
// DoubleNear(first field, max_abs_error) matches the second field.
TEST(DoubleNear2Test, MatchesEqualArguments) {
typedef ::testing::tuple<double, double> Tpl;
typedef ::std::tuple<double, double> Tpl;
Matcher<const Tpl&> m = DoubleNear(0.5);
EXPECT_TRUE(m.Matches(Tpl(1.0, 1.0)));
EXPECT_TRUE(m.Matches(Tpl(1.3, 1.0)));
@ -2450,14 +2445,14 @@ TEST(DoubleNear2Test, MatchesEqualArguments) {
// Tests that DoubleNear() describes itself properly.
TEST(DoubleNear2Test, CanDescribeSelf) {
Matcher<const ::testing::tuple<double, double>&> m = DoubleNear(0.5);
Matcher<const ::std::tuple<double, double>&> m = DoubleNear(0.5);
EXPECT_EQ("are an almost-equal pair", Describe(m));
}
// Tests that NanSensitiveDoubleNear() matches a 2-tuple where
// NanSensitiveDoubleNear(first field) matches the second field.
TEST(NanSensitiveDoubleNearTest, MatchesNearbyArgumentsWithNaN) {
typedef ::testing::tuple<double, double> Tpl;
typedef ::std::tuple<double, double> Tpl;
Matcher<const Tpl&> m = NanSensitiveDoubleNear(0.5f);
EXPECT_TRUE(m.Matches(Tpl(1.0f, 1.0f)));
EXPECT_TRUE(m.Matches(Tpl(1.1f, 1.0f)));
@ -2470,8 +2465,7 @@ TEST(NanSensitiveDoubleNearTest, MatchesNearbyArgumentsWithNaN) {
// Tests that NanSensitiveDoubleNear() describes itself properly.
TEST(NanSensitiveDoubleNearTest, CanDescribeSelfWithNaNs) {
Matcher<const ::testing::tuple<double, double>&> m =
NanSensitiveDoubleNear(0.5f);
Matcher<const ::std::tuple<double, double>&> m = NanSensitiveDoubleNear(0.5f);
EXPECT_EQ("are an almost-equal pair", Describe(m));
}
@ -2796,28 +2790,22 @@ TEST(ElementsAreTest, HugeMatcherUnordered) {
TEST(AnyOfTest, CanDescribeSelf) {
Matcher<int> m;
m = AnyOf(Le(1), Ge(3));
EXPECT_EQ("(is <= 1) or (is >= 3)",
Describe(m));
m = AnyOf(Lt(0), Eq(1), Eq(2));
EXPECT_EQ("(is < 0) or "
"((is equal to 1) or (is equal to 2))",
Describe(m));
EXPECT_EQ("(is < 0) or (is equal to 1) or (is equal to 2)", Describe(m));
m = AnyOf(Lt(0), Eq(1), Eq(2), Eq(3));
EXPECT_EQ("((is < 0) or "
"(is equal to 1)) or "
"((is equal to 2) or "
"(is equal to 3))",
EXPECT_EQ("(is < 0) or (is equal to 1) or (is equal to 2) or (is equal to 3)",
Describe(m));
m = AnyOf(Le(0), Gt(10), 3, 5, 7);
EXPECT_EQ("((is <= 0) or "
"(is > 10)) or "
"((is equal to 3) or "
"((is equal to 5) or "
"(is equal to 7)))",
Describe(m));
EXPECT_EQ(
"(is <= 0) or (is > 10) or (is equal to 3) or (is equal to 5) or (is "
"equal to 7)",
Describe(m));
}
// Tests that AnyOf(m1, ..., mn) describes its negation properly.
@ -2828,24 +2816,20 @@ TEST(AnyOfTest, CanDescribeNegation) {
DescribeNegation(m));
m = AnyOf(Lt(0), Eq(1), Eq(2));
EXPECT_EQ("(isn't < 0) and "
"((isn't equal to 1) and (isn't equal to 2))",
EXPECT_EQ("(isn't < 0) and (isn't equal to 1) and (isn't equal to 2)",
DescribeNegation(m));
m = AnyOf(Lt(0), Eq(1), Eq(2), Eq(3));
EXPECT_EQ("((isn't < 0) and "
"(isn't equal to 1)) and "
"((isn't equal to 2) and "
"(isn't equal to 3))",
DescribeNegation(m));
EXPECT_EQ(
"(isn't < 0) and (isn't equal to 1) and (isn't equal to 2) and (isn't "
"equal to 3)",
DescribeNegation(m));
m = AnyOf(Le(0), Gt(10), 3, 5, 7);
EXPECT_EQ("((isn't <= 0) and "
"(isn't > 10)) and "
"((isn't equal to 3) and "
"((isn't equal to 5) and "
"(isn't equal to 7)))",
DescribeNegation(m));
EXPECT_EQ(
"(isn't <= 0) and (isn't > 10) and (isn't equal to 3) and (isn't equal "
"to 5) and (isn't equal to 7)",
DescribeNegation(m));
}
// Tests that monomorphic matchers are safely cast by the AnyOf matcher.
@ -3081,8 +3065,8 @@ TEST(DescribeMatcherTest, WorksWithPolymorphicMatcher) {
}
TEST(AllArgsTest, WorksForTuple) {
EXPECT_THAT(make_tuple(1, 2L), AllArgs(Lt()));
EXPECT_THAT(make_tuple(2L, 1), Not(AllArgs(Lt())));
EXPECT_THAT(std::make_tuple(1, 2L), AllArgs(Lt()));
EXPECT_THAT(std::make_tuple(2L, 1), Not(AllArgs(Lt())));
}
TEST(AllArgsTest, WorksForNonTuple) {
@ -5060,11 +5044,11 @@ TEST(ContainerEqExtraTest, WorksForNativeArrayAsTuple) {
const int b[] = {1, 2, 3, 4};
const int* const p1 = a1;
EXPECT_THAT(make_tuple(p1, 3), ContainerEq(a2));
EXPECT_THAT(make_tuple(p1, 3), Not(ContainerEq(b)));
EXPECT_THAT(std::make_tuple(p1, 3), ContainerEq(a2));
EXPECT_THAT(std::make_tuple(p1, 3), Not(ContainerEq(b)));
const int c[] = {1, 3, 2};
EXPECT_THAT(make_tuple(p1, 3), Not(ContainerEq(c)));
EXPECT_THAT(std::make_tuple(p1, 3), Not(ContainerEq(c)));
}
TEST(ContainerEqExtraTest, CopiesNativeArrayParameter) {
@ -6246,13 +6230,15 @@ TEST(PolymorphicMatcherTest, CanAccessImpl) {
TEST(MatcherTupleTest, ExplainsMatchFailure) {
stringstream ss1;
ExplainMatchFailureTupleTo(make_tuple(Matcher<char>(Eq('a')), GreaterThan(5)),
make_tuple('a', 10), &ss1);
ExplainMatchFailureTupleTo(
std::make_tuple(Matcher<char>(Eq('a')), GreaterThan(5)),
std::make_tuple('a', 10), &ss1);
EXPECT_EQ("", ss1.str()); // Successful match.
stringstream ss2;
ExplainMatchFailureTupleTo(make_tuple(GreaterThan(5), Matcher<char>(Eq('a'))),
make_tuple(2, 'b'), &ss2);
ExplainMatchFailureTupleTo(
std::make_tuple(GreaterThan(5), Matcher<char>(Eq('a'))),
std::make_tuple(2, 'b'), &ss2);
EXPECT_EQ(" Expected arg #0: is > 5\n"
" Actual: 2, which is 3 less than 5\n"
" Expected arg #1: is equal to 'a' (97, 0x61)\n"
@ -6260,8 +6246,9 @@ TEST(MatcherTupleTest, ExplainsMatchFailure) {
ss2.str()); // Failed match where both arguments need explanation.
stringstream ss3;
ExplainMatchFailureTupleTo(make_tuple(GreaterThan(5), Matcher<char>(Eq('a'))),
make_tuple(2, 'a'), &ss3);
ExplainMatchFailureTupleTo(
std::make_tuple(GreaterThan(5), Matcher<char>(Eq('a'))),
std::make_tuple(2, 'a'), &ss3);
EXPECT_EQ(" Expected arg #0: is > 5\n"
" Actual: 2, which is 3 less than 5\n",
ss3.str()); // Failed match where only one argument needs
@ -6350,21 +6337,21 @@ TEST(EachTest, AcceptsMatcher) {
TEST(EachTest, WorksForNativeArrayAsTuple) {
const int a[] = {1, 2};
const int* const pointer = a;
EXPECT_THAT(make_tuple(pointer, 2), Each(Gt(0)));
EXPECT_THAT(make_tuple(pointer, 2), Not(Each(Gt(1))));
EXPECT_THAT(std::make_tuple(pointer, 2), Each(Gt(0)));
EXPECT_THAT(std::make_tuple(pointer, 2), Not(Each(Gt(1))));
}
// For testing Pointwise().
class IsHalfOfMatcher {
public:
template <typename T1, typename T2>
bool MatchAndExplain(const tuple<T1, T2>& a_pair,
bool MatchAndExplain(const std::tuple<T1, T2>& a_pair,
MatchResultListener* listener) const {
if (get<0>(a_pair) == get<1>(a_pair)/2) {
*listener << "where the second is " << get<1>(a_pair);
if (std::get<0>(a_pair) == std::get<1>(a_pair) / 2) {
*listener << "where the second is " << std::get<1>(a_pair);
return true;
} else {
*listener << "where the second/2 is " << get<1>(a_pair)/2;
*listener << "where the second/2 is " << std::get<1>(a_pair) / 2;
return false;
}
}
@ -6481,13 +6468,13 @@ TEST(PointwiseTest, AcceptsCorrectContent) {
TEST(PointwiseTest, AllowsMonomorphicInnerMatcher) {
const double lhs[3] = {1, 2, 3};
const int rhs[3] = {2, 4, 6};
const Matcher<tuple<const double&, const int&> > m1 = IsHalfOf();
const Matcher<std::tuple<const double&, const int&>> m1 = IsHalfOf();
EXPECT_THAT(lhs, Pointwise(m1, rhs));
EXPECT_EQ("", Explain(Pointwise(m1, rhs), lhs));
// This type works as a tuple<const double&, const int&> can be
// implicitly cast to tuple<double, int>.
const Matcher<tuple<double, int> > m2 = IsHalfOf();
// This type works as a std::tuple<const double&, const int&> can be
// implicitly cast to std::tuple<double, int>.
const Matcher<std::tuple<double, int>> m2 = IsHalfOf();
EXPECT_THAT(lhs, Pointwise(m2, rhs));
EXPECT_EQ("", Explain(Pointwise(m2, rhs), lhs));
}
@ -6597,12 +6584,12 @@ TEST(UnorderedPointwiseTest, AcceptsCorrectContentInDifferentOrder) {
TEST(UnorderedPointwiseTest, AllowsMonomorphicInnerMatcher) {
const double lhs[3] = {1, 2, 3};
const int rhs[3] = {4, 6, 2};
const Matcher<tuple<const double&, const int&> > m1 = IsHalfOf();
const Matcher<std::tuple<const double&, const int&>> m1 = IsHalfOf();
EXPECT_THAT(lhs, UnorderedPointwise(m1, rhs));
// This type works as a tuple<const double&, const int&> can be
// implicitly cast to tuple<double, int>.
const Matcher<tuple<double, int> > m2 = IsHalfOf();
// This type works as a std::tuple<const double&, const int&> can be
// implicitly cast to std::tuple<double, int>.
const Matcher<std::tuple<double, int>> m2 = IsHalfOf();
EXPECT_THAT(lhs, UnorderedPointwise(m2, rhs));
}

View File

@ -46,10 +46,6 @@ namespace gmock_more_actions_test {
using ::std::plus;
using ::std::string;
using testing::get;
using testing::make_tuple;
using testing::tuple;
using testing::tuple_element;
using testing::_;
using testing::Action;
using testing::ActionInterface;
@ -232,45 +228,46 @@ class Foo {
// Tests using Invoke() with a nullary function.
TEST(InvokeTest, Nullary) {
Action<int()> a = Invoke(Nullary); // NOLINT
EXPECT_EQ(1, a.Perform(make_tuple()));
EXPECT_EQ(1, a.Perform(std::make_tuple()));
}
// Tests using Invoke() with a unary function.
TEST(InvokeTest, Unary) {
Action<bool(int)> a = Invoke(Unary); // NOLINT
EXPECT_FALSE(a.Perform(make_tuple(1)));
EXPECT_TRUE(a.Perform(make_tuple(-1)));
EXPECT_FALSE(a.Perform(std::make_tuple(1)));
EXPECT_TRUE(a.Perform(std::make_tuple(-1)));
}
// Tests using Invoke() with a binary function.
TEST(InvokeTest, Binary) {
Action<const char*(const char*, short)> a = Invoke(Binary); // NOLINT
const char* p = "Hello";
EXPECT_EQ(p + 2, a.Perform(make_tuple(p, Short(2))));
EXPECT_EQ(p + 2, a.Perform(std::make_tuple(p, Short(2))));
}
// Tests using Invoke() with a ternary function.
TEST(InvokeTest, Ternary) {
Action<int(int, char, short)> a = Invoke(Ternary); // NOLINT
EXPECT_EQ(6, a.Perform(make_tuple(1, '\2', Short(3))));
EXPECT_EQ(6, a.Perform(std::make_tuple(1, '\2', Short(3))));
}
// Tests using Invoke() with a 4-argument function.
TEST(InvokeTest, FunctionThatTakes4Arguments) {
Action<int(int, int, int, int)> a = Invoke(SumOf4); // NOLINT
EXPECT_EQ(1234, a.Perform(make_tuple(1000, 200, 30, 4)));
EXPECT_EQ(1234, a.Perform(std::make_tuple(1000, 200, 30, 4)));
}
// Tests using Invoke() with a 5-argument function.
TEST(InvokeTest, FunctionThatTakes5Arguments) {
Action<int(int, int, int, int, int)> a = Invoke(SumOf5); // NOLINT
EXPECT_EQ(12345, a.Perform(make_tuple(10000, 2000, 300, 40, 5)));
EXPECT_EQ(12345, a.Perform(std::make_tuple(10000, 2000, 300, 40, 5)));
}
// Tests using Invoke() with a 6-argument function.
TEST(InvokeTest, FunctionThatTakes6Arguments) {
Action<int(int, int, int, int, int, int)> a = Invoke(SumOf6); // NOLINT
EXPECT_EQ(123456, a.Perform(make_tuple(100000, 20000, 3000, 400, 50, 6)));
EXPECT_EQ(123456,
a.Perform(std::make_tuple(100000, 20000, 3000, 400, 50, 6)));
}
// A helper that turns the type of a C-string literal from const
@ -283,9 +280,9 @@ TEST(InvokeTest, FunctionThatTakes7Arguments) {
const char*, const char*, const char*)>
a = Invoke(Concat7);
EXPECT_EQ("1234567",
a.Perform(make_tuple(CharPtr("1"), CharPtr("2"), CharPtr("3"),
CharPtr("4"), CharPtr("5"), CharPtr("6"),
CharPtr("7"))));
a.Perform(std::make_tuple(CharPtr("1"), CharPtr("2"), CharPtr("3"),
CharPtr("4"), CharPtr("5"), CharPtr("6"),
CharPtr("7"))));
}
// Tests using Invoke() with a 8-argument function.
@ -294,9 +291,9 @@ TEST(InvokeTest, FunctionThatTakes8Arguments) {
const char*, const char*, const char*, const char*)>
a = Invoke(Concat8);
EXPECT_EQ("12345678",
a.Perform(make_tuple(CharPtr("1"), CharPtr("2"), CharPtr("3"),
CharPtr("4"), CharPtr("5"), CharPtr("6"),
CharPtr("7"), CharPtr("8"))));
a.Perform(std::make_tuple(CharPtr("1"), CharPtr("2"), CharPtr("3"),
CharPtr("4"), CharPtr("5"), CharPtr("6"),
CharPtr("7"), CharPtr("8"))));
}
// Tests using Invoke() with a 9-argument function.
@ -305,10 +302,10 @@ TEST(InvokeTest, FunctionThatTakes9Arguments) {
const char*, const char*, const char*, const char*,
const char*)>
a = Invoke(Concat9);
EXPECT_EQ("123456789",
a.Perform(make_tuple(CharPtr("1"), CharPtr("2"), CharPtr("3"),
CharPtr("4"), CharPtr("5"), CharPtr("6"),
CharPtr("7"), CharPtr("8"), CharPtr("9"))));
EXPECT_EQ("123456789", a.Perform(std::make_tuple(
CharPtr("1"), CharPtr("2"), CharPtr("3"),
CharPtr("4"), CharPtr("5"), CharPtr("6"),
CharPtr("7"), CharPtr("8"), CharPtr("9"))));
}
// Tests using Invoke() with a 10-argument function.
@ -318,46 +315,46 @@ TEST(InvokeTest, FunctionThatTakes10Arguments) {
const char*, const char*)>
a = Invoke(Concat10);
EXPECT_EQ("1234567890",
a.Perform(make_tuple(CharPtr("1"), CharPtr("2"), CharPtr("3"),
CharPtr("4"), CharPtr("5"), CharPtr("6"),
CharPtr("7"), CharPtr("8"), CharPtr("9"),
CharPtr("0"))));
a.Perform(std::make_tuple(CharPtr("1"), CharPtr("2"), CharPtr("3"),
CharPtr("4"), CharPtr("5"), CharPtr("6"),
CharPtr("7"), CharPtr("8"), CharPtr("9"),
CharPtr("0"))));
}
// Tests using Invoke() with functions with parameters declared as Unused.
TEST(InvokeTest, FunctionWithUnusedParameters) {
Action<int(int, int, double, const std::string&)> a1 = Invoke(SumOfFirst2);
tuple<int, int, double, std::string> dummy =
make_tuple(10, 2, 5.6, std::string("hi"));
std::tuple<int, int, double, std::string> dummy =
std::make_tuple(10, 2, 5.6, std::string("hi"));
EXPECT_EQ(12, a1.Perform(dummy));
Action<int(int, int, bool, int*)> a2 =
Invoke(SumOfFirst2);
EXPECT_EQ(23,
a2.Perform(make_tuple(20, 3, true, static_cast<int*>(nullptr))));
EXPECT_EQ(
23, a2.Perform(std::make_tuple(20, 3, true, static_cast<int*>(nullptr))));
}
// Tests using Invoke() with methods with parameters declared as Unused.
TEST(InvokeTest, MethodWithUnusedParameters) {
Foo foo;
Action<int(std::string, bool, int, int)> a1 = Invoke(&foo, &Foo::SumOfLast2);
EXPECT_EQ(12, a1.Perform(make_tuple(CharPtr("hi"), true, 10, 2)));
EXPECT_EQ(12, a1.Perform(std::make_tuple(CharPtr("hi"), true, 10, 2)));
Action<int(char, double, int, int)> a2 =
Invoke(&foo, &Foo::SumOfLast2);
EXPECT_EQ(23, a2.Perform(make_tuple('a', 2.5, 20, 3)));
EXPECT_EQ(23, a2.Perform(std::make_tuple('a', 2.5, 20, 3)));
}
// Tests using Invoke() with a functor.
TEST(InvokeTest, Functor) {
Action<long(long, int)> a = Invoke(plus<long>()); // NOLINT
EXPECT_EQ(3L, a.Perform(make_tuple(1, 2)));
EXPECT_EQ(3L, a.Perform(std::make_tuple(1, 2)));
}
// Tests using Invoke(f) as an action of a compatible type.
TEST(InvokeTest, FunctionWithCompatibleType) {
Action<long(int, short, char, bool)> a = Invoke(SumOf4); // NOLINT
EXPECT_EQ(4321, a.Perform(make_tuple(4000, Short(300), Char(20), true)));
EXPECT_EQ(4321, a.Perform(std::make_tuple(4000, Short(300), Char(20), true)));
}
// Tests using Invoke() with an object pointer and a method pointer.
@ -366,14 +363,14 @@ TEST(InvokeTest, FunctionWithCompatibleType) {
TEST(InvokeMethodTest, Nullary) {
Foo foo;
Action<int()> a = Invoke(&foo, &Foo::Nullary); // NOLINT
EXPECT_EQ(123, a.Perform(make_tuple()));
EXPECT_EQ(123, a.Perform(std::make_tuple()));
}
// Tests using Invoke() with a unary method.
TEST(InvokeMethodTest, Unary) {
Foo foo;
Action<short(long)> a = Invoke(&foo, &Foo::Unary); // NOLINT
EXPECT_EQ(4123, a.Perform(make_tuple(4000)));
EXPECT_EQ(4123, a.Perform(std::make_tuple(4000)));
}
// Tests using Invoke() with a binary method.
@ -381,7 +378,7 @@ TEST(InvokeMethodTest, Binary) {
Foo foo;
Action<std::string(const std::string&, char)> a = Invoke(&foo, &Foo::Binary);
std::string s("Hell");
tuple<std::string, char> dummy = make_tuple(s, 'o');
std::tuple<std::string, char> dummy = std::make_tuple(s, 'o');
EXPECT_EQ("Hello", a.Perform(dummy));
}
@ -389,21 +386,21 @@ TEST(InvokeMethodTest, Binary) {
TEST(InvokeMethodTest, Ternary) {
Foo foo;
Action<int(int, bool, char)> a = Invoke(&foo, &Foo::Ternary); // NOLINT
EXPECT_EQ(1124, a.Perform(make_tuple(1000, true, Char(1))));
EXPECT_EQ(1124, a.Perform(std::make_tuple(1000, true, Char(1))));
}
// Tests using Invoke() with a 4-argument method.
TEST(InvokeMethodTest, MethodThatTakes4Arguments) {
Foo foo;
Action<int(int, int, int, int)> a = Invoke(&foo, &Foo::SumOf4); // NOLINT
EXPECT_EQ(1357, a.Perform(make_tuple(1000, 200, 30, 4)));
EXPECT_EQ(1357, a.Perform(std::make_tuple(1000, 200, 30, 4)));
}
// Tests using Invoke() with a 5-argument method.
TEST(InvokeMethodTest, MethodThatTakes5Arguments) {
Foo foo;
Action<int(int, int, int, int, int)> a = Invoke(&foo, &Foo::SumOf5); // NOLINT
EXPECT_EQ(12345, a.Perform(make_tuple(10000, 2000, 300, 40, 5)));
EXPECT_EQ(12345, a.Perform(std::make_tuple(10000, 2000, 300, 40, 5)));
}
// Tests using Invoke() with a 6-argument method.
@ -411,7 +408,8 @@ TEST(InvokeMethodTest, MethodThatTakes6Arguments) {
Foo foo;
Action<int(int, int, int, int, int, int)> a = // NOLINT
Invoke(&foo, &Foo::SumOf6);
EXPECT_EQ(123456, a.Perform(make_tuple(100000, 20000, 3000, 400, 50, 6)));
EXPECT_EQ(123456,
a.Perform(std::make_tuple(100000, 20000, 3000, 400, 50, 6)));
}
// Tests using Invoke() with a 7-argument method.
@ -421,9 +419,9 @@ TEST(InvokeMethodTest, MethodThatTakes7Arguments) {
const char*, const char*, const char*)>
a = Invoke(&foo, &Foo::Concat7);
EXPECT_EQ("1234567",
a.Perform(make_tuple(CharPtr("1"), CharPtr("2"), CharPtr("3"),
CharPtr("4"), CharPtr("5"), CharPtr("6"),
CharPtr("7"))));
a.Perform(std::make_tuple(CharPtr("1"), CharPtr("2"), CharPtr("3"),
CharPtr("4"), CharPtr("5"), CharPtr("6"),
CharPtr("7"))));
}
// Tests using Invoke() with a 8-argument method.
@ -433,9 +431,9 @@ TEST(InvokeMethodTest, MethodThatTakes8Arguments) {
const char*, const char*, const char*, const char*)>
a = Invoke(&foo, &Foo::Concat8);
EXPECT_EQ("12345678",
a.Perform(make_tuple(CharPtr("1"), CharPtr("2"), CharPtr("3"),
CharPtr("4"), CharPtr("5"), CharPtr("6"),
CharPtr("7"), CharPtr("8"))));
a.Perform(std::make_tuple(CharPtr("1"), CharPtr("2"), CharPtr("3"),
CharPtr("4"), CharPtr("5"), CharPtr("6"),
CharPtr("7"), CharPtr("8"))));
}
// Tests using Invoke() with a 9-argument method.
@ -445,10 +443,10 @@ TEST(InvokeMethodTest, MethodThatTakes9Arguments) {
const char*, const char*, const char*, const char*,
const char*)>
a = Invoke(&foo, &Foo::Concat9);
EXPECT_EQ("123456789",
a.Perform(make_tuple(CharPtr("1"), CharPtr("2"), CharPtr("3"),
CharPtr("4"), CharPtr("5"), CharPtr("6"),
CharPtr("7"), CharPtr("8"), CharPtr("9"))));
EXPECT_EQ("123456789", a.Perform(std::make_tuple(
CharPtr("1"), CharPtr("2"), CharPtr("3"),
CharPtr("4"), CharPtr("5"), CharPtr("6"),
CharPtr("7"), CharPtr("8"), CharPtr("9"))));
}
// Tests using Invoke() with a 10-argument method.
@ -459,10 +457,10 @@ TEST(InvokeMethodTest, MethodThatTakes10Arguments) {
const char*, const char*)>
a = Invoke(&foo, &Foo::Concat10);
EXPECT_EQ("1234567890",
a.Perform(make_tuple(CharPtr("1"), CharPtr("2"), CharPtr("3"),
CharPtr("4"), CharPtr("5"), CharPtr("6"),
CharPtr("7"), CharPtr("8"), CharPtr("9"),
CharPtr("0"))));
a.Perform(std::make_tuple(CharPtr("1"), CharPtr("2"), CharPtr("3"),
CharPtr("4"), CharPtr("5"), CharPtr("6"),
CharPtr("7"), CharPtr("8"), CharPtr("9"),
CharPtr("0"))));
}
// Tests using Invoke(f) as an action of a compatible type.
@ -470,48 +468,48 @@ TEST(InvokeMethodTest, MethodWithCompatibleType) {
Foo foo;
Action<long(int, short, char, bool)> a = // NOLINT
Invoke(&foo, &Foo::SumOf4);
EXPECT_EQ(4444, a.Perform(make_tuple(4000, Short(300), Char(20), true)));
EXPECT_EQ(4444, a.Perform(std::make_tuple(4000, Short(300), Char(20), true)));
}
// Tests using WithoutArgs with an action that takes no argument.
TEST(WithoutArgsTest, NoArg) {
Action<int(int n)> a = WithoutArgs(Invoke(Nullary)); // NOLINT
EXPECT_EQ(1, a.Perform(make_tuple(2)));
EXPECT_EQ(1, a.Perform(std::make_tuple(2)));
}
// Tests using WithArg with an action that takes 1 argument.
TEST(WithArgTest, OneArg) {
Action<bool(double x, int n)> b = WithArg<1>(Invoke(Unary)); // NOLINT
EXPECT_TRUE(b.Perform(make_tuple(1.5, -1)));
EXPECT_FALSE(b.Perform(make_tuple(1.5, 1)));
EXPECT_TRUE(b.Perform(std::make_tuple(1.5, -1)));
EXPECT_FALSE(b.Perform(std::make_tuple(1.5, 1)));
}
TEST(ReturnArgActionTest, WorksForOneArgIntArg0) {
const Action<int(int)> a = ReturnArg<0>();
EXPECT_EQ(5, a.Perform(make_tuple(5)));
EXPECT_EQ(5, a.Perform(std::make_tuple(5)));
}
TEST(ReturnArgActionTest, WorksForMultiArgBoolArg0) {
const Action<bool(bool, bool, bool)> a = ReturnArg<0>();
EXPECT_TRUE(a.Perform(make_tuple(true, false, false)));
EXPECT_TRUE(a.Perform(std::make_tuple(true, false, false)));
}
TEST(ReturnArgActionTest, WorksForMultiArgStringArg2) {
const Action<std::string(int, int, std::string, int)> a = ReturnArg<2>();
EXPECT_EQ("seven", a.Perform(make_tuple(5, 6, std::string("seven"), 8)));
EXPECT_EQ("seven", a.Perform(std::make_tuple(5, 6, std::string("seven"), 8)));
}
TEST(SaveArgActionTest, WorksForSameType) {
int result = 0;
const Action<void(int n)> a1 = SaveArg<0>(&result);
a1.Perform(make_tuple(5));
a1.Perform(std::make_tuple(5));
EXPECT_EQ(5, result);
}
TEST(SaveArgActionTest, WorksForCompatibleType) {
int result = 0;
const Action<void(bool, char)> a1 = SaveArg<1>(&result);
a1.Perform(make_tuple(true, 'a'));
a1.Perform(std::make_tuple(true, 'a'));
EXPECT_EQ('a', result);
}
@ -519,7 +517,7 @@ TEST(SaveArgPointeeActionTest, WorksForSameType) {
int result = 0;
const int value = 5;
const Action<void(const int*)> a1 = SaveArgPointee<0>(&result);
a1.Perform(make_tuple(&value));
a1.Perform(std::make_tuple(&value));
EXPECT_EQ(5, result);
}
@ -527,7 +525,7 @@ TEST(SaveArgPointeeActionTest, WorksForCompatibleType) {
int result = 0;
char value = 'a';
const Action<void(bool, char*)> a1 = SaveArgPointee<1>(&result);
a1.Perform(make_tuple(true, &value));
a1.Perform(std::make_tuple(true, &value));
EXPECT_EQ('a', result);
}
@ -535,28 +533,28 @@ TEST(SaveArgPointeeActionTest, WorksForLinkedPtr) {
int result = 0;
linked_ptr<int> value(new int(5));
const Action<void(linked_ptr<int>)> a1 = SaveArgPointee<0>(&result);
a1.Perform(make_tuple(value));
a1.Perform(std::make_tuple(value));
EXPECT_EQ(5, result);
}
TEST(SetArgRefereeActionTest, WorksForSameType) {
int value = 0;
const Action<void(int&)> a1 = SetArgReferee<0>(1);
a1.Perform(tuple<int&>(value));
a1.Perform(std::tuple<int&>(value));
EXPECT_EQ(1, value);
}
TEST(SetArgRefereeActionTest, WorksForCompatibleType) {
int value = 0;
const Action<void(int, int&)> a1 = SetArgReferee<1>('a');
a1.Perform(tuple<int, int&>(0, value));
a1.Perform(std::tuple<int, int&>(0, value));
EXPECT_EQ('a', value);
}
TEST(SetArgRefereeActionTest, WorksWithExtraArguments) {
int value = 0;
const Action<void(bool, int, int&, const char*)> a1 = SetArgReferee<2>('a');
a1.Perform(tuple<bool, int, int&, const char*>(true, 0, value, "hi"));
a1.Perform(std::tuple<bool, int, int&, const char*>(true, 0, value, "hi"));
EXPECT_EQ('a', value);
}
@ -583,7 +581,7 @@ TEST(DeleteArgActionTest, OneArg) {
DeletionTester* t = new DeletionTester(&is_deleted);
const Action<void(DeletionTester*)> a1 = DeleteArg<0>(); // NOLINT
EXPECT_FALSE(is_deleted);
a1.Perform(make_tuple(t));
a1.Perform(std::make_tuple(t));
EXPECT_TRUE(is_deleted);
}
@ -593,7 +591,7 @@ TEST(DeleteArgActionTest, TenArgs) {
const Action<void(bool, int, int, const char*, bool,
int, int, int, int, DeletionTester*)> a1 = DeleteArg<9>();
EXPECT_FALSE(is_deleted);
a1.Perform(make_tuple(true, 5, 6, CharPtr("hi"), false, 7, 8, 9, 10, t));
a1.Perform(std::make_tuple(true, 5, 6, CharPtr("hi"), false, 7, 8, 9, 10, t));
EXPECT_TRUE(is_deleted);
}
@ -601,19 +599,19 @@ TEST(DeleteArgActionTest, TenArgs) {
TEST(ThrowActionTest, ThrowsGivenExceptionInVoidFunction) {
const Action<void(int n)> a = Throw('a');
EXPECT_THROW(a.Perform(make_tuple(0)), char);
EXPECT_THROW(a.Perform(std::make_tuple(0)), char);
}
class MyException {};
TEST(ThrowActionTest, ThrowsGivenExceptionInNonVoidFunction) {
const Action<double(char ch)> a = Throw(MyException());
EXPECT_THROW(a.Perform(make_tuple('0')), MyException);
EXPECT_THROW(a.Perform(std::make_tuple('0')), MyException);
}
TEST(ThrowActionTest, ThrowsGivenExceptionInNullaryFunction) {
const Action<double()> a = Throw(MyException());
EXPECT_THROW(a.Perform(make_tuple()), MyException);
EXPECT_THROW(a.Perform(std::make_tuple()), MyException);
}
#endif // GTEST_HAS_EXCEPTIONS
@ -629,7 +627,7 @@ TEST(SetArrayArgumentTest, SetsTheNthArray) {
int* pn = n;
char ch[4] = {};
char* pch = ch;
a.Perform(make_tuple(true, pn, pch));
a.Perform(std::make_tuple(true, pn, pch));
EXPECT_EQ(1, n[0]);
EXPECT_EQ(2, n[1]);
EXPECT_EQ(3, n[2]);
@ -644,7 +642,7 @@ TEST(SetArrayArgumentTest, SetsTheNthArray) {
a = SetArrayArgument<2>(letters.begin(), letters.end());
std::fill_n(n, 4, 0);
std::fill_n(ch, 4, '\0');
a.Perform(make_tuple(true, pn, pch));
a.Perform(std::make_tuple(true, pn, pch));
EXPECT_EQ(0, n[0]);
EXPECT_EQ(0, n[1]);
EXPECT_EQ(0, n[2]);
@ -663,7 +661,7 @@ TEST(SetArrayArgumentTest, SetsTheNthArrayWithEmptyRange) {
int n[4] = {};
int* pn = n;
a.Perform(make_tuple(true, pn));
a.Perform(std::make_tuple(true, pn));
EXPECT_EQ(0, n[0]);
EXPECT_EQ(0, n[1]);
EXPECT_EQ(0, n[2]);
@ -679,7 +677,7 @@ TEST(SetArrayArgumentTest, SetsTheNthArrayWithConvertibleType) {
int codes[4] = { 111, 222, 333, 444 };
int* pcodes = codes;
a.Perform(make_tuple(true, pcodes));
a.Perform(std::make_tuple(true, pcodes));
EXPECT_EQ(97, codes[0]);
EXPECT_EQ(98, codes[1]);
EXPECT_EQ(99, codes[2]);
@ -693,17 +691,17 @@ TEST(SetArrayArgumentTest, SetsTheNthArrayWithIteratorArgument) {
Action<MyFunction> a = SetArrayArgument<1>(letters.begin(), letters.end());
std::string s;
a.Perform(make_tuple(true, back_inserter(s)));
a.Perform(std::make_tuple(true, back_inserter(s)));
EXPECT_EQ(letters, s);
}
TEST(ReturnPointeeTest, Works) {
int n = 42;
const Action<int()> a = ReturnPointee(&n);
EXPECT_EQ(42, a.Perform(make_tuple()));
EXPECT_EQ(42, a.Perform(std::make_tuple()));
n = 43;
EXPECT_EQ(43, a.Perform(make_tuple()));
EXPECT_EQ(43, a.Perform(std::make_tuple()));
}
} // namespace gmock_generated_actions_test

View File

@ -1,157 +0,0 @@
Changes for 1.7.0:
* New feature: death tests are supported on OpenBSD and in iOS
simulator now.
* New feature: Google Test now implements a protocol to allow
a test runner to detect that a test program has exited
prematurely and report it as a failure (before it would be
falsely reported as a success if the exit code is 0).
* New feature: Test::RecordProperty() can now be used outside of the
lifespan of a test method, in which case it will be attributed to
the current test case or the test program in the XML report.
* New feature (potentially breaking): --gtest_list_tests now prints
the type parameters and value parameters for each test.
* Improvement: char pointers and char arrays are now escaped properly
in failure messages.
* Improvement: failure summary in XML reports now includes file and
line information.
* Improvement: the <testsuites> XML element now has a timestamp attribute.
* Improvement: When --gtest_filter is specified, XML report now doesn't
contain information about tests that are filtered out.
* Fixed the bug where long --gtest_filter flag values are truncated in
death tests.
* Potentially breaking change: RUN_ALL_TESTS() is now implemented as a
function instead of a macro in order to work better with Clang.
* Compatibility fixes with C++ 11 and various platforms.
* Bug/warning fixes.
Changes for 1.6.0:
* New feature: ADD_FAILURE_AT() for reporting a test failure at the
given source location -- useful for writing testing utilities.
* New feature: the universal value printer is moved from Google Mock
to Google Test.
* New feature: type parameters and value parameters are reported in
the XML report now.
* A gtest_disable_pthreads CMake option.
* Colored output works in GNU Screen sessions now.
* Parameters of value-parameterized tests are now printed in the
textual output.
* Failures from ad hoc test assertions run before RUN_ALL_TESTS() are
now correctly reported.
* Arguments of ASSERT_XY and EXPECT_XY no longer need to support << to
ostream.
* More complete handling of exceptions.
* GTEST_ASSERT_XY can be used instead of ASSERT_XY in case the latter
name is already used by another library.
* --gtest_catch_exceptions is now true by default, allowing a test
program to continue after an exception is thrown.
* Value-parameterized test fixtures can now derive from Test and
WithParamInterface<T> separately, easing conversion of legacy tests.
* Death test messages are clearly marked to make them more
distinguishable from other messages.
* Compatibility fixes for Android, Google Native Client, MinGW, HP UX,
PowerPC, Lucid autotools, libCStd, Sun C++, Borland C++ Builder (Code Gear),
IBM XL C++ (Visual Age C++), and C++0x.
* Bug fixes and implementation clean-ups.
* Potentially incompatible changes: disables the harmful 'make install'
command in autotools.
Changes for 1.5.0:
* New feature: assertions can be safely called in multiple threads
where the pthreads library is available.
* New feature: predicates used inside EXPECT_TRUE() and friends
can now generate custom failure messages.
* New feature: Google Test can now be compiled as a DLL.
* New feature: fused source files are included.
* New feature: prints help when encountering unrecognized Google Test flags.
* Experimental feature: CMake build script (requires CMake 2.6.4+).
* Experimental feature: the Pump script for meta programming.
* double values streamed to an assertion are printed with enough precision
to differentiate any two different values.
* Google Test now works on Solaris and AIX.
* Build and test script improvements.
* Bug fixes and implementation clean-ups.
Potentially breaking changes:
* Stopped supporting VC++ 7.1 with exceptions disabled.
* Dropped support for 'make install'.
Changes for 1.4.0:
* New feature: the event listener API
* New feature: test shuffling
* New feature: the XML report format is closer to junitreport and can
be parsed by Hudson now.
* New feature: when a test runs under Visual Studio, its failures are
integrated in the IDE.
* New feature: /MD(d) versions of VC++ projects.
* New feature: elapsed time for the tests is printed by default.
* New feature: comes with a TR1 tuple implementation such that Boost
is no longer needed for Combine().
* New feature: EXPECT_DEATH_IF_SUPPORTED macro and friends.
* New feature: the Xcode project can now produce static gtest
libraries in addition to a framework.
* Compatibility fixes for Solaris, Cygwin, minGW, Windows Mobile,
Symbian, gcc, and C++Builder.
* Bug fixes and implementation clean-ups.
Changes for 1.3.0:
* New feature: death tests on Windows, Cygwin, and Mac.
* New feature: ability to use Google Test assertions in other testing
frameworks.
* New feature: ability to run disabled test via
--gtest_also_run_disabled_tests.
* New feature: the --help flag for printing the usage.
* New feature: access to Google Test flag values in user code.
* New feature: a script that packs Google Test into one .h and one
.cc file for easy deployment.
* New feature: support for distributing test functions to multiple
machines (requires support from the test runner).
* Bug fixes and implementation clean-ups.
Changes for 1.2.1:
* Compatibility fixes for Linux IA-64 and IBM z/OS.
* Added support for using Boost and other TR1 implementations.
* Changes to the build scripts to support upcoming release of Google C++
Mocking Framework.
* Added Makefile to the distribution package.
* Improved build instructions in README.
Changes for 1.2.0:
* New feature: value-parameterized tests.
* New feature: the ASSERT/EXPECT_(NON)FATAL_FAILURE(_ON_ALL_THREADS)
macros.
* Changed the XML report format to match JUnit/Ant's.
* Added tests to the Xcode project.
* Added scons/SConscript for building with SCons.
* Added src/gtest-all.cc for building Google Test from a single file.
* Fixed compatibility with Solaris and z/OS.
* Enabled running Python tests on systems with python 2.3 installed,
e.g. Mac OS X 10.4.
* Bug fixes.
Changes for 1.1.0:
* New feature: type-parameterized tests.
* New feature: exception assertions.
* New feature: printing elapsed time of tests.
* Improved the robustness of death tests.
* Added an Xcode project and samples.
* Adjusted the output format on Windows to be understandable by Visual Studio.
* Minor bug fixes.
Changes for 1.0.1:
* Added project files for Visual Studio 7.1.
* Fixed issues with compiling on Mac OS X.
* Fixed issues with compiling on Cygwin.
Changes for 1.0.0:
* Initial Open Source release of Google Test

View File

@ -110,18 +110,6 @@ set(gtest_build_include_dirs
"${gtest_SOURCE_DIR}")
include_directories(${gtest_build_include_dirs})
# Summary of tuple support for Microsoft Visual Studio:
# Compiler version(MS) version(cmake) Support
# ---------- ----------- -------------- -----------------------------
# <= VS 2010 <= 10 <= 1600 Use Google Tests's own tuple.
# VS 2012 11 1700 std::tr1::tuple + _VARIADIC_MAX=10
# VS 2013 12 1800 std::tr1::tuple
# VS 2015 14 1900 std::tuple
# VS 2017 15 >= 1910 std::tuple
if (MSVC AND MSVC_VERSION EQUAL 1700)
add_definitions(/D _VARIADIC_MAX=10)
endif()
########################################################################
#
# Defines the gtest & gtest_main libraries. User tests should link
@ -265,21 +253,6 @@ $env:Path = \"$project_bin;$env:Path\"
PROPERTIES
COMPILE_DEFINITIONS "GTEST_LINKED_AS_SHARED_LIBRARY=1")
if (NOT MSVC OR MSVC_VERSION LESS 1600) # 1600 is Visual Studio 2010.
# Visual Studio 2010, 2012, and 2013 define symbols in std::tr1 that
# conflict with our own definitions. Therefore using our own tuple does not
# work on those compilers.
cxx_library(gtest_main_use_own_tuple "${cxx_use_own_tuple}"
src/gtest-all.cc src/gtest_main.cc)
cxx_test_with_flags(googletest-tuple-test "${cxx_use_own_tuple}"
gtest_main_use_own_tuple test/googletest-tuple-test.cc)
cxx_test_with_flags(gtest_use_own_tuple_test "${cxx_use_own_tuple}"
gtest_main_use_own_tuple
test/googletest-param-test-test.cc test/googletest-param-test2-test.cc)
endif()
############################################################
# Python tests.

View File

@ -9,7 +9,6 @@ EXTRA_DIST = \
LICENSE \
include/gtest/gtest-param-test.h.pump \
include/gtest/internal/gtest-param-util-generated.h.pump \
include/gtest/internal/gtest-tuple.h.pump \
include/gtest/internal/gtest-type-util.h.pump \
make/Makefile \
scripts/fuse_gtest_files.py \
@ -62,7 +61,6 @@ EXTRA_DIST += \
test/gtest_premature_exit_test.cc \
test/gtest-printers_test.cc \
test/gtest-test-part_test.cc \
test/googletest-tuple-test.cc \
test/gtest-typed-test2_test.cc \
test/gtest-typed-test_test.cc \
test/gtest-typed-test_test.h \
@ -208,7 +206,6 @@ pkginclude_internal_HEADERS = \
include/gtest/internal/gtest-port.h \
include/gtest/internal/gtest-port-arch.h \
include/gtest/internal/gtest-string.h \
include/gtest/internal/gtest-tuple.h \
include/gtest/internal/gtest-type-util.h \
include/gtest/internal/custom/gtest.h \
include/gtest/internal/custom/gtest-port.h \

View File

@ -148,7 +148,6 @@ macro(config_compiler_and_linker)
"${CMAKE_CXX_FLAGS} ${cxx_base_flags} ${cxx_no_exception_flags}")
set(cxx_default "${cxx_exception}")
set(cxx_no_rtti "${cxx_default} ${cxx_no_rtti_flags}")
set(cxx_use_own_tuple "${cxx_default} -DGTEST_USE_OWN_TR1_TUPLE=1")
# For building the gtest libraries.
set(cxx_strict "${cxx_default} ${cxx_strict_flags}")

View File

@ -1215,7 +1215,6 @@ inline internal::ParamGenerator<bool> Bool() {
return Values(false, true);
}
# if GTEST_HAS_COMBINE
// Combine() allows the user to combine two or more sequences to produce
// values of a Cartesian product of those sequences' elements.
//
@ -1224,12 +1223,10 @@ inline internal::ParamGenerator<bool> Bool() {
// - returns a generator producing sequences with elements coming from
// the Cartesian product of elements from the sequences generated by
// gen1, gen2, ..., genN. The sequence elements will have a type of
// tuple<T1, T2, ..., TN> where T1, T2, ..., TN are the types
// std::tuple<T1, T2, ..., TN> where T1, T2, ..., TN are the types
// of elements from sequences produces by gen1, gen2, ..., genN.
//
// Combine can have up to 10 arguments. This number is currently limited
// by the maximum number of elements in the tuple implementation used by Google
// Test.
// Combine can have up to 10 arguments.
//
// Example:
//
@ -1239,7 +1236,7 @@ inline internal::ParamGenerator<bool> Bool() {
//
// enum Color { BLACK, GRAY, WHITE };
// class AnimalTest
// : public testing::TestWithParam<tuple<const char*, Color> > {...};
// : public testing::TestWithParam<std::tuple<const char*, Color> > {...};
//
// TEST_P(AnimalTest, AnimalLooksNice) {...}
//
@ -1251,10 +1248,10 @@ inline internal::ParamGenerator<bool> Bool() {
// Boolean flags:
//
// class FlagDependentTest
// : public testing::TestWithParam<tuple<bool, bool> > {
// : public testing::TestWithParam<std::tuple<bool, bool> > {
// virtual void SetUp() {
// // Assigns external_flag_1 and external_flag_2 values from the tuple.
// tie(external_flag_1, external_flag_2) = GetParam();
// std::tie(external_flag_1, external_flag_2) = GetParam();
// }
// };
//
@ -1367,7 +1364,6 @@ internal::CartesianProductHolder10<Generator1, Generator2, Generator3,
Generator10>(
g1, g2, g3, g4, g5, g6, g7, g8, g9, g10);
}
# endif // GTEST_HAS_COMBINE
# define TEST_P(test_case_name, test_name) \
class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) \

View File

@ -372,7 +372,6 @@ inline internal::ParamGenerator<bool> Bool() {
return Values(false, true);
}
# if GTEST_HAS_COMBINE
// Combine() allows the user to combine two or more sequences to produce
// values of a Cartesian product of those sequences' elements.
//
@ -381,12 +380,10 @@ inline internal::ParamGenerator<bool> Bool() {
// - returns a generator producing sequences with elements coming from
// the Cartesian product of elements from the sequences generated by
// gen1, gen2, ..., genN. The sequence elements will have a type of
// tuple<T1, T2, ..., TN> where T1, T2, ..., TN are the types
// std::tuple<T1, T2, ..., TN> where T1, T2, ..., TN are the types
// of elements from sequences produces by gen1, gen2, ..., genN.
//
// Combine can have up to $maxtuple arguments. This number is currently limited
// by the maximum number of elements in the tuple implementation used by Google
// Test.
// Combine can have up to $maxtuple arguments.
//
// Example:
//
@ -396,7 +393,7 @@ inline internal::ParamGenerator<bool> Bool() {
//
// enum Color { BLACK, GRAY, WHITE };
// class AnimalTest
// : public testing::TestWithParam<tuple<const char*, Color> > {...};
// : public testing::TestWithParam<std::tuple<const char*, Color> > {...};
//
// TEST_P(AnimalTest, AnimalLooksNice) {...}
//
@ -408,10 +405,10 @@ inline internal::ParamGenerator<bool> Bool() {
// Boolean flags:
//
// class FlagDependentTest
// : public testing::TestWithParam<tuple<bool, bool> > {
// : public testing::TestWithParam<std::tuple<bool, bool> > {
// virtual void SetUp() {
// // Assigns external_flag_1 and external_flag_2 values from the tuple.
// tie(external_flag_1, external_flag_2) = GetParam();
// std::tie(external_flag_1, external_flag_2) = GetParam();
// }
// };
//
@ -433,7 +430,6 @@ internal::CartesianProductHolder$i<$for j, [[Generator$j]]> Combine(
}
]]
# endif // GTEST_HAS_COMBINE
# define TEST_P(test_case_name, test_name) \
class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) \

View File

@ -104,14 +104,12 @@
#include <ostream> // NOLINT
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <utility>
#include <vector>
#include "gtest/internal/gtest-port.h"
#include "gtest/internal/gtest-internal.h"
#if GTEST_HAS_STD_TUPLE_
# include <tuple>
#endif
#include "gtest/internal/gtest-port.h"
#if GTEST_HAS_ABSL
#include "absl/strings/string_view.h"
@ -643,95 +641,31 @@ void PrintTo(std::reference_wrapper<T> ref, ::std::ostream* os) {
PrintTo(ref.get(), os);
}
#if GTEST_HAS_TR1_TUPLE || GTEST_HAS_STD_TUPLE_
// Helper function for printing a tuple. T must be instantiated with
// a tuple type.
template <typename T>
void PrintTupleTo(const T& t, ::std::ostream* os);
#endif // GTEST_HAS_TR1_TUPLE || GTEST_HAS_STD_TUPLE_
void PrintTupleTo(const T&, std::integral_constant<size_t, 0>,
::std::ostream*) {}
#if GTEST_HAS_TR1_TUPLE
// Overload for ::std::tr1::tuple. Needed for printing function arguments,
// which are packed as tuples.
// Overloaded PrintTo() for tuples of various arities. We support
// tuples of up-to 10 fields. The following implementation works
// regardless of whether tr1::tuple is implemented using the
// non-standard variadic template feature or not.
inline void PrintTo(const ::std::tr1::tuple<>& t, ::std::ostream* os) {
PrintTupleTo(t, os);
template <typename T, size_t I>
void PrintTupleTo(const T& t, std::integral_constant<size_t, I>,
::std::ostream* os) {
PrintTupleTo(t, std::integral_constant<size_t, I - 1>(), os);
GTEST_INTENTIONAL_CONST_COND_PUSH_()
if (I > 1) {
GTEST_INTENTIONAL_CONST_COND_POP_()
*os << ", ";
}
UniversalPrinter<typename std::tuple_element<I - 1, T>::type>::Print(
std::get<I - 1>(t), os);
}
template <typename T1>
void PrintTo(const ::std::tr1::tuple<T1>& t, ::std::ostream* os) {
PrintTupleTo(t, os);
}
template <typename T1, typename T2>
void PrintTo(const ::std::tr1::tuple<T1, T2>& t, ::std::ostream* os) {
PrintTupleTo(t, os);
}
template <typename T1, typename T2, typename T3>
void PrintTo(const ::std::tr1::tuple<T1, T2, T3>& t, ::std::ostream* os) {
PrintTupleTo(t, os);
}
template <typename T1, typename T2, typename T3, typename T4>
void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4>& t, ::std::ostream* os) {
PrintTupleTo(t, os);
}
template <typename T1, typename T2, typename T3, typename T4, typename T5>
void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5>& t,
::std::ostream* os) {
PrintTupleTo(t, os);
}
template <typename T1, typename T2, typename T3, typename T4, typename T5,
typename T6>
void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6>& t,
::std::ostream* os) {
PrintTupleTo(t, os);
}
template <typename T1, typename T2, typename T3, typename T4, typename T5,
typename T6, typename T7>
void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7>& t,
::std::ostream* os) {
PrintTupleTo(t, os);
}
template <typename T1, typename T2, typename T3, typename T4, typename T5,
typename T6, typename T7, typename T8>
void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8>& t,
::std::ostream* os) {
PrintTupleTo(t, os);
}
template <typename T1, typename T2, typename T3, typename T4, typename T5,
typename T6, typename T7, typename T8, typename T9>
void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9>& t,
::std::ostream* os) {
PrintTupleTo(t, os);
}
template <typename T1, typename T2, typename T3, typename T4, typename T5,
typename T6, typename T7, typename T8, typename T9, typename T10>
void PrintTo(
const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>& t,
::std::ostream* os) {
PrintTupleTo(t, os);
}
#endif // GTEST_HAS_TR1_TUPLE
#if GTEST_HAS_STD_TUPLE_
template <typename... Types>
void PrintTo(const ::std::tuple<Types...>& t, ::std::ostream* os) {
PrintTupleTo(t, os);
*os << "(";
PrintTupleTo(t, std::integral_constant<size_t, sizeof...(Types)>(), os);
*os << ")";
}
#endif // GTEST_HAS_STD_TUPLE_
// Overload for std::pair.
template <typename T1, typename T2>
@ -962,109 +896,20 @@ void UniversalPrint(const T& value, ::std::ostream* os) {
typedef ::std::vector< ::std::string> Strings;
// TuplePolicy<TupleT> must provide:
// - tuple_size
// size of tuple TupleT.
// - get<size_t I>(const TupleT& t)
// static function extracting element I of tuple TupleT.
// - tuple_element<size_t I>::type
// type of element I of tuple TupleT.
template <typename TupleT>
struct TuplePolicy;
#if GTEST_HAS_TR1_TUPLE
template <typename TupleT>
struct TuplePolicy {
typedef TupleT Tuple;
static const size_t tuple_size = ::std::tr1::tuple_size<Tuple>::value;
template <size_t I>
struct tuple_element : ::std::tr1::tuple_element<static_cast<int>(I), Tuple> {
};
template <size_t I>
static typename AddReference<const typename ::std::tr1::tuple_element<
static_cast<int>(I), Tuple>::type>::type
get(const Tuple& tuple) {
return ::std::tr1::get<I>(tuple);
}
};
template <typename TupleT>
const size_t TuplePolicy<TupleT>::tuple_size;
#endif // GTEST_HAS_TR1_TUPLE
#if GTEST_HAS_STD_TUPLE_
template <typename... Types>
struct TuplePolicy< ::std::tuple<Types...> > {
typedef ::std::tuple<Types...> Tuple;
static const size_t tuple_size = ::std::tuple_size<Tuple>::value;
template <size_t I>
struct tuple_element : ::std::tuple_element<I, Tuple> {};
template <size_t I>
static const typename ::std::tuple_element<I, Tuple>::type& get(
const Tuple& tuple) {
return ::std::get<I>(tuple);
}
};
template <typename... Types>
const size_t TuplePolicy< ::std::tuple<Types...> >::tuple_size;
#endif // GTEST_HAS_STD_TUPLE_
#if GTEST_HAS_TR1_TUPLE || GTEST_HAS_STD_TUPLE_
// This helper template allows PrintTo() for tuples and
// UniversalTersePrintTupleFieldsToStrings() to be defined by
// induction on the number of tuple fields. The idea is that
// TuplePrefixPrinter<N>::PrintPrefixTo(t, os) prints the first N
// fields in tuple t, and can be defined in terms of
// TuplePrefixPrinter<N - 1>.
//
// The inductive case.
template <size_t N>
struct TuplePrefixPrinter {
// Prints the first N fields of a tuple.
template <typename Tuple>
static void PrintPrefixTo(const Tuple& t, ::std::ostream* os) {
TuplePrefixPrinter<N - 1>::PrintPrefixTo(t, os);
GTEST_INTENTIONAL_CONST_COND_PUSH_()
if (N > 1) {
GTEST_INTENTIONAL_CONST_COND_POP_()
*os << ", ";
}
UniversalPrinter<
typename TuplePolicy<Tuple>::template tuple_element<N - 1>::type>
::Print(TuplePolicy<Tuple>::template get<N - 1>(t), os);
}
// Tersely prints the first N fields of a tuple to a string vector,
// one element for each field.
template <typename Tuple>
static void TersePrintPrefixToStrings(const Tuple& t, Strings* strings) {
TuplePrefixPrinter<N - 1>::TersePrintPrefixToStrings(t, strings);
::std::stringstream ss;
UniversalTersePrint(TuplePolicy<Tuple>::template get<N - 1>(t), &ss);
strings->push_back(ss.str());
}
};
// Base case.
template <>
struct TuplePrefixPrinter<0> {
template <typename Tuple>
static void PrintPrefixTo(const Tuple&, ::std::ostream*) {}
template <typename Tuple>
static void TersePrintPrefixToStrings(const Tuple&, Strings*) {}
};
// Helper function for printing a tuple.
// Tuple must be either std::tr1::tuple or std::tuple type.
template <typename Tuple>
void PrintTupleTo(const Tuple& t, ::std::ostream* os) {
*os << "(";
TuplePrefixPrinter<TuplePolicy<Tuple>::tuple_size>::PrintPrefixTo(t, os);
*os << ")";
void TersePrintPrefixToStrings(const Tuple&, std::integral_constant<size_t, 0>,
Strings*) {}
template <typename Tuple, size_t I>
void TersePrintPrefixToStrings(const Tuple& t,
std::integral_constant<size_t, I>,
Strings* strings) {
TersePrintPrefixToStrings(t, std::integral_constant<size_t, I - 1>(),
strings);
::std::stringstream ss;
UniversalTersePrint(std::get<I - 1>(t), &ss);
strings->push_back(ss.str());
}
// Prints the fields of a tuple tersely to a string vector, one
@ -1073,11 +918,11 @@ void PrintTupleTo(const Tuple& t, ::std::ostream* os) {
template <typename Tuple>
Strings UniversalTersePrintTupleFieldsToStrings(const Tuple& value) {
Strings result;
TuplePrefixPrinter<TuplePolicy<Tuple>::tuple_size>::
TersePrintPrefixToStrings(value, &result);
TersePrintPrefixToStrings(
value, std::integral_constant<size_t, std::tuple_size<Tuple>::value>(),
&result);
return result;
}
#endif // GTEST_HAS_TR1_TUPLE || GTEST_HAS_STD_TUPLE_
} // namespace internal

View File

@ -3560,7 +3560,6 @@ class ValueArray50 {
const T50 v50_;
};
# if GTEST_HAS_COMBINE
// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
//
// Generates values from the Cartesian product of values produced
@ -3568,9 +3567,9 @@ class ValueArray50 {
//
template <typename T1, typename T2>
class CartesianProductGenerator2
: public ParamGeneratorInterface< ::testing::tuple<T1, T2> > {
: public ParamGeneratorInterface< ::std::tuple<T1, T2> > {
public:
typedef ::testing::tuple<T1, T2> ParamType;
typedef ::std::tuple<T1, T2> ParamType;
CartesianProductGenerator2(const ParamGenerator<T1>& g1,
const ParamGenerator<T2>& g2)
@ -3683,9 +3682,9 @@ class CartesianProductGenerator2
template <typename T1, typename T2, typename T3>
class CartesianProductGenerator3
: public ParamGeneratorInterface< ::testing::tuple<T1, T2, T3> > {
: public ParamGeneratorInterface< ::std::tuple<T1, T2, T3> > {
public:
typedef ::testing::tuple<T1, T2, T3> ParamType;
typedef ::std::tuple<T1, T2, T3> ParamType;
CartesianProductGenerator3(const ParamGenerator<T1>& g1,
const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3)
@ -3815,9 +3814,9 @@ class CartesianProductGenerator3
template <typename T1, typename T2, typename T3, typename T4>
class CartesianProductGenerator4
: public ParamGeneratorInterface< ::testing::tuple<T1, T2, T3, T4> > {
: public ParamGeneratorInterface< ::std::tuple<T1, T2, T3, T4> > {
public:
typedef ::testing::tuple<T1, T2, T3, T4> ParamType;
typedef ::std::tuple<T1, T2, T3, T4> ParamType;
CartesianProductGenerator4(const ParamGenerator<T1>& g1,
const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3,
@ -3966,9 +3965,9 @@ class CartesianProductGenerator4
template <typename T1, typename T2, typename T3, typename T4, typename T5>
class CartesianProductGenerator5
: public ParamGeneratorInterface< ::testing::tuple<T1, T2, T3, T4, T5> > {
: public ParamGeneratorInterface< ::std::tuple<T1, T2, T3, T4, T5> > {
public:
typedef ::testing::tuple<T1, T2, T3, T4, T5> ParamType;
typedef ::std::tuple<T1, T2, T3, T4, T5> ParamType;
CartesianProductGenerator5(const ParamGenerator<T1>& g1,
const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3,
@ -4134,10 +4133,9 @@ class CartesianProductGenerator5
template <typename T1, typename T2, typename T3, typename T4, typename T5,
typename T6>
class CartesianProductGenerator6
: public ParamGeneratorInterface< ::testing::tuple<T1, T2, T3, T4, T5,
T6> > {
: public ParamGeneratorInterface< ::std::tuple<T1, T2, T3, T4, T5, T6> > {
public:
typedef ::testing::tuple<T1, T2, T3, T4, T5, T6> ParamType;
typedef ::std::tuple<T1, T2, T3, T4, T5, T6> ParamType;
CartesianProductGenerator6(const ParamGenerator<T1>& g1,
const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3,
@ -4320,10 +4318,10 @@ class CartesianProductGenerator6
template <typename T1, typename T2, typename T3, typename T4, typename T5,
typename T6, typename T7>
class CartesianProductGenerator7
: public ParamGeneratorInterface< ::testing::tuple<T1, T2, T3, T4, T5, T6,
: public ParamGeneratorInterface< ::std::tuple<T1, T2, T3, T4, T5, T6,
T7> > {
public:
typedef ::testing::tuple<T1, T2, T3, T4, T5, T6, T7> ParamType;
typedef ::std::tuple<T1, T2, T3, T4, T5, T6, T7> ParamType;
CartesianProductGenerator7(const ParamGenerator<T1>& g1,
const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3,
@ -4523,10 +4521,10 @@ class CartesianProductGenerator7
template <typename T1, typename T2, typename T3, typename T4, typename T5,
typename T6, typename T7, typename T8>
class CartesianProductGenerator8
: public ParamGeneratorInterface< ::testing::tuple<T1, T2, T3, T4, T5, T6,
T7, T8> > {
: public ParamGeneratorInterface< ::std::tuple<T1, T2, T3, T4, T5, T6, T7,
T8> > {
public:
typedef ::testing::tuple<T1, T2, T3, T4, T5, T6, T7, T8> ParamType;
typedef ::std::tuple<T1, T2, T3, T4, T5, T6, T7, T8> ParamType;
CartesianProductGenerator8(const ParamGenerator<T1>& g1,
const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3,
@ -4745,10 +4743,10 @@ class CartesianProductGenerator8
template <typename T1, typename T2, typename T3, typename T4, typename T5,
typename T6, typename T7, typename T8, typename T9>
class CartesianProductGenerator9
: public ParamGeneratorInterface< ::testing::tuple<T1, T2, T3, T4, T5, T6,
T7, T8, T9> > {
: public ParamGeneratorInterface< ::std::tuple<T1, T2, T3, T4, T5, T6, T7,
T8, T9> > {
public:
typedef ::testing::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9> ParamType;
typedef ::std::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9> ParamType;
CartesianProductGenerator9(const ParamGenerator<T1>& g1,
const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3,
@ -4984,10 +4982,10 @@ class CartesianProductGenerator9
template <typename T1, typename T2, typename T3, typename T4, typename T5,
typename T6, typename T7, typename T8, typename T9, typename T10>
class CartesianProductGenerator10
: public ParamGeneratorInterface< ::testing::tuple<T1, T2, T3, T4, T5, T6,
T7, T8, T9, T10> > {
: public ParamGeneratorInterface< ::std::tuple<T1, T2, T3, T4, T5, T6, T7,
T8, T9, T10> > {
public:
typedef ::testing::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> ParamType;
typedef ::std::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> ParamType;
CartesianProductGenerator10(const ParamGenerator<T1>& g1,
const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3,
@ -5249,8 +5247,8 @@ class CartesianProductHolder2 {
CartesianProductHolder2(const Generator1& g1, const Generator2& g2)
: g1_(g1), g2_(g2) {}
template <typename T1, typename T2>
operator ParamGenerator< ::testing::tuple<T1, T2> >() const {
return ParamGenerator< ::testing::tuple<T1, T2> >(
operator ParamGenerator< ::std::tuple<T1, T2> >() const {
return ParamGenerator< ::std::tuple<T1, T2> >(
new CartesianProductGenerator2<T1, T2>(
static_cast<ParamGenerator<T1> >(g1_),
static_cast<ParamGenerator<T2> >(g2_)));
@ -5271,8 +5269,8 @@ CartesianProductHolder3(const Generator1& g1, const Generator2& g2,
const Generator3& g3)
: g1_(g1), g2_(g2), g3_(g3) {}
template <typename T1, typename T2, typename T3>
operator ParamGenerator< ::testing::tuple<T1, T2, T3> >() const {
return ParamGenerator< ::testing::tuple<T1, T2, T3> >(
operator ParamGenerator< ::std::tuple<T1, T2, T3> >() const {
return ParamGenerator< ::std::tuple<T1, T2, T3> >(
new CartesianProductGenerator3<T1, T2, T3>(
static_cast<ParamGenerator<T1> >(g1_),
static_cast<ParamGenerator<T2> >(g2_),
@ -5296,8 +5294,8 @@ CartesianProductHolder4(const Generator1& g1, const Generator2& g2,
const Generator3& g3, const Generator4& g4)
: g1_(g1), g2_(g2), g3_(g3), g4_(g4) {}
template <typename T1, typename T2, typename T3, typename T4>
operator ParamGenerator< ::testing::tuple<T1, T2, T3, T4> >() const {
return ParamGenerator< ::testing::tuple<T1, T2, T3, T4> >(
operator ParamGenerator< ::std::tuple<T1, T2, T3, T4> >() const {
return ParamGenerator< ::std::tuple<T1, T2, T3, T4> >(
new CartesianProductGenerator4<T1, T2, T3, T4>(
static_cast<ParamGenerator<T1> >(g1_),
static_cast<ParamGenerator<T2> >(g2_),
@ -5323,8 +5321,8 @@ CartesianProductHolder5(const Generator1& g1, const Generator2& g2,
const Generator3& g3, const Generator4& g4, const Generator5& g5)
: g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5) {}
template <typename T1, typename T2, typename T3, typename T4, typename T5>
operator ParamGenerator< ::testing::tuple<T1, T2, T3, T4, T5> >() const {
return ParamGenerator< ::testing::tuple<T1, T2, T3, T4, T5> >(
operator ParamGenerator< ::std::tuple<T1, T2, T3, T4, T5> >() const {
return ParamGenerator< ::std::tuple<T1, T2, T3, T4, T5> >(
new CartesianProductGenerator5<T1, T2, T3, T4, T5>(
static_cast<ParamGenerator<T1> >(g1_),
static_cast<ParamGenerator<T2> >(g2_),
@ -5354,8 +5352,8 @@ CartesianProductHolder6(const Generator1& g1, const Generator2& g2,
: g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6) {}
template <typename T1, typename T2, typename T3, typename T4, typename T5,
typename T6>
operator ParamGenerator< ::testing::tuple<T1, T2, T3, T4, T5, T6> >() const {
return ParamGenerator< ::testing::tuple<T1, T2, T3, T4, T5, T6> >(
operator ParamGenerator< ::std::tuple<T1, T2, T3, T4, T5, T6> >() const {
return ParamGenerator< ::std::tuple<T1, T2, T3, T4, T5, T6> >(
new CartesianProductGenerator6<T1, T2, T3, T4, T5, T6>(
static_cast<ParamGenerator<T1> >(g1_),
static_cast<ParamGenerator<T2> >(g2_),
@ -5387,9 +5385,8 @@ CartesianProductHolder7(const Generator1& g1, const Generator2& g2,
: g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7) {}
template <typename T1, typename T2, typename T3, typename T4, typename T5,
typename T6, typename T7>
operator ParamGenerator< ::testing::tuple<T1, T2, T3, T4, T5, T6,
T7> >() const {
return ParamGenerator< ::testing::tuple<T1, T2, T3, T4, T5, T6, T7> >(
operator ParamGenerator< ::std::tuple<T1, T2, T3, T4, T5, T6, T7> >() const {
return ParamGenerator< ::std::tuple<T1, T2, T3, T4, T5, T6, T7> >(
new CartesianProductGenerator7<T1, T2, T3, T4, T5, T6, T7>(
static_cast<ParamGenerator<T1> >(g1_),
static_cast<ParamGenerator<T2> >(g2_),
@ -5425,9 +5422,9 @@ CartesianProductHolder8(const Generator1& g1, const Generator2& g2,
g8_(g8) {}
template <typename T1, typename T2, typename T3, typename T4, typename T5,
typename T6, typename T7, typename T8>
operator ParamGenerator< ::testing::tuple<T1, T2, T3, T4, T5, T6, T7,
operator ParamGenerator< ::std::tuple<T1, T2, T3, T4, T5, T6, T7,
T8> >() const {
return ParamGenerator< ::testing::tuple<T1, T2, T3, T4, T5, T6, T7, T8> >(
return ParamGenerator< ::std::tuple<T1, T2, T3, T4, T5, T6, T7, T8> >(
new CartesianProductGenerator8<T1, T2, T3, T4, T5, T6, T7, T8>(
static_cast<ParamGenerator<T1> >(g1_),
static_cast<ParamGenerator<T2> >(g2_),
@ -5466,10 +5463,9 @@ CartesianProductHolder9(const Generator1& g1, const Generator2& g2,
g9_(g9) {}
template <typename T1, typename T2, typename T3, typename T4, typename T5,
typename T6, typename T7, typename T8, typename T9>
operator ParamGenerator< ::testing::tuple<T1, T2, T3, T4, T5, T6, T7, T8,
operator ParamGenerator< ::std::tuple<T1, T2, T3, T4, T5, T6, T7, T8,
T9> >() const {
return ParamGenerator< ::testing::tuple<T1, T2, T3, T4, T5, T6, T7, T8,
T9> >(
return ParamGenerator< ::std::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9> >(
new CartesianProductGenerator9<T1, T2, T3, T4, T5, T6, T7, T8, T9>(
static_cast<ParamGenerator<T1> >(g1_),
static_cast<ParamGenerator<T2> >(g2_),
@ -5510,9 +5506,9 @@ CartesianProductHolder10(const Generator1& g1, const Generator2& g2,
g9_(g9), g10_(g10) {}
template <typename T1, typename T2, typename T3, typename T4, typename T5,
typename T6, typename T7, typename T8, typename T9, typename T10>
operator ParamGenerator< ::testing::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9,
operator ParamGenerator< ::std::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9,
T10> >() const {
return ParamGenerator< ::testing::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9,
return ParamGenerator< ::std::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9,
T10> >(
new CartesianProductGenerator10<T1, T2, T3, T4, T5, T6, T7, T8, T9,
T10>(
@ -5544,8 +5540,6 @@ CartesianProductHolder10(const Generator1& g1, const Generator2& g2,
const Generator10 g10_;
}; // class CartesianProductHolder10
# endif // GTEST_HAS_COMBINE
} // namespace internal
} // namespace testing

View File

@ -98,7 +98,6 @@ $for j [[
]]
# if GTEST_HAS_COMBINE
// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
//
// Generates values from the Cartesian product of values produced
@ -111,9 +110,9 @@ $range k 2..i
template <$for j, [[typename T$j]]>
class CartesianProductGenerator$i
: public ParamGeneratorInterface< ::testing::tuple<$for j, [[T$j]]> > {
: public ParamGeneratorInterface< ::std::tuple<$for j, [[T$j]]> > {
public:
typedef ::testing::tuple<$for j, [[T$j]]> ParamType;
typedef ::std::tuple<$for j, [[T$j]]> ParamType;
CartesianProductGenerator$i($for j, [[const ParamGenerator<T$j>& g$j]])
: $for j, [[g$(j)_(g$j)]] {}
@ -252,8 +251,8 @@ class CartesianProductHolder$i {
CartesianProductHolder$i($for j, [[const Generator$j& g$j]])
: $for j, [[g$(j)_(g$j)]] {}
template <$for j, [[typename T$j]]>
operator ParamGenerator< ::testing::tuple<$for j, [[T$j]]> >() const {
return ParamGenerator< ::testing::tuple<$for j, [[T$j]]> >(
operator ParamGenerator< ::std::tuple<$for j, [[T$j]]> >() const {
return ParamGenerator< ::std::tuple<$for j, [[T$j]]> >(
new CartesianProductGenerator$i<$for j, [[T$j]]>(
$for j,[[
@ -274,8 +273,6 @@ $for j [[
]]
# endif // GTEST_HAS_COMBINE
} // namespace internal
} // namespace testing

View File

@ -85,8 +85,6 @@
// GTEST_HAS_STD_WSTRING - Define it to 1/0 to indicate that
// std::wstring does/doesn't work (Google Test can
// be used where std::wstring is unavailable).
// GTEST_HAS_TR1_TUPLE - Define it to 1/0 to indicate tr1::tuple
// is/isn't available.
// GTEST_HAS_SEH - Define it to 1/0 to indicate whether the
// compiler supports Microsoft's "Structured
// Exception Handling".
@ -94,10 +92,6 @@
// - Define it to 1/0 to indicate whether the
// platform supports I/O stream redirection using
// dup() and dup2().
// GTEST_USE_OWN_TR1_TUPLE - Define it to 1/0 to indicate whether Google
// Test's own tr1 tuple implementation should be
// used. Unused when the user sets
// GTEST_HAS_TR1_TUPLE to 0.
// GTEST_LANG_CXX11 - Define it to 1/0 to indicate that Google Test
// is building in C++11/C++98 mode.
// GTEST_LINKED_AS_SHARED_LIBRARY
@ -172,8 +166,6 @@
// EXPECT_DEATH(DoSomethingDeadly());
// #endif
//
// GTEST_HAS_COMBINE - the Combine() function (for value-parameterized
// tests)
// GTEST_HAS_DEATH_TEST - death tests
// GTEST_HAS_TYPED_TEST - typed tests
// GTEST_HAS_TYPED_TEST_P - type-parameterized tests
@ -280,10 +272,11 @@
// Brings in the definition of HAS_GLOBAL_STRING. This must be done
// BEFORE we test HAS_GLOBAL_STRING.
#include <string> // NOLINT
#include <string> // NOLINT
#include <algorithm> // NOLINT
#include <iostream> // NOLINT
#include <sstream> // NOLINT
#include <iostream> // NOLINT
#include <sstream> // NOLINT
#include <tuple>
#include <utility>
#include <vector> // NOLINT
@ -381,31 +374,6 @@
# define GTEST_HAS_UNORDERED_SET_ 1
#endif
// C++11 specifies that <tuple> provides std::tuple.
// Some platforms still might not have it, however.
#if GTEST_LANG_CXX11
# define GTEST_HAS_STD_TUPLE_ 1
# if defined(__clang__)
// Inspired by
// https://clang.llvm.org/docs/LanguageExtensions.html#include-file-checking-macros
# if defined(__has_include) && !__has_include(<tuple>)
# undef GTEST_HAS_STD_TUPLE_
# endif
# elif defined(_MSC_VER)
// Inspired by boost/config/stdlib/dinkumware.hpp
# if defined(_CPPLIB_VER) && _CPPLIB_VER < 520
# undef GTEST_HAS_STD_TUPLE_
# endif
# elif defined(__GLIBCXX__)
// Inspired by boost/config/stdlib/libstdcpp3.hpp,
// http://gcc.gnu.org/gcc-4.2/changes.html and
// https://web.archive.org/web/20140227044429/gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt01ch01.html#manual.intro.status.standard.200x
# if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 2)
# undef GTEST_HAS_STD_TUPLE_
# endif
# endif
#endif
// Brings in definitions for functions used in the testing::internal::posix
// namespace (read, write, close, chdir, isatty, stat). We do not currently
// use them on Windows Mobile.
@ -647,127 +615,6 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
# endif // _MSC_VER
#endif // !defined(GTEST_HAS_HASH_MAP_)
// Determines whether Google Test can use tr1/tuple. You can define
// this macro to 0 to prevent Google Test from using tuple (any
// feature depending on tuple with be disabled in this mode).
#ifndef GTEST_HAS_TR1_TUPLE
# if GTEST_OS_LINUX_ANDROID && defined(_STLPORT_MAJOR)
// STLport, provided with the Android NDK, has neither <tr1/tuple> or <tuple>.
# define GTEST_HAS_TR1_TUPLE 0
# elif defined(_MSC_VER) && (_MSC_VER >= 1910)
// Prevent `warning C4996: 'std::tr1': warning STL4002:
// The non-Standard std::tr1 namespace and TR1-only machinery
// are deprecated and will be REMOVED.`
# define GTEST_HAS_TR1_TUPLE 0
# elif GTEST_LANG_CXX11 && defined(_LIBCPP_VERSION)
// libc++ doesn't support TR1.
# define GTEST_HAS_TR1_TUPLE 0
# else
// The user didn't tell us not to do it, so we assume it's OK.
# define GTEST_HAS_TR1_TUPLE 1
# endif
#endif // GTEST_HAS_TR1_TUPLE
// Determines whether Google Test's own tr1 tuple implementation
// should be used.
#ifndef GTEST_USE_OWN_TR1_TUPLE
// We use our own tuple implementation on Symbian.
# if GTEST_OS_SYMBIAN
# define GTEST_USE_OWN_TR1_TUPLE 1
# else
// The user didn't tell us, so we need to figure it out.
// We use our own TR1 tuple if we aren't sure the user has an
// implementation of it already. At this time, libstdc++ 4.0.0+ and
// MSVC 2010 are the only mainstream standard libraries that come
// with a TR1 tuple implementation. NVIDIA's CUDA NVCC compiler
// pretends to be GCC by defining __GNUC__ and friends, but cannot
// compile GCC's tuple implementation. MSVC 2008 (9.0) provides TR1
// tuple in a 323 MB Feature Pack download, which we cannot assume the
// user has. QNX's QCC compiler is a modified GCC but it doesn't
// support TR1 tuple. libc++ only provides std::tuple, in C++11 mode,
// and it can be used with some compilers that define __GNUC__.
# if (defined(__GNUC__) && !defined(__CUDACC__) && (GTEST_GCC_VER_ >= 40000) \
&& !GTEST_OS_QNX && !defined(_LIBCPP_VERSION)) \
|| (_MSC_VER >= 1600 && _MSC_VER < 1900)
# define GTEST_ENV_HAS_TR1_TUPLE_ 1
# endif
// C++11 specifies that <tuple> provides std::tuple. Use that if gtest is used
// in C++11 mode and libstdc++ isn't very old (binaries targeting OS X 10.6
// can build with clang but need to use gcc4.2's libstdc++).
# if GTEST_LANG_CXX11 && (!defined(__GLIBCXX__) || __GLIBCXX__ > 20110325)
# define GTEST_ENV_HAS_STD_TUPLE_ 1
# endif
# if GTEST_ENV_HAS_TR1_TUPLE_ || GTEST_ENV_HAS_STD_TUPLE_
# define GTEST_USE_OWN_TR1_TUPLE 0
# else
# define GTEST_USE_OWN_TR1_TUPLE 1
# endif
# endif // GTEST_OS_SYMBIAN
#endif // GTEST_USE_OWN_TR1_TUPLE
// To avoid conditional compilation we make it gtest-port.h's responsibility
// to #include the header implementing tuple.
#if GTEST_HAS_STD_TUPLE_
# include <tuple> // IWYU pragma: export
# define GTEST_TUPLE_NAMESPACE_ ::std
#endif // GTEST_HAS_STD_TUPLE_
// We include tr1::tuple even if std::tuple is available to define printers for
// them.
#if GTEST_HAS_TR1_TUPLE
# ifndef GTEST_TUPLE_NAMESPACE_
# define GTEST_TUPLE_NAMESPACE_ ::std::tr1
# endif // GTEST_TUPLE_NAMESPACE_
# if GTEST_USE_OWN_TR1_TUPLE
# include "gtest/internal/gtest-tuple.h" // IWYU pragma: export // NOLINT
# elif GTEST_OS_SYMBIAN
// On Symbian, BOOST_HAS_TR1_TUPLE causes Boost's TR1 tuple library to
// use STLport's tuple implementation, which unfortunately doesn't
// work as the copy of STLport distributed with Symbian is incomplete.
// By making sure BOOST_HAS_TR1_TUPLE is undefined, we force Boost to
// use its own tuple implementation.
# ifdef BOOST_HAS_TR1_TUPLE
# undef BOOST_HAS_TR1_TUPLE
# endif // BOOST_HAS_TR1_TUPLE
// This prevents <boost/tr1/detail/config.hpp>, which defines
// BOOST_HAS_TR1_TUPLE, from being #included by Boost's <tuple>.
# define BOOST_TR1_DETAIL_CONFIG_HPP_INCLUDED
# include <tuple> // IWYU pragma: export // NOLINT
# elif defined(__GNUC__) && (GTEST_GCC_VER_ >= 40000)
// GCC 4.0+ implements tr1/tuple in the <tr1/tuple> header. This does
// not conform to the TR1 spec, which requires the header to be <tuple>.
# if !GTEST_HAS_RTTI && GTEST_GCC_VER_ < 40302
// Until version 4.3.2, gcc has a bug that causes <tr1/functional>,
// which is #included by <tr1/tuple>, to not compile when RTTI is
// disabled. _TR1_FUNCTIONAL is the header guard for
// <tr1/functional>. Hence the following #define is used to prevent
// <tr1/functional> from being included.
# define _TR1_FUNCTIONAL 1
# include <tr1/tuple>
# undef _TR1_FUNCTIONAL // Allows the user to #include
// <tr1/functional> if they choose to.
# else
# include <tr1/tuple> // NOLINT
# endif // !GTEST_HAS_RTTI && GTEST_GCC_VER_ < 40302
// VS 2010 now has tr1 support.
# elif _MSC_VER >= 1600
# include <tuple> // IWYU pragma: export // NOLINT
# else // GTEST_USE_OWN_TR1_TUPLE
# include <tr1/tuple> // IWYU pragma: export // NOLINT
# endif // GTEST_USE_OWN_TR1_TUPLE
#endif // GTEST_HAS_TR1_TUPLE
// Determines whether clone(2) is supported.
// Usually it will only be available on Linux, excluding
// Linux on the Itanium architecture.
@ -832,14 +679,6 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
# define GTEST_HAS_TYPED_TEST_P 1
#endif
// Determines whether to support Combine(). This only makes sense when
// value-parameterized tests are enabled. The implementation doesn't
// work on Sun Studio since it doesn't understand templated conversion
// operators.
#if (GTEST_HAS_TR1_TUPLE || GTEST_HAS_STD_TUPLE_) && !defined(__SUNPRO_CC)
# define GTEST_HAS_COMBINE 1
#endif
// Determines whether the system compiler uses UTF-16 for encoding wide strings.
#define GTEST_WIDE_STRING_USES_UTF16_ \
(GTEST_OS_WINDOWS || GTEST_OS_CYGWIN || GTEST_OS_SYMBIAN || GTEST_OS_AIX)
@ -1049,16 +888,13 @@ namespace testing {
class Message;
#if defined(GTEST_TUPLE_NAMESPACE_)
// Import tuple and friends into the ::testing namespace.
// It is part of our interface, having them in ::testing allows us to change
// their types as needed.
using GTEST_TUPLE_NAMESPACE_::get;
using GTEST_TUPLE_NAMESPACE_::make_tuple;
using GTEST_TUPLE_NAMESPACE_::tuple;
using GTEST_TUPLE_NAMESPACE_::tuple_size;
using GTEST_TUPLE_NAMESPACE_::tuple_element;
#endif // defined(GTEST_TUPLE_NAMESPACE_)
// Legacy imports for backwards compatibility.
// New code should use std:: names directly.
using std::get;
using std::make_tuple;
using std::tuple;
using std::tuple_element;
using std::tuple_size;
namespace internal {
@ -2540,9 +2376,9 @@ GTEST_DISABLE_MSC_DEPRECATED_POP_()
// Windows CE has no C library. The abort() function is used in
// several places in Google Test. This implementation provides a reasonable
// imitation of standard behaviour.
void Abort();
[[noreturn]] void Abort();
#else
inline void Abort() { abort(); }
[[noreturn]] inline void Abort() { abort(); }
#endif // GTEST_OS_WINDOWS_MOBILE
} // namespace posix

File diff suppressed because it is too large Load Diff

View File

@ -1,348 +0,0 @@
$$ -*- mode: c++; -*-
$var n = 10 $$ Maximum number of tuple fields we want to support.
$$ This meta comment fixes auto-indentation in Emacs. }}
// Copyright 2009 Google Inc.
// All Rights Reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Implements a subset of TR1 tuple needed by Google Test and Google Mock.
// GOOGLETEST_CM0001 DO NOT DELETE
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_
#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_
#include <utility> // For ::std::pair.
// The compiler used in Symbian has a bug that prevents us from declaring the
// tuple template as a friend (it complains that tuple is redefined). This
// bypasses the bug by declaring the members that should otherwise be
// private as public.
// Sun Studio versions < 12 also have the above bug.
#if defined(__SYMBIAN32__) || (defined(__SUNPRO_CC) && __SUNPRO_CC < 0x590)
# define GTEST_DECLARE_TUPLE_AS_FRIEND_ public:
#else
# define GTEST_DECLARE_TUPLE_AS_FRIEND_ \
template <GTEST_$(n)_TYPENAMES_(U)> friend class tuple; \
private:
#endif
// Visual Studio 2010, 2012, and 2013 define symbols in std::tr1 that conflict
// with our own definitions. Therefore using our own tuple does not work on
// those compilers.
#if defined(_MSC_VER) && _MSC_VER >= 1600 /* 1600 is Visual Studio 2010 */
# error "gtest's tuple doesn't compile on Visual Studio 2010 or later. \
GTEST_USE_OWN_TR1_TUPLE must be set to 0 on those compilers."
#endif
$range i 0..n-1
$range j 0..n
$range k 1..n
// GTEST_n_TUPLE_(T) is the type of an n-tuple.
#define GTEST_0_TUPLE_(T) tuple<>
$for k [[
$range m 0..k-1
$range m2 k..n-1
#define GTEST_$(k)_TUPLE_(T) tuple<$for m, [[T##$m]]$for m2 [[, void]]>
]]
// GTEST_n_TYPENAMES_(T) declares a list of n typenames.
$for j [[
$range m 0..j-1
#define GTEST_$(j)_TYPENAMES_(T) $for m, [[typename T##$m]]
]]
// In theory, defining stuff in the ::std namespace is undefined
// behavior. We can do this as we are playing the role of a standard
// library vendor.
namespace std {
namespace tr1 {
template <$for i, [[typename T$i = void]]>
class tuple;
// Anything in namespace gtest_internal is Google Test's INTERNAL
// IMPLEMENTATION DETAIL and MUST NOT BE USED DIRECTLY in user code.
namespace gtest_internal {
// ByRef<T>::type is T if T is a reference; otherwise it's const T&.
template <typename T>
struct ByRef { typedef const T& type; }; // NOLINT
template <typename T>
struct ByRef<T&> { typedef T& type; }; // NOLINT
// A handy wrapper for ByRef.
#define GTEST_BY_REF_(T) typename ::std::tr1::gtest_internal::ByRef<T>::type
// AddRef<T>::type is T if T is a reference; otherwise it's T&. This
// is the same as tr1::add_reference<T>::type.
template <typename T>
struct AddRef { typedef T& type; }; // NOLINT
template <typename T>
struct AddRef<T&> { typedef T& type; }; // NOLINT
// A handy wrapper for AddRef.
#define GTEST_ADD_REF_(T) typename ::std::tr1::gtest_internal::AddRef<T>::type
// A helper for implementing get<k>().
template <int k> class Get;
// A helper for implementing tuple_element<k, T>. kIndexValid is true
// iff k < the number of fields in tuple type T.
template <bool kIndexValid, int kIndex, class Tuple>
struct TupleElement;
$for i [[
template <GTEST_$(n)_TYPENAMES_(T)>
struct TupleElement<true, $i, GTEST_$(n)_TUPLE_(T) > {
typedef T$i type;
};
]]
} // namespace gtest_internal
template <>
class tuple<> {
public:
tuple() {}
tuple(const tuple& /* t */) {}
tuple& operator=(const tuple& /* t */) { return *this; }
};
$for k [[
$range m 0..k-1
template <GTEST_$(k)_TYPENAMES_(T)>
class $if k < n [[GTEST_$(k)_TUPLE_(T)]] $else [[tuple]] {
public:
template <int k> friend class gtest_internal::Get;
tuple() : $for m, [[f$(m)_()]] {}
explicit tuple($for m, [[GTEST_BY_REF_(T$m) f$m]]) : [[]]
$for m, [[f$(m)_(f$m)]] {}
tuple(const tuple& t) : $for m, [[f$(m)_(t.f$(m)_)]] {}
template <GTEST_$(k)_TYPENAMES_(U)>
tuple(const GTEST_$(k)_TUPLE_(U)& t) : $for m, [[f$(m)_(t.f$(m)_)]] {}
$if k == 2 [[
template <typename U0, typename U1>
tuple(const ::std::pair<U0, U1>& p) : f0_(p.first), f1_(p.second) {}
]]
tuple& operator=(const tuple& t) { return CopyFrom(t); }
template <GTEST_$(k)_TYPENAMES_(U)>
tuple& operator=(const GTEST_$(k)_TUPLE_(U)& t) {
return CopyFrom(t);
}
$if k == 2 [[
template <typename U0, typename U1>
tuple& operator=(const ::std::pair<U0, U1>& p) {
f0_ = p.first;
f1_ = p.second;
return *this;
}
]]
GTEST_DECLARE_TUPLE_AS_FRIEND_
template <GTEST_$(k)_TYPENAMES_(U)>
tuple& CopyFrom(const GTEST_$(k)_TUPLE_(U)& t) {
$for m [[
f$(m)_ = t.f$(m)_;
]]
return *this;
}
$for m [[
T$m f$(m)_;
]]
};
]]
// 6.1.3.2 Tuple creation functions.
// Known limitations: we don't support passing an
// std::tr1::reference_wrapper<T> to make_tuple(). And we don't
// implement tie().
inline tuple<> make_tuple() { return tuple<>(); }
$for k [[
$range m 0..k-1
template <GTEST_$(k)_TYPENAMES_(T)>
inline GTEST_$(k)_TUPLE_(T) make_tuple($for m, [[const T$m& f$m]]) {
return GTEST_$(k)_TUPLE_(T)($for m, [[f$m]]);
}
]]
// 6.1.3.3 Tuple helper classes.
template <typename Tuple> struct tuple_size;
$for j [[
template <GTEST_$(j)_TYPENAMES_(T)>
struct tuple_size<GTEST_$(j)_TUPLE_(T) > {
static const int value = $j;
};
]]
template <int k, class Tuple>
struct tuple_element {
typedef typename gtest_internal::TupleElement<
k < (tuple_size<Tuple>::value), k, Tuple>::type type;
};
#define GTEST_TUPLE_ELEMENT_(k, Tuple) typename tuple_element<k, Tuple >::type
// 6.1.3.4 Element access.
namespace gtest_internal {
$for i [[
template <>
class Get<$i> {
public:
template <class Tuple>
static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_($i, Tuple))
Field(Tuple& t) { return t.f$(i)_; } // NOLINT
template <class Tuple>
static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_($i, Tuple))
ConstField(const Tuple& t) { return t.f$(i)_; }
};
]]
} // namespace gtest_internal
template <int k, GTEST_$(n)_TYPENAMES_(T)>
GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(k, GTEST_$(n)_TUPLE_(T)))
get(GTEST_$(n)_TUPLE_(T)& t) {
return gtest_internal::Get<k>::Field(t);
}
template <int k, GTEST_$(n)_TYPENAMES_(T)>
GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(k, GTEST_$(n)_TUPLE_(T)))
get(const GTEST_$(n)_TUPLE_(T)& t) {
return gtest_internal::Get<k>::ConstField(t);
}
// 6.1.3.5 Relational operators
// We only implement == and !=, as we don't have a need for the rest yet.
namespace gtest_internal {
// SameSizeTuplePrefixComparator<k, k>::Eq(t1, t2) returns true if the
// first k fields of t1 equals the first k fields of t2.
// SameSizeTuplePrefixComparator(k1, k2) would be a compiler error if
// k1 != k2.
template <int kSize1, int kSize2>
struct SameSizeTuplePrefixComparator;
template <>
struct SameSizeTuplePrefixComparator<0, 0> {
template <class Tuple1, class Tuple2>
static bool Eq(const Tuple1& /* t1 */, const Tuple2& /* t2 */) {
return true;
}
};
template <int k>
struct SameSizeTuplePrefixComparator<k, k> {
template <class Tuple1, class Tuple2>
static bool Eq(const Tuple1& t1, const Tuple2& t2) {
return SameSizeTuplePrefixComparator<k - 1, k - 1>::Eq(t1, t2) &&
::std::tr1::get<k - 1>(t1) == ::std::tr1::get<k - 1>(t2);
}
};
} // namespace gtest_internal
template <GTEST_$(n)_TYPENAMES_(T), GTEST_$(n)_TYPENAMES_(U)>
inline bool operator==(const GTEST_$(n)_TUPLE_(T)& t,
const GTEST_$(n)_TUPLE_(U)& u) {
return gtest_internal::SameSizeTuplePrefixComparator<
tuple_size<GTEST_$(n)_TUPLE_(T) >::value,
tuple_size<GTEST_$(n)_TUPLE_(U) >::value>::Eq(t, u);
}
template <GTEST_$(n)_TYPENAMES_(T), GTEST_$(n)_TYPENAMES_(U)>
inline bool operator!=(const GTEST_$(n)_TUPLE_(T)& t,
const GTEST_$(n)_TUPLE_(U)& u) { return !(t == u); }
// 6.1.4 Pairs.
// Unimplemented.
} // namespace tr1
} // namespace std
$for j [[
#undef GTEST_$(j)_TUPLE_
]]
$for j [[
#undef GTEST_$(j)_TYPENAMES_
]]
#undef GTEST_DECLARE_TUPLE_AS_FRIEND_
#undef GTEST_BY_REF_
#undef GTEST_ADD_REF_
#undef GTEST_TUPLE_ELEMENT_
#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_

View File

@ -37,7 +37,6 @@
#include "gtest/gtest.h"
namespace {
#if GTEST_HAS_COMBINE
// Suppose we want to introduce a new, improved implementation of PrimeTable
// which combines speed of PrecalcPrimeTable and versatility of
@ -90,19 +89,12 @@ using ::testing::Combine;
// PreCalculatedPrimeTable disabled. We do this by defining fixture which will
// accept different combinations of parameters for instantiating a
// HybridPrimeTable instance.
class PrimeTableTest : public TestWithParam< ::testing::tuple<bool, int> > {
class PrimeTableTest : public TestWithParam< ::std::tuple<bool, int> > {
protected:
virtual void SetUp() {
// This can be written as
//
// bool force_on_the_fly;
// int max_precalculated;
// tie(force_on_the_fly, max_precalculated) = GetParam();
//
// once the Google C++ Style Guide allows use of ::std::tr1::tie.
//
bool force_on_the_fly = ::testing::get<0>(GetParam());
int max_precalculated = ::testing::get<1>(GetParam());
bool force_on_the_fly;
int max_precalculated;
std::tie(force_on_the_fly, max_precalculated) = GetParam();
table_ = new HybridPrimeTable(force_on_the_fly, max_precalculated);
}
virtual void TearDown() {
@ -160,15 +152,4 @@ INSTANTIATE_TEST_CASE_P(MeaningfulTestParameters,
PrimeTableTest,
Combine(Bool(), Values(1, 10)));
#else
// Google Test may not support Combine() with some compilers. If we
// use conditional compilation to compile out all code referring to
// the gtest_main library, MSVC linker will not link that library at
// all and consequently complain about missing entry point defined in
// that library (fatal error LNK1561: entry point must be
// defined). This dummy test keeps gtest_main linked in.
TEST(DummyTest, CombineIsNotSupportedOnThisPlatform) {}
#endif // GTEST_HAS_COMBINE
} // namespace

View File

@ -49,7 +49,7 @@ config_setting(
values = {"define": "absl=1"},
)
#on windows exclude gtest-tuple.h and googletest-tuple-test.cc
#on windows exclude gtest-tuple.h
cc_test(
name = "gtest_all_test",
size = "small",
@ -62,7 +62,6 @@ cc_test(
],
exclude = [
"gtest-unittest-api_test.cc",
"googletest-tuple-test.cc",
"googletest/src/gtest-all.cc",
"gtest_all_test.cc",
"gtest-death-test_ex_test.cc",
@ -89,9 +88,7 @@ cc_test(
) + select({
"//:windows": [],
"//:windows_msvc": [],
"//conditions:default": [
"googletest-tuple-test.cc",
],
"//conditions:default": [],
}),
copts = select({
"//:windows": ["-DGTEST_USE_OWN_TR1_TUPLE=0"],

View File

@ -49,19 +49,13 @@ using ::std::sort;
using ::testing::AddGlobalTestEnvironment;
using ::testing::Bool;
using ::testing::Combine;
using ::testing::Message;
using ::testing::Range;
using ::testing::TestWithParam;
using ::testing::Values;
using ::testing::ValuesIn;
# if GTEST_HAS_COMBINE
using ::testing::Combine;
using ::testing::get;
using ::testing::make_tuple;
using ::testing::tuple;
# endif // GTEST_HAS_COMBINE
using ::testing::internal::ParamGenerator;
using ::testing::internal::UnitTestOptions;
@ -78,8 +72,6 @@ template <typename T>
return stream.str();
}
# if GTEST_HAS_COMBINE
// These overloads allow printing tuples in our tests. We cannot
// define an operator<< for tuples, as that definition needs to be in
// the std namespace in order to be picked up by Google Test via
@ -87,35 +79,33 @@ template <typename T>
// namespace in non-STL code is undefined behavior.
template <typename T1, typename T2>
::std::string PrintValue(const tuple<T1, T2>& value) {
::std::string PrintValue(const std::tuple<T1, T2>& value) {
::std::stringstream stream;
stream << "(" << get<0>(value) << ", " << get<1>(value) << ")";
stream << "(" << std::get<0>(value) << ", " << std::get<1>(value) << ")";
return stream.str();
}
template <typename T1, typename T2, typename T3>
::std::string PrintValue(const tuple<T1, T2, T3>& value) {
::std::string PrintValue(const std::tuple<T1, T2, T3>& value) {
::std::stringstream stream;
stream << "(" << get<0>(value) << ", " << get<1>(value)
<< ", "<< get<2>(value) << ")";
stream << "(" << std::get<0>(value) << ", " << std::get<1>(value) << ", "
<< std::get<2>(value) << ")";
return stream.str();
}
template <typename T1, typename T2, typename T3, typename T4, typename T5,
typename T6, typename T7, typename T8, typename T9, typename T10>
::std::string PrintValue(
const tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>& value) {
const std::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>& value) {
::std::stringstream stream;
stream << "(" << get<0>(value) << ", " << get<1>(value)
<< ", "<< get<2>(value) << ", " << get<3>(value)
<< ", "<< get<4>(value) << ", " << get<5>(value)
<< ", "<< get<6>(value) << ", " << get<7>(value)
<< ", "<< get<8>(value) << ", " << get<9>(value) << ")";
stream << "(" << std::get<0>(value) << ", " << std::get<1>(value) << ", "
<< std::get<2>(value) << ", " << std::get<3>(value) << ", "
<< std::get<4>(value) << ", " << std::get<5>(value) << ", "
<< std::get<6>(value) << ", " << std::get<7>(value) << ", "
<< std::get<8>(value) << ", " << std::get<9>(value) << ")";
return stream.str();
}
# endif // GTEST_HAS_COMBINE
// Verifies that a sequence generated by the generator and accessed
// via the iterator object matches the expected one using Google Test
// assertions.
@ -450,31 +440,28 @@ TEST(BoolTest, BoolWorks) {
VerifyGenerator(gen, expected_values);
}
# if GTEST_HAS_COMBINE
// Tests that Combine() with two parameters generates the expected sequence.
TEST(CombineTest, CombineWithTwoParameters) {
const char* foo = "foo";
const char* bar = "bar";
const ParamGenerator<tuple<const char*, int> > gen =
const ParamGenerator<std::tuple<const char*, int> > gen =
Combine(Values(foo, bar), Values(3, 4));
tuple<const char*, int> expected_values[] = {
make_tuple(foo, 3), make_tuple(foo, 4),
make_tuple(bar, 3), make_tuple(bar, 4)};
std::tuple<const char*, int> expected_values[] = {
std::make_tuple(foo, 3), std::make_tuple(foo, 4), std::make_tuple(bar, 3),
std::make_tuple(bar, 4)};
VerifyGenerator(gen, expected_values);
}
// Tests that Combine() with three parameters generates the expected sequence.
TEST(CombineTest, CombineWithThreeParameters) {
const ParamGenerator<tuple<int, int, int> > gen = Combine(Values(0, 1),
Values(3, 4),
Values(5, 6));
tuple<int, int, int> expected_values[] = {
make_tuple(0, 3, 5), make_tuple(0, 3, 6),
make_tuple(0, 4, 5), make_tuple(0, 4, 6),
make_tuple(1, 3, 5), make_tuple(1, 3, 6),
make_tuple(1, 4, 5), make_tuple(1, 4, 6)};
const ParamGenerator<std::tuple<int, int, int> > gen =
Combine(Values(0, 1), Values(3, 4), Values(5, 6));
std::tuple<int, int, int> expected_values[] = {
std::make_tuple(0, 3, 5), std::make_tuple(0, 3, 6),
std::make_tuple(0, 4, 5), std::make_tuple(0, 4, 6),
std::make_tuple(1, 3, 5), std::make_tuple(1, 3, 6),
std::make_tuple(1, 4, 5), std::make_tuple(1, 4, 6)};
VerifyGenerator(gen, expected_values);
}
@ -482,10 +469,11 @@ TEST(CombineTest, CombineWithThreeParameters) {
// sequence generates a sequence with the number of elements equal to the
// number of elements in the sequence generated by the second parameter.
TEST(CombineTest, CombineWithFirstParameterSingleValue) {
const ParamGenerator<tuple<int, int> > gen = Combine(Values(42),
Values(0, 1));
const ParamGenerator<std::tuple<int, int> > gen =
Combine(Values(42), Values(0, 1));
tuple<int, int> expected_values[] = {make_tuple(42, 0), make_tuple(42, 1)};
std::tuple<int, int> expected_values[] = {std::make_tuple(42, 0),
std::make_tuple(42, 1)};
VerifyGenerator(gen, expected_values);
}
@ -493,26 +481,27 @@ TEST(CombineTest, CombineWithFirstParameterSingleValue) {
// sequence generates a sequence with the number of elements equal to the
// number of elements in the sequence generated by the first parameter.
TEST(CombineTest, CombineWithSecondParameterSingleValue) {
const ParamGenerator<tuple<int, int> > gen = Combine(Values(0, 1),
Values(42));
const ParamGenerator<std::tuple<int, int> > gen =
Combine(Values(0, 1), Values(42));
tuple<int, int> expected_values[] = {make_tuple(0, 42), make_tuple(1, 42)};
std::tuple<int, int> expected_values[] = {std::make_tuple(0, 42),
std::make_tuple(1, 42)};
VerifyGenerator(gen, expected_values);
}
// Tests that when the first parameter produces an empty sequence,
// Combine() produces an empty sequence, too.
TEST(CombineTest, CombineWithFirstParameterEmptyRange) {
const ParamGenerator<tuple<int, int> > gen = Combine(Range(0, 0),
Values(0, 1));
const ParamGenerator<std::tuple<int, int> > gen =
Combine(Range(0, 0), Values(0, 1));
VerifyGeneratorIsEmpty(gen);
}
// Tests that when the second parameter produces an empty sequence,
// Combine() produces an empty sequence, too.
TEST(CombineTest, CombineWithSecondParameterEmptyRange) {
const ParamGenerator<tuple<int, int> > gen = Combine(Values(0, 1),
Range(1, 1));
const ParamGenerator<std::tuple<int, int> > gen =
Combine(Values(0, 1), Range(1, 1));
VerifyGeneratorIsEmpty(gen);
}
@ -521,17 +510,15 @@ TEST(CombineTest, CombineWithSecondParameterEmptyRange) {
TEST(CombineTest, CombineWithMaxNumberOfParameters) {
const char* foo = "foo";
const char* bar = "bar";
const ParamGenerator<tuple<const char*, int, int, int, int, int, int, int,
int, int> > gen = Combine(Values(foo, bar),
Values(1), Values(2),
Values(3), Values(4),
Values(5), Values(6),
Values(7), Values(8),
Values(9));
const ParamGenerator<
std::tuple<const char*, int, int, int, int, int, int, int, int, int> >
gen =
Combine(Values(foo, bar), Values(1), Values(2), Values(3), Values(4),
Values(5), Values(6), Values(7), Values(8), Values(9));
tuple<const char*, int, int, int, int, int, int, int, int, int>
expected_values[] = {make_tuple(foo, 1, 2, 3, 4, 5, 6, 7, 8, 9),
make_tuple(bar, 1, 2, 3, 4, 5, 6, 7, 8, 9)};
std::tuple<const char*, int, int, int, int, int, int, int, int, int>
expected_values[] = {std::make_tuple(foo, 1, 2, 3, 4, 5, 6, 7, 8, 9),
std::make_tuple(bar, 1, 2, 3, 4, 5, 6, 7, 8, 9)};
VerifyGenerator(gen, expected_values);
}
@ -551,12 +538,12 @@ class NonDefaultConstructAssignString {
};
TEST(CombineTest, NonDefaultConstructAssign) {
const ParamGenerator<tuple<int, NonDefaultConstructAssignString> > gen =
const ParamGenerator<std::tuple<int, NonDefaultConstructAssignString> > gen =
Combine(Values(0, 1), Values(NonDefaultConstructAssignString("A"),
NonDefaultConstructAssignString("B")));
ParamGenerator<tuple<int, NonDefaultConstructAssignString> >::iterator it =
gen.begin();
ParamGenerator<std::tuple<int, NonDefaultConstructAssignString> >::iterator
it = gen.begin();
EXPECT_EQ(0, std::get<0>(*it));
EXPECT_EQ("A", std::get<1>(*it).str());
@ -577,7 +564,6 @@ TEST(CombineTest, NonDefaultConstructAssign) {
EXPECT_TRUE(it == gen.end());
}
# endif // GTEST_HAS_COMBINE
// Tests that an generator produces correct sequence after being
// assigned from another generator.

View File

@ -228,9 +228,7 @@ using ::testing::internal::Strings;
using ::testing::internal::UniversalPrint;
using ::testing::internal::UniversalPrinter;
using ::testing::internal::UniversalTersePrint;
#if GTEST_HAS_TR1_TUPLE || GTEST_HAS_STD_TUPLE_
using ::testing::internal::UniversalTersePrintTupleFieldsToStrings;
#endif
// Prints a value to a string using the universal value printer. This
// is a helper for testing UniversalPrinter<T>::Print() for various types.
@ -991,67 +989,6 @@ TEST(PrintStlContainerTest, ConstIterator) {
EXPECT_EQ("1-byte object <00>", Print(it));
}
#if GTEST_HAS_TR1_TUPLE
// Tests printing ::std::tr1::tuples.
// Tuples of various arities.
TEST(PrintTr1TupleTest, VariousSizes) {
::std::tr1::tuple<> t0;
EXPECT_EQ("()", Print(t0));
::std::tr1::tuple<int> t1(5);
EXPECT_EQ("(5)", Print(t1));
::std::tr1::tuple<char, bool> t2('a', true);
EXPECT_EQ("('a' (97, 0x61), true)", Print(t2));
::std::tr1::tuple<bool, int, int> t3(false, 2, 3);
EXPECT_EQ("(false, 2, 3)", Print(t3));
::std::tr1::tuple<bool, int, int, int> t4(false, 2, 3, 4);
EXPECT_EQ("(false, 2, 3, 4)", Print(t4));
::std::tr1::tuple<bool, int, int, int, bool> t5(false, 2, 3, 4, true);
EXPECT_EQ("(false, 2, 3, 4, true)", Print(t5));
::std::tr1::tuple<bool, int, int, int, bool, int> t6(false, 2, 3, 4, true, 6);
EXPECT_EQ("(false, 2, 3, 4, true, 6)", Print(t6));
::std::tr1::tuple<bool, int, int, int, bool, int, int> t7(
false, 2, 3, 4, true, 6, 7);
EXPECT_EQ("(false, 2, 3, 4, true, 6, 7)", Print(t7));
::std::tr1::tuple<bool, int, int, int, bool, int, int, bool> t8(
false, 2, 3, 4, true, 6, 7, true);
EXPECT_EQ("(false, 2, 3, 4, true, 6, 7, true)", Print(t8));
::std::tr1::tuple<bool, int, int, int, bool, int, int, bool, int> t9(
false, 2, 3, 4, true, 6, 7, true, 9);
EXPECT_EQ("(false, 2, 3, 4, true, 6, 7, true, 9)", Print(t9));
const char* const str = "8";
// VC++ 2010's implementation of tuple of C++0x is deficient, requiring
// an explicit type cast of NULL to be used.
::std::tr1::tuple<bool, char, short, testing::internal::Int32, // NOLINT
testing::internal::Int64, float, double, const char*, void*,
std::string>
t10(false, 'a', static_cast<short>(3), 4, 5, 1.5F, -2.5, str, // NOLINT
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));
}
// Nested tuples.
TEST(PrintTr1TupleTest, NestedTuple) {
::std::tr1::tuple< ::std::tr1::tuple<int, bool>, char> nested(
::std::tr1::make_tuple(5, true), 'a');
EXPECT_EQ("((5, true), 'a' (97, 0x61))", Print(nested));
}
#endif // GTEST_HAS_TR1_TUPLE
#if GTEST_HAS_STD_TUPLE_
// Tests printing ::std::tuples.
// Tuples of various arities.
@ -1071,32 +1008,12 @@ TEST(PrintStdTupleTest, VariousSizes) {
::std::tuple<bool, int, int, int> t4(false, 2, 3, 4);
EXPECT_EQ("(false, 2, 3, 4)", Print(t4));
::std::tuple<bool, int, int, int, bool> t5(false, 2, 3, 4, true);
EXPECT_EQ("(false, 2, 3, 4, true)", Print(t5));
::std::tuple<bool, int, int, int, bool, int> t6(false, 2, 3, 4, true, 6);
EXPECT_EQ("(false, 2, 3, 4, true, 6)", Print(t6));
::std::tuple<bool, int, int, int, bool, int, int> t7(
false, 2, 3, 4, true, 6, 7);
EXPECT_EQ("(false, 2, 3, 4, true, 6, 7)", Print(t7));
::std::tuple<bool, int, int, int, bool, int, int, bool> t8(
false, 2, 3, 4, true, 6, 7, true);
EXPECT_EQ("(false, 2, 3, 4, true, 6, 7, true)", Print(t8));
::std::tuple<bool, int, int, int, bool, int, int, bool, int> t9(
false, 2, 3, 4, true, 6, 7, true, 9);
EXPECT_EQ("(false, 2, 3, 4, true, 6, 7, true, 9)", Print(t9));
const char* const str = "8";
// VC++ 2010's implementation of tuple of C++0x is deficient, requiring
// an explicit type cast of NULL to be used.
::std::tuple<bool, char, short, testing::internal::Int32, // NOLINT
testing::internal::Int64, float, double, const char*, void*,
std::string>
t10(false, 'a', static_cast<short>(3), 4, 5, 1.5F, -2.5, str, // NOLINT
ImplicitCast_<void*>(NULL), "10");
nullptr, "10");
EXPECT_EQ("(false, 'a' (97, 0x61), 3, 4, 5, 1.5, -2.5, " + PrintPointer(str) +
" pointing to \"8\", NULL, \"10\")",
Print(t10));
@ -1109,8 +1026,6 @@ TEST(PrintStdTupleTest, NestedTuple) {
EXPECT_EQ("((5, true), 'a' (97, 0x61))", Print(nested));
}
#endif // GTEST_HAS_TR1_TUPLE
TEST(PrintNullptrT, Basic) {
EXPECT_EQ("(nullptr)", Print(nullptr));
}
@ -1662,42 +1577,6 @@ TEST(UniversalPrintTest, WorksForCharArray) {
EXPECT_EQ("\"\\\"Line\\0 1\\\"\\nLine 2\"", ss2.str());
}
#if GTEST_HAS_TR1_TUPLE
TEST(UniversalTersePrintTupleFieldsToStringsTestWithTr1, PrintsEmptyTuple) {
Strings result = UniversalTersePrintTupleFieldsToStrings(
::std::tr1::make_tuple());
EXPECT_EQ(0u, result.size());
}
TEST(UniversalTersePrintTupleFieldsToStringsTestWithTr1, PrintsOneTuple) {
Strings result = UniversalTersePrintTupleFieldsToStrings(
::std::tr1::make_tuple(1));
ASSERT_EQ(1u, result.size());
EXPECT_EQ("1", result[0]);
}
TEST(UniversalTersePrintTupleFieldsToStringsTestWithTr1, PrintsTwoTuple) {
Strings result = UniversalTersePrintTupleFieldsToStrings(
::std::tr1::make_tuple(1, 'a'));
ASSERT_EQ(2u, result.size());
EXPECT_EQ("1", result[0]);
EXPECT_EQ("'a' (97, 0x61)", result[1]);
}
TEST(UniversalTersePrintTupleFieldsToStringsTestWithTr1, PrintsTersely) {
const int n = 1;
Strings result = UniversalTersePrintTupleFieldsToStrings(
::std::tr1::tuple<const int&, const char*>(n, "a"));
ASSERT_EQ(2u, result.size());
EXPECT_EQ("1", result[0]);
EXPECT_EQ("\"a\"", result[1]);
}
#endif // GTEST_HAS_TR1_TUPLE
#if GTEST_HAS_STD_TUPLE_
TEST(UniversalTersePrintTupleFieldsToStringsTestWithStd, PrintsEmptyTuple) {
Strings result = UniversalTersePrintTupleFieldsToStrings(::std::make_tuple());
EXPECT_EQ(0u, result.size());
@ -1727,8 +1606,6 @@ TEST(UniversalTersePrintTupleFieldsToStringsTestWithStd, PrintsTersely) {
EXPECT_EQ("\"a\"", result[1]);
}
#endif // GTEST_HAS_STD_TUPLE_
#if GTEST_HAS_ABSL
TEST(PrintOptionalTest, Basic) {

View File

@ -1,319 +0,0 @@
// Copyright 2007, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "gtest/internal/gtest-tuple.h"
#include <utility>
#include "gtest/gtest.h"
namespace {
using ::std::tr1::get;
using ::std::tr1::make_tuple;
using ::std::tr1::tuple;
using ::std::tr1::tuple_element;
using ::std::tr1::tuple_size;
using ::testing::StaticAssertTypeEq;
// Tests that tuple_element<K, tuple<T0, T1, ..., TN> >::type returns TK.
TEST(tuple_element_Test, ReturnsElementType) {
StaticAssertTypeEq<int, tuple_element<0, tuple<int, char> >::type>();
StaticAssertTypeEq<int&, tuple_element<1, tuple<double, int&> >::type>();
StaticAssertTypeEq<bool, tuple_element<2, tuple<double, int, bool> >::type>();
}
// Tests that tuple_size<T>::value gives the number of fields in tuple
// type T.
TEST(tuple_size_Test, ReturnsNumberOfFields) {
EXPECT_EQ(0, +tuple_size<tuple<> >::value);
EXPECT_EQ(1, +tuple_size<tuple<void*> >::value);
EXPECT_EQ(1, +tuple_size<tuple<char> >::value);
EXPECT_EQ(1, +(tuple_size<tuple<tuple<int, double> > >::value));
EXPECT_EQ(2, +(tuple_size<tuple<int&, const char> >::value));
EXPECT_EQ(3, +(tuple_size<tuple<char*, void, const bool&> >::value));
}
// Tests comparing a tuple with itself.
TEST(ComparisonTest, ComparesWithSelf) {
const tuple<int, char, bool> a(5, 'a', false);
EXPECT_TRUE(a == a);
EXPECT_FALSE(a != a);
}
// Tests comparing two tuples with the same value.
TEST(ComparisonTest, ComparesEqualTuples) {
const tuple<int, bool> a(5, true), b(5, true);
EXPECT_TRUE(a == b);
EXPECT_FALSE(a != b);
}
// Tests comparing two different tuples that have no reference fields.
TEST(ComparisonTest, ComparesUnequalTuplesWithoutReferenceFields) {
typedef tuple<const int, char> FooTuple;
const FooTuple a(0, 'x');
const FooTuple b(1, 'a');
EXPECT_TRUE(a != b);
EXPECT_FALSE(a == b);
const FooTuple c(1, 'b');
EXPECT_TRUE(b != c);
EXPECT_FALSE(b == c);
}
// Tests comparing two different tuples that have reference fields.
TEST(ComparisonTest, ComparesUnequalTuplesWithReferenceFields) {
typedef tuple<int&, const char&> FooTuple;
int i = 5;
const char ch = 'a';
const FooTuple a(i, ch);
int j = 6;
const FooTuple b(j, ch);
EXPECT_TRUE(a != b);
EXPECT_FALSE(a == b);
j = 5;
const char ch2 = 'b';
const FooTuple c(j, ch2);
EXPECT_TRUE(b != c);
EXPECT_FALSE(b == c);
}
// Tests that a tuple field with a reference type is an alias of the
// variable it's supposed to reference.
TEST(ReferenceFieldTest, IsAliasOfReferencedVariable) {
int n = 0;
tuple<bool, int&> t(true, n);
n = 1;
EXPECT_EQ(n, get<1>(t))
<< "Changing a underlying variable should update the reference field.";
// Makes sure that the implementation doesn't do anything funny with
// the & operator for the return type of get<>().
EXPECT_EQ(&n, &(get<1>(t)))
<< "The address of a reference field should equal the address of "
<< "the underlying variable.";
get<1>(t) = 2;
EXPECT_EQ(2, n)
<< "Changing a reference field should update the underlying variable.";
}
// Tests that tuple's default constructor default initializes each field.
// This test needs to compile without generating warnings.
TEST(TupleConstructorTest, DefaultConstructorDefaultInitializesEachField) {
// The TR1 report requires that tuple's default constructor default
// initializes each field, even if it's a primitive type. If the
// implementation forgets to do this, this test will catch it by
// generating warnings about using uninitialized variables (assuming
// a decent compiler).
tuple<> empty;
tuple<int> a1, b1;
b1 = a1;
EXPECT_EQ(0, get<0>(b1));
tuple<int, double> a2, b2;
b2 = a2;
EXPECT_EQ(0, get<0>(b2));
EXPECT_EQ(0.0, get<1>(b2));
tuple<double, char, bool*> a3, b3;
b3 = a3;
EXPECT_EQ(0.0, get<0>(b3));
EXPECT_EQ('\0', get<1>(b3));
EXPECT_TRUE(get<2>(b3) == nullptr);
tuple<int, int, int, int, int, int, int, int, int, int> a10, b10;
b10 = a10;
EXPECT_EQ(0, get<0>(b10));
EXPECT_EQ(0, get<1>(b10));
EXPECT_EQ(0, get<2>(b10));
EXPECT_EQ(0, get<3>(b10));
EXPECT_EQ(0, get<4>(b10));
EXPECT_EQ(0, get<5>(b10));
EXPECT_EQ(0, get<6>(b10));
EXPECT_EQ(0, get<7>(b10));
EXPECT_EQ(0, get<8>(b10));
EXPECT_EQ(0, get<9>(b10));
}
// Tests constructing a tuple from its fields.
TEST(TupleConstructorTest, ConstructsFromFields) {
int n = 1;
// Reference field.
tuple<int&> a(n);
EXPECT_EQ(&n, &(get<0>(a)));
// Non-reference fields.
tuple<int, char> b(5, 'a');
EXPECT_EQ(5, get<0>(b));
EXPECT_EQ('a', get<1>(b));
// Const reference field.
const int m = 2;
tuple<bool, const int&> c(true, m);
EXPECT_TRUE(get<0>(c));
EXPECT_EQ(&m, &(get<1>(c)));
}
// Tests tuple's copy constructor.
TEST(TupleConstructorTest, CopyConstructor) {
tuple<double, bool> a(0.0, true);
tuple<double, bool> b(a);
EXPECT_DOUBLE_EQ(0.0, get<0>(b));
EXPECT_TRUE(get<1>(b));
}
// Tests constructing a tuple from another tuple that has a compatible
// but different type.
TEST(TupleConstructorTest, ConstructsFromDifferentTupleType) {
tuple<int, int, char> a(0, 1, 'a');
tuple<double, long, int> b(a);
EXPECT_DOUBLE_EQ(0.0, get<0>(b));
EXPECT_EQ(1, get<1>(b));
EXPECT_EQ('a', get<2>(b));
}
// Tests constructing a 2-tuple from an std::pair.
TEST(TupleConstructorTest, ConstructsFromPair) {
::std::pair<int, char> a(1, 'a');
tuple<int, char> b(a);
tuple<int, const char&> c(a);
}
// Tests assigning a tuple to another tuple with the same type.
TEST(TupleAssignmentTest, AssignsToSameTupleType) {
const tuple<int, long> a(5, 7L);
tuple<int, long> b;
b = a;
EXPECT_EQ(5, get<0>(b));
EXPECT_EQ(7L, get<1>(b));
}
// Tests assigning a tuple to another tuple with a different but
// compatible type.
TEST(TupleAssignmentTest, AssignsToDifferentTupleType) {
const tuple<int, long, bool> a(1, 7L, true);
tuple<long, int, bool> b;
b = a;
EXPECT_EQ(1L, get<0>(b));
EXPECT_EQ(7, get<1>(b));
EXPECT_TRUE(get<2>(b));
}
// Tests assigning an std::pair to a 2-tuple.
TEST(TupleAssignmentTest, AssignsFromPair) {
const ::std::pair<int, bool> a(5, true);
tuple<int, bool> b;
b = a;
EXPECT_EQ(5, get<0>(b));
EXPECT_TRUE(get<1>(b));
tuple<long, bool> c;
c = a;
EXPECT_EQ(5L, get<0>(c));
EXPECT_TRUE(get<1>(c));
}
// A fixture for testing big tuples.
class BigTupleTest : public testing::Test {
protected:
typedef tuple<int, int, int, int, int, int, int, int, int, int> BigTuple;
BigTupleTest() :
a_(1, 0, 0, 0, 0, 0, 0, 0, 0, 2),
b_(1, 0, 0, 0, 0, 0, 0, 0, 0, 3) {}
BigTuple a_, b_;
};
// Tests constructing big tuples.
TEST_F(BigTupleTest, Construction) {
BigTuple a;
BigTuple b(b_);
}
// Tests that get<N>(t) returns the N-th (0-based) field of tuple t.
TEST_F(BigTupleTest, get) {
EXPECT_EQ(1, get<0>(a_));
EXPECT_EQ(2, get<9>(a_));
// Tests that get() works on a const tuple too.
const BigTuple a(a_);
EXPECT_EQ(1, get<0>(a));
EXPECT_EQ(2, get<9>(a));
}
// Tests comparing big tuples.
TEST_F(BigTupleTest, Comparisons) {
EXPECT_TRUE(a_ == a_);
EXPECT_FALSE(a_ != a_);
EXPECT_TRUE(a_ != b_);
EXPECT_FALSE(a_ == b_);
}
TEST(MakeTupleTest, WorksForScalarTypes) {
tuple<bool, int> a;
a = make_tuple(true, 5);
EXPECT_TRUE(get<0>(a));
EXPECT_EQ(5, get<1>(a));
tuple<char, int, long> b;
b = make_tuple('a', 'b', 5);
EXPECT_EQ('a', get<0>(b));
EXPECT_EQ('b', get<1>(b));
EXPECT_EQ(5, get<2>(b));
}
TEST(MakeTupleTest, WorksForPointers) {
int a[] = { 1, 2, 3, 4 };
const char* const str = "hi";
int* const p = a;
tuple<const char*, int*> t;
t = make_tuple(str, p);
EXPECT_EQ(str, get<0>(t));
EXPECT_EQ(p, get<1>(t));
}
} // namespace