Update gmock and gtest.
(Hoping to pick up a clang-related bug fix.) Review URL: http://codereview.chromium.org/521012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35352 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
DEPS
testing
README.chromium
gmock
CONTRIBUTORSMakefile.am
include
gmock
gmock-actions.hgmock-generated-actions.hgmock-generated-actions.h.pumpgmock-generated-function-mockers.hgmock-generated-function-mockers.h.pumpgmock-generated-matchers.hgmock-generated-matchers.h.pumpgmock-generated-nice-strict.hgmock-generated-nice-strict.h.pumpgmock-matchers.hgmock-more-actions.hgmock-printers.hgmock-spec-builders.h
internal
msvc
scripts
src
test
gmock-actions_test.ccgmock-cardinalities_test.ccgmock-generated-actions_test.ccgmock-generated-function-mockers_test.ccgmock-generated-matchers_test.ccgmock-internal-utils_test.ccgmock-matchers_test.ccgmock-more-actions_test.ccgmock-nice-strict_test.ccgmock-port_test.ccgmock-printers_test.ccgmock-spec-builders_test.ccgmock_leak_test.pygmock_leak_test_.ccgmock_link_test.hgmock_output_test.pygmock_output_test_.ccgmock_output_test_golden.txtgmock_test_utils.py
2
DEPS
2
DEPS
@ -21,7 +21,7 @@ deps = {
|
||||
"http://open-vcdiff.googlecode.com/svn/trunk@28",
|
||||
|
||||
"src/testing/gtest":
|
||||
"http://googletest.googlecode.com/svn/trunk@336",
|
||||
"http://googletest.googlecode.com/svn/trunk@359",
|
||||
|
||||
"src/third_party/WebKit":
|
||||
"/trunk/deps/third_party/WebKit@33467",
|
||||
|
@ -1,7 +1,8 @@
|
||||
We include a snapshot of gmock from http://googlemock.googlecode.com/svn/trunk
|
||||
with chromium.patch applied.
|
||||
We include a snapshot of gmock from http://googlemock.googlecode.com/svn/trunk.
|
||||
(Why not pull from it directly via DEPS? Because it uses svn:externals, which
|
||||
confuses gclient.)
|
||||
|
||||
Current revision: 222
|
||||
Current revision: 254
|
||||
|
||||
|
||||
-- HOW TO USE --
|
||||
@ -21,11 +22,6 @@ In particular, the "For Dummies" guide is a good place to start. The
|
||||
|
||||
-- RECREATING PACKAGE --
|
||||
|
||||
Starting with r173, gmock began distributing a pared down version of tr1 tuple
|
||||
that can be used on compilers without TR1. This means that we will no longer
|
||||
need TR1 or boost on windows.
|
||||
|
||||
Recreating this package is now just exporting the wanted revision.
|
||||
Example:
|
||||
|
||||
svn export --ignore-externals \
|
||||
|
@ -31,6 +31,7 @@ Paneendra Ba <paneendra@google.com>
|
||||
Paul Menage <menage@google.com>
|
||||
Piotr Kaminski <piotrk@google.com>
|
||||
Russ Rufer <russ@pentad.com>
|
||||
Sverre Sundsdal <sundsdal@gmail.com>
|
||||
Takeshi Yoshino <tyoshino@google.com>
|
||||
Vadim Berman <vadimb@google.com>
|
||||
Vlad Losev <vladl@google.com>
|
||||
|
@ -19,12 +19,7 @@ AM_CPPFLAGS = $(GTEST_CPPFLAGS) -I$(srcdir)/include
|
||||
# Build rules for libraries.
|
||||
lib_LTLIBRARIES = lib/libgmock.la lib/libgmock_main.la
|
||||
|
||||
lib_libgmock_la_SOURCES = src/gmock.cc \
|
||||
src/gmock-cardinalities.cc \
|
||||
src/gmock-internal-utils.cc \
|
||||
src/gmock-matchers.cc \
|
||||
src/gmock-printers.cc \
|
||||
src/gmock-spec-builders.cc
|
||||
lib_libgmock_la_SOURCES = src/gmock-all.cc
|
||||
|
||||
pkginclude_HEADERS = include/gmock/gmock.h \
|
||||
include/gmock/gmock-actions.h \
|
||||
@ -54,51 +49,18 @@ lib_libgmock_main_la_LIBADD = lib/libgmock.la
|
||||
# check_PROGRAMS -- Programs built by "make check" but not necessarily run
|
||||
|
||||
TESTS=
|
||||
TESTS_ENVIRONMENT = GMOCK_SOURCE_DIR="$(srcdir)/test" \
|
||||
GMOCK_BUILD_DIR="$(top_builddir)/test"
|
||||
check_PROGRAMS=
|
||||
AM_LDFLAGS = $(GTEST_LDFLAGS)
|
||||
|
||||
TESTS += test/gmock-actions_test
|
||||
check_PROGRAMS += test/gmock-actions_test
|
||||
test_gmock_actions_test_SOURCES = test/gmock-actions_test.cc
|
||||
test_gmock_actions_test_LDADD = $(GTEST_LIBS) lib/libgmock_main.la
|
||||
|
||||
TESTS += test/gmock-cardinalities_test
|
||||
check_PROGRAMS += test/gmock-cardinalities_test
|
||||
test_gmock_cardinalities_test_SOURCES = test/gmock-cardinalities_test.cc
|
||||
test_gmock_cardinalities_test_LDADD = $(GTEST_LIBS) lib/libgmock_main.la
|
||||
|
||||
TESTS += test/gmock-generated-actions_test
|
||||
check_PROGRAMS += test/gmock-generated-actions_test
|
||||
test_gmock_generated_actions_test_SOURCES = test/gmock-generated-actions_test.cc
|
||||
test_gmock_generated_actions_test_LDADD = $(GTEST_LIBS) lib/libgmock_main.la
|
||||
|
||||
TESTS += test/gmock-generated-function-mockers_test
|
||||
check_PROGRAMS += test/gmock-generated-function-mockers_test
|
||||
test_gmock_generated_function_mockers_test_SOURCES = \
|
||||
test/gmock-generated-function-mockers_test.cc
|
||||
test_gmock_generated_function_mockers_test_LDADD = $(GTEST_LIBS) \
|
||||
lib/libgmock_main.la
|
||||
|
||||
TESTS += test/gmock-generated-internal-utils_test
|
||||
check_PROGRAMS += test/gmock-generated-internal-utils_test
|
||||
test_gmock_generated_internal_utils_test_SOURCES = \
|
||||
test/gmock-generated-internal-utils_test.cc
|
||||
test_gmock_generated_internal_utils_test_LDADD = $(GTEST_LIBS) \
|
||||
lib/libgmock_main.la
|
||||
|
||||
TESTS += test/gmock-generated-matchers_test
|
||||
check_PROGRAMS += test/gmock-generated-matchers_test
|
||||
test_gmock_generated_matchers_test_SOURCES = \
|
||||
test/gmock-generated-matchers_test.cc
|
||||
test_gmock_generated_matchers_test_LDADD = $(GTEST_LIBS) lib/libgmock_main.la
|
||||
|
||||
TESTS += test/gmock-internal-utils_test
|
||||
check_PROGRAMS += test/gmock-internal-utils_test
|
||||
test_gmock_internal_utils_test_SOURCES = test/gmock-internal-utils_test.cc
|
||||
test_gmock_internal_utils_test_LDADD = $(GTEST_LIBS) lib/libgmock_main.la
|
||||
# This exercises all major components of Google Mock. It also
|
||||
# verifies that libgmock works.
|
||||
TESTS += test/gmock-spec-builders_test
|
||||
check_PROGRAMS += test/gmock-spec-builders_test
|
||||
test_gmock_spec_builders_test_SOURCES = test/gmock-spec-builders_test.cc
|
||||
test_gmock_spec_builders_test_LDADD = $(GTEST_LIBS) lib/libgmock.la
|
||||
|
||||
# This tests using Google Mock in multiple translation units. It also
|
||||
# verifies that libgmock_main works.
|
||||
TESTS += test/gmock_link_test
|
||||
check_PROGRAMS += test/gmock_link_test
|
||||
test_gmock_link_test_SOURCES = test/gmock_link_test.cc \
|
||||
@ -106,99 +68,46 @@ test_gmock_link_test_SOURCES = test/gmock_link_test.cc \
|
||||
test/gmock_link_test.h
|
||||
test_gmock_link_test_LDADD = $(GTEST_LIBS) lib/libgmock_main.la
|
||||
|
||||
TESTS += test/gmock-matchers_test
|
||||
check_PROGRAMS += test/gmock-matchers_test
|
||||
test_gmock_matchers_test_SOURCES = test/gmock-matchers_test.cc
|
||||
test_gmock_matchers_test_LDADD = $(GTEST_LIBS) lib/libgmock_main.la
|
||||
# Google Mock source files that we don't compile directly.
|
||||
EXTRA_DIST += \
|
||||
src/gmock.cc \
|
||||
src/gmock-cardinalities.cc \
|
||||
src/gmock-internal-utils.cc \
|
||||
src/gmock-matchers.cc \
|
||||
src/gmock-printers.cc \
|
||||
src/gmock-spec-builders.cc
|
||||
|
||||
TESTS += test/gmock-more-actions_test
|
||||
check_PROGRAMS += test/gmock-more-actions_test
|
||||
test_gmock_more_actions_test_SOURCES = test/gmock-more-actions_test.cc
|
||||
test_gmock_more_actions_test_LDADD = $(GTEST_LIBS) lib/libgmock_main.la
|
||||
# C++ tests that we don't compile using autotools.
|
||||
EXTRA_DIST += \
|
||||
test/gmock_all_test.cc \
|
||||
test/gmock-actions_test.cc \
|
||||
test/gmock-cardinalities_test.cc \
|
||||
test/gmock-generated-actions_test.cc \
|
||||
test/gmock-generated-function-mockers_test.cc \
|
||||
test/gmock-generated-internal-utils_test.cc \
|
||||
test/gmock-generated-matchers_test.cc \
|
||||
test/gmock-internal-utils_test.cc \
|
||||
test/gmock-matchers_test.cc \
|
||||
test/gmock-more-actions_test.cc \
|
||||
test/gmock-nice-strict_test.cc \
|
||||
test/gmock-port_test.cc \
|
||||
test/gmock-printers_test.cc \
|
||||
test/gmock_test.cc
|
||||
|
||||
TESTS += test/gmock-nice-strict_test
|
||||
check_PROGRAMS += test/gmock-nice-strict_test
|
||||
test_gmock_nice_strict_test_SOURCES = test/gmock-nice-strict_test.cc
|
||||
test_gmock_nice_strict_test_LDADD = $(GTEST_LIBS) lib/libgmock_main.la
|
||||
|
||||
TESTS += test/gmock-port_test
|
||||
check_PROGRAMS += test/gmock-port_test
|
||||
test_gmock_port_test_SOURCES = test/gmock-port_test.cc
|
||||
test_gmock_port_test_LDADD = $(GTEST_LIBS) lib/libgmock_main.la
|
||||
|
||||
TESTS += test/gmock-printers_test
|
||||
check_PROGRAMS += test/gmock-printers_test
|
||||
test_gmock_printers_test_SOURCES = test/gmock-printers_test.cc
|
||||
test_gmock_printers_test_LDADD = $(GTEST_LIBS) lib/libgmock_main.la
|
||||
|
||||
TESTS += test/gmock-spec-builders_test
|
||||
check_PROGRAMS += test/gmock-spec-builders_test
|
||||
test_gmock_spec_builders_test_SOURCES = test/gmock-spec-builders_test.cc
|
||||
test_gmock_spec_builders_test_LDADD = $(GTEST_LIBS) lib/libgmock.la
|
||||
|
||||
TESTS += test/gmock_test
|
||||
check_PROGRAMS += test/gmock_test
|
||||
test_gmock_test_SOURCES = test/gmock_test.cc
|
||||
test_gmock_test_LDADD = $(GTEST_LIBS) lib/libgmock_main.la
|
||||
|
||||
# A sanity test for verifying that Google Mock works when RTTI is
|
||||
# disabled. We pick gmock-spec-builders_test.cc as it exercises all
|
||||
# components of Google Mock.
|
||||
TESTS += test/gmock_no_rtti_test
|
||||
check_PROGRAMS += test/gmock_no_rtti_test
|
||||
test_gmock_no_rtti_test_SOURCES = test/gmock-spec-builders_test.cc \
|
||||
src/gmock-all.cc
|
||||
test_gmock_no_rtti_test_CXXFLAGS = $(AM_CXXFLAGS) -fno-rtti -DGTEST_HAS_RTTI=0
|
||||
test_gmock_no_rtti_test_LDADD = $(GTEST_LIBS)
|
||||
|
||||
# A sanity test for verifying that Google Mock works with Google
|
||||
# Test's TR1 tuple implementation. We pick
|
||||
# gmock-spec-builders_test.cc as it exercises all components of Google
|
||||
# Mock.
|
||||
TESTS += test/gmock_use_own_tuple_test
|
||||
check_PROGRAMS += test/gmock_use_own_tuple_test
|
||||
test_gmock_use_own_tuple_test_SOURCES = test/gmock-spec-builders_test.cc \
|
||||
src/gmock-all.cc
|
||||
test_gmock_use_own_tuple_test_CXXFLAGS = \
|
||||
$(AM_CXXFLAGS) -DGTEST_USE_OWN_TR1_TUPLE=1
|
||||
test_gmock_use_own_tuple_test_LDADD = $(GTEST_LIBS)
|
||||
|
||||
# The following tests depend on the presence of a Python installation and are
|
||||
# keyed off of it. We only add them to the TESTS variable when a Python
|
||||
# interpreter is available. TODO(chandlerc@google.com): While we currently only
|
||||
# attempt to build and execute these tests if Autoconf has found Python v2.3 on
|
||||
# the system, we don't use the PYTHON variable it specified as the valid
|
||||
# interpreter. The problem is that TESTS_ENVIRONMENT is a global variable, and
|
||||
# thus we cannot distinguish between C++ unit tests and Python unit tests.
|
||||
dist_check_SCRIPTS =
|
||||
|
||||
# Python modules used by multiple Python tests below.
|
||||
dist_check_SCRIPTS += test/gmock_test_utils.py
|
||||
|
||||
check_PROGRAMS += test/gmock_leak_test_
|
||||
test_gmock_leak_test__SOURCES = test/gmock_leak_test_.cc
|
||||
test_gmock_leak_test__LDADD = $(GTEST_LIBS) lib/libgmock_main.la
|
||||
dist_check_SCRIPTS += test/gmock_leak_test.py
|
||||
|
||||
check_PROGRAMS += test/gmock_output_test_
|
||||
test_gmock_output_test__SOURCES = test/gmock_output_test_.cc
|
||||
test_gmock_output_test__LDADD = $(GTEST_LIBS) lib/libgmock_main.la
|
||||
dist_check_SCRIPTS += test/gmock_output_test.py
|
||||
EXTRA_DIST += test/gmock_output_test_golden.txt
|
||||
|
||||
# Enable all the python driven tests when we can run them.
|
||||
if HAVE_PYTHON
|
||||
TESTS += \
|
||||
test/gmock_leak_test.py \
|
||||
test/gmock_output_test.py
|
||||
endif
|
||||
# Python tests, which we don't run using autotools.
|
||||
EXTRA_DIST += \
|
||||
test/gmock_test_utils.py \
|
||||
test/gmock_leak_test_.cc \
|
||||
test/gmock_leak_test.py \
|
||||
test/gmock_output_test_.cc \
|
||||
test/gmock_output_test.py \
|
||||
test/gmock_output_test_golden.txt
|
||||
|
||||
# Nonstandard package files for distribution.
|
||||
EXTRA_DIST += \
|
||||
CHANGES \
|
||||
CONTRIBUTORS \
|
||||
make/Makefile \
|
||||
src/gmock-all.cc
|
||||
make/Makefile
|
||||
|
||||
# Pump scripts for generating Google Mock headers.
|
||||
# TODO(chandlerc@google.com): automate the generation of *.h from *.h.pump.
|
||||
@ -233,6 +142,5 @@ EXTRA_DIST += \
|
||||
msvc/gmock_config.vsprops \
|
||||
msvc/gmock_link_test.vcproj \
|
||||
msvc/gmock_main.vcproj \
|
||||
msvc/gmock_output_test_.vcproj \
|
||||
msvc/gmock-spec-builders_test.vcproj \
|
||||
msvc/gmock_test.vcproj
|
||||
|
@ -117,9 +117,7 @@ GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(void, ); // NOLINT
|
||||
#if GTEST_HAS_GLOBAL_STRING
|
||||
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(::string, "");
|
||||
#endif // GTEST_HAS_GLOBAL_STRING
|
||||
#if GTEST_HAS_STD_STRING
|
||||
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(::std::string, "");
|
||||
#endif // GTEST_HAS_STD_STRING
|
||||
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(bool, false);
|
||||
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned char, '\0');
|
||||
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed char, '\0');
|
||||
@ -270,6 +268,7 @@ class ActionInterface {
|
||||
|
||||
// Returns true iff this is the DoDefault() action.
|
||||
bool IsDoDefault() const { return is_do_default_; }
|
||||
|
||||
private:
|
||||
template <typename Function>
|
||||
friend class internal::MonomorphicDoDefaultActionImpl;
|
||||
@ -281,6 +280,8 @@ class ActionInterface {
|
||||
|
||||
// True iff this action is DoDefault().
|
||||
const bool is_do_default_;
|
||||
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(ActionInterface);
|
||||
};
|
||||
|
||||
// An Action<F> is a copyable and IMMUTABLE (except by assignment)
|
||||
@ -310,7 +311,7 @@ class Action {
|
||||
|
||||
// This constructor allows us to turn an Action<Func> object into an
|
||||
// Action<F>, as long as F's arguments can be implicitly converted
|
||||
// to Func's and Func's return type cann be implicitly converted to
|
||||
// to Func's and Func's return type can be implicitly converted to
|
||||
// F's.
|
||||
template <typename Func>
|
||||
explicit Action(const Action<Func>& action);
|
||||
@ -327,6 +328,7 @@ class Action {
|
||||
Result Perform(const ArgumentTuple& args) const {
|
||||
return impl_->Perform(args);
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename F1, typename F2>
|
||||
friend class internal::ActionAdaptor;
|
||||
@ -364,6 +366,7 @@ class PolymorphicAction {
|
||||
operator Action<F>() const {
|
||||
return Action<F>(new MonomorphicImpl<F>(impl_));
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename F>
|
||||
class MonomorphicImpl : public ActionInterface<F> {
|
||||
@ -379,9 +382,13 @@ class PolymorphicAction {
|
||||
|
||||
private:
|
||||
Impl impl_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(MonomorphicImpl);
|
||||
};
|
||||
|
||||
Impl impl_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(PolymorphicAction);
|
||||
};
|
||||
|
||||
// Creates an Action from its implementation and returns it. The
|
||||
@ -418,13 +425,37 @@ class ActionAdaptor : public ActionInterface<F1> {
|
||||
virtual Result Perform(const ArgumentTuple& args) {
|
||||
return impl_->Perform(args);
|
||||
}
|
||||
|
||||
private:
|
||||
const internal::linked_ptr<ActionInterface<F2> > impl_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(ActionAdaptor);
|
||||
};
|
||||
|
||||
// Implements the polymorphic Return(x) action, which can be used in
|
||||
// any function that returns the type of x, regardless of the argument
|
||||
// types.
|
||||
//
|
||||
// Note: The value passed into Return must be converted into
|
||||
// Function<F>::Result when this action is cast to Action<F> rather than
|
||||
// when that action is performed. This is important in scenarios like
|
||||
//
|
||||
// MOCK_METHOD1(Method, T(U));
|
||||
// ...
|
||||
// {
|
||||
// Foo foo;
|
||||
// X x(&foo);
|
||||
// EXPECT_CALL(mock, Method(_)).WillOnce(Return(x));
|
||||
// }
|
||||
//
|
||||
// In the example above the variable x holds reference to foo which leaves
|
||||
// scope and gets destroyed. If copying X just copies a reference to foo,
|
||||
// that copy will be left with a hanging reference. If conversion to T
|
||||
// makes a copy of foo, the above code is safe. To support that scenario, we
|
||||
// need to make sure that the type conversion happens inside the EXPECT_CALL
|
||||
// statement, and conversion of the result of Return to Action<T(U)> is a
|
||||
// good place for that.
|
||||
//
|
||||
template <typename R>
|
||||
class ReturnAction {
|
||||
public:
|
||||
@ -451,6 +482,7 @@ class ReturnAction {
|
||||
use_ReturnRef_instead_of_Return_to_return_a_reference);
|
||||
return Action<F>(new Impl<F>(value_));
|
||||
}
|
||||
|
||||
private:
|
||||
// Implements the Return(x) action for a particular function type F.
|
||||
template <typename F>
|
||||
@ -459,15 +491,29 @@ class ReturnAction {
|
||||
typedef typename Function<F>::Result Result;
|
||||
typedef typename Function<F>::ArgumentTuple ArgumentTuple;
|
||||
|
||||
explicit Impl(R value) : value_(value) {}
|
||||
// The implicit cast is necessary when Result has more than one
|
||||
// single-argument constructor (e.g. Result is std::vector<int>) and R
|
||||
// has a type conversion operator template. In that case, value_(value)
|
||||
// won't compile as the compiler doesn't known which constructor of
|
||||
// Result to call. implicit_cast forces the compiler to convert R to
|
||||
// Result without considering explicit constructors, thus resolving the
|
||||
// ambiguity. value_ is then initialized using its copy constructor.
|
||||
explicit Impl(R value)
|
||||
: value_(::testing::internal::implicit_cast<Result>(value)) {}
|
||||
|
||||
virtual Result Perform(const ArgumentTuple&) { return value_; }
|
||||
|
||||
private:
|
||||
R value_;
|
||||
GMOCK_COMPILE_ASSERT_(!internal::is_reference<Result>::value,
|
||||
Result_cannot_be_a_reference_type);
|
||||
Result value_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(Impl);
|
||||
};
|
||||
|
||||
R value_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(ReturnAction);
|
||||
};
|
||||
|
||||
// Implements the ReturnNull() action.
|
||||
@ -513,6 +559,7 @@ class ReturnRefAction {
|
||||
use_Return_instead_of_ReturnRef_to_return_a_value);
|
||||
return Action<F>(new Impl<F>(ref_));
|
||||
}
|
||||
|
||||
private:
|
||||
// Implements the ReturnRef(x) action for a particular function type F.
|
||||
template <typename F>
|
||||
@ -526,11 +573,16 @@ class ReturnRefAction {
|
||||
virtual Result Perform(const ArgumentTuple&) {
|
||||
return ref_;
|
||||
}
|
||||
|
||||
private:
|
||||
T& ref_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(Impl);
|
||||
};
|
||||
|
||||
T& ref_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(ReturnRefAction);
|
||||
};
|
||||
|
||||
// Implements the DoDefault() action for a particular function type F.
|
||||
@ -582,9 +634,12 @@ class AssignAction {
|
||||
void Perform(const ArgumentTuple& /* args */) const {
|
||||
*ptr_ = value_;
|
||||
}
|
||||
|
||||
private:
|
||||
T1* const ptr_;
|
||||
const T2 value_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(AssignAction);
|
||||
};
|
||||
|
||||
#if !GTEST_OS_WINDOWS_MOBILE
|
||||
@ -602,9 +657,12 @@ class SetErrnoAndReturnAction {
|
||||
errno = errno_;
|
||||
return result_;
|
||||
}
|
||||
|
||||
private:
|
||||
const int errno_;
|
||||
const T result_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(SetErrnoAndReturnAction);
|
||||
};
|
||||
|
||||
#endif // !GTEST_OS_WINDOWS_MOBILE
|
||||
@ -628,6 +686,8 @@ class SetArgumentPointeeAction {
|
||||
|
||||
private:
|
||||
const A value_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(SetArgumentPointeeAction);
|
||||
};
|
||||
|
||||
template <size_t N, typename Proto>
|
||||
@ -646,8 +706,11 @@ class SetArgumentPointeeAction<N, Proto, true> {
|
||||
CompileAssertTypesEqual<void, Result>();
|
||||
::std::tr1::get<N>(args)->CopyFrom(*proto_);
|
||||
}
|
||||
|
||||
private:
|
||||
const internal::linked_ptr<Proto> proto_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(SetArgumentPointeeAction);
|
||||
};
|
||||
|
||||
// Implements the InvokeWithoutArgs(f) action. The template argument
|
||||
@ -667,8 +730,11 @@ class InvokeWithoutArgsAction {
|
||||
// compatible with f.
|
||||
template <typename Result, typename ArgumentTuple>
|
||||
Result Perform(const ArgumentTuple&) { return function_impl_(); }
|
||||
|
||||
private:
|
||||
FunctionImpl function_impl_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(InvokeWithoutArgsAction);
|
||||
};
|
||||
|
||||
// Implements the InvokeWithoutArgs(object_ptr, &Class::Method) action.
|
||||
@ -682,9 +748,12 @@ class InvokeMethodWithoutArgsAction {
|
||||
Result Perform(const ArgumentTuple&) const {
|
||||
return (obj_ptr_->*method_ptr_)();
|
||||
}
|
||||
|
||||
private:
|
||||
Class* const obj_ptr_;
|
||||
const MethodPtr method_ptr_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(InvokeMethodWithoutArgsAction);
|
||||
};
|
||||
|
||||
// Implements the IgnoreResult(action) action.
|
||||
@ -710,6 +779,7 @@ class IgnoreResultAction {
|
||||
|
||||
return Action<F>(new Impl<F>(action_));
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename F>
|
||||
class Impl : public ActionInterface<F> {
|
||||
@ -731,9 +801,13 @@ class IgnoreResultAction {
|
||||
OriginalFunction;
|
||||
|
||||
const Action<OriginalFunction> action_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(Impl);
|
||||
};
|
||||
|
||||
const A action_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(IgnoreResultAction);
|
||||
};
|
||||
|
||||
// A ReferenceWrapper<T> object represents a reference to type T,
|
||||
@ -798,10 +872,14 @@ class DoBothAction {
|
||||
private:
|
||||
const Action<VoidResult> action1_;
|
||||
const Action<F> action2_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(Impl);
|
||||
};
|
||||
|
||||
Action1 action1_;
|
||||
Action2 action2_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(DoBothAction);
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
|
@ -615,6 +615,8 @@ class WithArgsAction {
|
||||
};
|
||||
|
||||
const InnerAction action_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(WithArgsAction);
|
||||
};
|
||||
|
||||
// A macro from the ACTION* family (defined later in this file)
|
||||
@ -1406,12 +1408,16 @@ DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
|
||||
arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
|
||||
arg9_type arg9) const;\
|
||||
GMOCK_INTERNAL_DEFN_##value_params\
|
||||
private:\
|
||||
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
|
||||
};\
|
||||
template <typename F> operator ::testing::Action<F>() const {\
|
||||
return ::testing::Action<F>(\
|
||||
new gmock_Impl<F>(GMOCK_INTERNAL_LIST_##value_params));\
|
||||
}\
|
||||
GMOCK_INTERNAL_DEFN_##value_params\
|
||||
private:\
|
||||
GTEST_DISALLOW_ASSIGN_(GMOCK_ACTION_CLASS_(name, value_params));\
|
||||
};\
|
||||
template <GMOCK_INTERNAL_DECL_##template_params\
|
||||
GMOCK_INTERNAL_DECL_TYPE_##value_params>\
|
||||
@ -1462,10 +1468,14 @@ DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
|
||||
arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
|
||||
arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
|
||||
arg9_type arg9) const;\
|
||||
private:\
|
||||
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
|
||||
};\
|
||||
template <typename F> operator ::testing::Action<F>() const {\
|
||||
return ::testing::Action<F>(new gmock_Impl<F>());\
|
||||
}\
|
||||
private:\
|
||||
GTEST_DISALLOW_ASSIGN_(name##Action);\
|
||||
};\
|
||||
inline name##Action name() {\
|
||||
return name##Action();\
|
||||
@ -1505,11 +1515,15 @@ DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
|
||||
arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
|
||||
arg9_type arg9) const;\
|
||||
p0##_type p0;\
|
||||
private:\
|
||||
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
|
||||
};\
|
||||
template <typename F> operator ::testing::Action<F>() const {\
|
||||
return ::testing::Action<F>(new gmock_Impl<F>(p0));\
|
||||
}\
|
||||
p0##_type p0;\
|
||||
private:\
|
||||
GTEST_DISALLOW_ASSIGN_(name##ActionP);\
|
||||
};\
|
||||
template <typename p0##_type>\
|
||||
inline name##ActionP<p0##_type> name(p0##_type p0) {\
|
||||
@ -1554,12 +1568,16 @@ DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
|
||||
arg9_type arg9) const;\
|
||||
p0##_type p0;\
|
||||
p1##_type p1;\
|
||||
private:\
|
||||
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
|
||||
};\
|
||||
template <typename F> operator ::testing::Action<F>() const {\
|
||||
return ::testing::Action<F>(new gmock_Impl<F>(p0, p1));\
|
||||
}\
|
||||
p0##_type p0;\
|
||||
p1##_type p1;\
|
||||
private:\
|
||||
GTEST_DISALLOW_ASSIGN_(name##ActionP2);\
|
||||
};\
|
||||
template <typename p0##_type, typename p1##_type>\
|
||||
inline name##ActionP2<p0##_type, p1##_type> name(p0##_type p0, \
|
||||
@ -1606,6 +1624,8 @@ DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
|
||||
p0##_type p0;\
|
||||
p1##_type p1;\
|
||||
p2##_type p2;\
|
||||
private:\
|
||||
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
|
||||
};\
|
||||
template <typename F> operator ::testing::Action<F>() const {\
|
||||
return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2));\
|
||||
@ -1613,6 +1633,8 @@ DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
|
||||
p0##_type p0;\
|
||||
p1##_type p1;\
|
||||
p2##_type p2;\
|
||||
private:\
|
||||
GTEST_DISALLOW_ASSIGN_(name##ActionP3);\
|
||||
};\
|
||||
template <typename p0##_type, typename p1##_type, typename p2##_type>\
|
||||
inline name##ActionP3<p0##_type, p1##_type, p2##_type> name(p0##_type p0, \
|
||||
@ -1664,6 +1686,8 @@ DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
|
||||
p1##_type p1;\
|
||||
p2##_type p2;\
|
||||
p3##_type p3;\
|
||||
private:\
|
||||
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
|
||||
};\
|
||||
template <typename F> operator ::testing::Action<F>() const {\
|
||||
return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3));\
|
||||
@ -1672,6 +1696,8 @@ DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
|
||||
p1##_type p1;\
|
||||
p2##_type p2;\
|
||||
p3##_type p3;\
|
||||
private:\
|
||||
GTEST_DISALLOW_ASSIGN_(name##ActionP4);\
|
||||
};\
|
||||
template <typename p0##_type, typename p1##_type, typename p2##_type, \
|
||||
typename p3##_type>\
|
||||
@ -1729,6 +1755,8 @@ DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
|
||||
p2##_type p2;\
|
||||
p3##_type p3;\
|
||||
p4##_type p4;\
|
||||
private:\
|
||||
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
|
||||
};\
|
||||
template <typename F> operator ::testing::Action<F>() const {\
|
||||
return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4));\
|
||||
@ -1738,6 +1766,8 @@ DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
|
||||
p2##_type p2;\
|
||||
p3##_type p3;\
|
||||
p4##_type p4;\
|
||||
private:\
|
||||
GTEST_DISALLOW_ASSIGN_(name##ActionP5);\
|
||||
};\
|
||||
template <typename p0##_type, typename p1##_type, typename p2##_type, \
|
||||
typename p3##_type, typename p4##_type>\
|
||||
@ -1797,6 +1827,8 @@ DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
|
||||
p3##_type p3;\
|
||||
p4##_type p4;\
|
||||
p5##_type p5;\
|
||||
private:\
|
||||
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
|
||||
};\
|
||||
template <typename F> operator ::testing::Action<F>() const {\
|
||||
return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5));\
|
||||
@ -1807,6 +1839,8 @@ DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
|
||||
p3##_type p3;\
|
||||
p4##_type p4;\
|
||||
p5##_type p5;\
|
||||
private:\
|
||||
GTEST_DISALLOW_ASSIGN_(name##ActionP6);\
|
||||
};\
|
||||
template <typename p0##_type, typename p1##_type, typename p2##_type, \
|
||||
typename p3##_type, typename p4##_type, typename p5##_type>\
|
||||
@ -1869,6 +1903,8 @@ DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
|
||||
p4##_type p4;\
|
||||
p5##_type p5;\
|
||||
p6##_type p6;\
|
||||
private:\
|
||||
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
|
||||
};\
|
||||
template <typename F> operator ::testing::Action<F>() const {\
|
||||
return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5, \
|
||||
@ -1881,6 +1917,8 @@ DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
|
||||
p4##_type p4;\
|
||||
p5##_type p5;\
|
||||
p6##_type p6;\
|
||||
private:\
|
||||
GTEST_DISALLOW_ASSIGN_(name##ActionP7);\
|
||||
};\
|
||||
template <typename p0##_type, typename p1##_type, typename p2##_type, \
|
||||
typename p3##_type, typename p4##_type, typename p5##_type, \
|
||||
@ -1949,6 +1987,8 @@ DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
|
||||
p5##_type p5;\
|
||||
p6##_type p6;\
|
||||
p7##_type p7;\
|
||||
private:\
|
||||
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
|
||||
};\
|
||||
template <typename F> operator ::testing::Action<F>() const {\
|
||||
return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5, \
|
||||
@ -1962,6 +2002,8 @@ DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
|
||||
p5##_type p5;\
|
||||
p6##_type p6;\
|
||||
p7##_type p7;\
|
||||
private:\
|
||||
GTEST_DISALLOW_ASSIGN_(name##ActionP8);\
|
||||
};\
|
||||
template <typename p0##_type, typename p1##_type, typename p2##_type, \
|
||||
typename p3##_type, typename p4##_type, typename p5##_type, \
|
||||
@ -2034,6 +2076,8 @@ DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
|
||||
p6##_type p6;\
|
||||
p7##_type p7;\
|
||||
p8##_type p8;\
|
||||
private:\
|
||||
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
|
||||
};\
|
||||
template <typename F> operator ::testing::Action<F>() const {\
|
||||
return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5, \
|
||||
@ -2048,6 +2092,8 @@ DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
|
||||
p6##_type p6;\
|
||||
p7##_type p7;\
|
||||
p8##_type p8;\
|
||||
private:\
|
||||
GTEST_DISALLOW_ASSIGN_(name##ActionP9);\
|
||||
};\
|
||||
template <typename p0##_type, typename p1##_type, typename p2##_type, \
|
||||
typename p3##_type, typename p4##_type, typename p5##_type, \
|
||||
@ -2123,6 +2169,8 @@ DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
|
||||
p7##_type p7;\
|
||||
p8##_type p8;\
|
||||
p9##_type p9;\
|
||||
private:\
|
||||
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
|
||||
};\
|
||||
template <typename F> operator ::testing::Action<F>() const {\
|
||||
return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5, \
|
||||
@ -2138,6 +2186,8 @@ DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
|
||||
p7##_type p7;\
|
||||
p8##_type p8;\
|
||||
p9##_type p9;\
|
||||
private:\
|
||||
GTEST_DISALLOW_ASSIGN_(name##ActionP10);\
|
||||
};\
|
||||
template <typename p0##_type, typename p1##_type, typename p2##_type, \
|
||||
typename p3##_type, typename p4##_type, typename p5##_type, \
|
||||
@ -2172,6 +2222,16 @@ DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
|
||||
// updated.
|
||||
namespace testing {
|
||||
|
||||
// The ACTION*() macros trigger warning C4100 (unreferenced formal
|
||||
// parameter) in MSVC with -W4. Unfortunately they cannot be fixed in
|
||||
// the macro definition, as the warnings are generated when the macro
|
||||
// is expanded and macro expansion cannot contain #pragma. Therefore
|
||||
// we suppress them here.
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4100)
|
||||
#endif
|
||||
|
||||
// Various overloads for InvokeArgument<N>().
|
||||
//
|
||||
// The InvokeArgument<N>(a1, a2, ..., a_k) action invokes the N-th
|
||||
@ -2350,6 +2410,10 @@ ACTION_TEMPLATE(ReturnNew,
|
||||
return new T(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
} // namespace testing
|
||||
|
||||
#endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
|
||||
|
@ -228,6 +228,8 @@ class WithArgsAction {
|
||||
};
|
||||
|
||||
const InnerAction action_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(WithArgsAction);
|
||||
};
|
||||
|
||||
// A macro from the ACTION* family (defined later in this file)
|
||||
@ -630,12 +632,16 @@ $range k 0..n-1
|
||||
return_type gmock_PerformImpl(const args_type& args[[]]
|
||||
$for k [[, arg$k[[]]_type arg$k]]) const;\
|
||||
GMOCK_INTERNAL_DEFN_##value_params\
|
||||
private:\
|
||||
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
|
||||
};\
|
||||
template <typename F> operator ::testing::Action<F>() const {\
|
||||
return ::testing::Action<F>(\
|
||||
new gmock_Impl<F>(GMOCK_INTERNAL_LIST_##value_params));\
|
||||
}\
|
||||
GMOCK_INTERNAL_DEFN_##value_params\
|
||||
private:\
|
||||
GTEST_DISALLOW_ASSIGN_(GMOCK_ACTION_CLASS_(name, value_params));\
|
||||
};\
|
||||
template <GMOCK_INTERNAL_DECL_##template_params\
|
||||
GMOCK_INTERNAL_DECL_TYPE_##value_params>\
|
||||
@ -712,10 +718,14 @@ $var macro_name = [[$if i==0 [[ACTION]] $elif i==1 [[ACTION_P]]
|
||||
template <$typename_arg_types>\
|
||||
return_type gmock_PerformImpl(const args_type& args, [[]]
|
||||
$arg_types_and_names) const;\$param_field_decls
|
||||
private:\
|
||||
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
|
||||
};\
|
||||
template <typename F> operator ::testing::Action<F>() const {\
|
||||
return ::testing::Action<F>(new gmock_Impl<F>($params));\
|
||||
}\$param_field_decls2
|
||||
private:\
|
||||
GTEST_DISALLOW_ASSIGN_($class_name);\
|
||||
};\$template
|
||||
inline $class_name$param_types name($param_types_and_names) {\
|
||||
return $class_name$param_types($params);\
|
||||
@ -735,6 +745,16 @@ $$ // show up in the generated code.
|
||||
// updated.
|
||||
namespace testing {
|
||||
|
||||
// The ACTION*() macros trigger warning C4100 (unreferenced formal
|
||||
// parameter) in MSVC with -W4. Unfortunately they cannot be fixed in
|
||||
// the macro definition, as the warnings are generated when the macro
|
||||
// is expanded and macro expansion cannot contain #pragma. Therefore
|
||||
// we suppress them here.
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4100)
|
||||
#endif
|
||||
|
||||
// Various overloads for InvokeArgument<N>().
|
||||
//
|
||||
// The InvokeArgument<N>(a1, a2, ..., a_k) action invokes the N-th
|
||||
@ -796,6 +816,10 @@ ACTION_TEMPLATE(ReturnNew,
|
||||
|
||||
]]
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
} // namespace testing
|
||||
|
||||
#endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
|
||||
|
@ -42,10 +42,6 @@
|
||||
#include <gmock/internal/gmock-internal-utils.h>
|
||||
|
||||
namespace testing {
|
||||
|
||||
template <typename F>
|
||||
class MockSpec;
|
||||
|
||||
namespace internal {
|
||||
|
||||
template <typename F>
|
||||
@ -71,7 +67,11 @@ class FunctionMocker<R()> : public
|
||||
}
|
||||
|
||||
R Invoke() {
|
||||
return InvokeWith(ArgumentTuple());
|
||||
// Even though gcc and MSVC don't enforce it, 'this->' is required
|
||||
// by the C++ standard [14.6.4] here, as the base class type is
|
||||
// dependent on the template argument (and thus shouldn't be
|
||||
// looked into when resolving InvokeWith).
|
||||
return this->InvokeWith(ArgumentTuple());
|
||||
}
|
||||
};
|
||||
|
||||
@ -88,7 +88,11 @@ class FunctionMocker<R(A1)> : public
|
||||
}
|
||||
|
||||
R Invoke(A1 a1) {
|
||||
return InvokeWith(ArgumentTuple(a1));
|
||||
// Even though gcc and MSVC don't enforce it, 'this->' is required
|
||||
// by the C++ standard [14.6.4] here, as the base class type is
|
||||
// dependent on the template argument (and thus shouldn't be
|
||||
// looked into when resolving InvokeWith).
|
||||
return this->InvokeWith(ArgumentTuple(a1));
|
||||
}
|
||||
};
|
||||
|
||||
@ -105,7 +109,11 @@ class FunctionMocker<R(A1, A2)> : public
|
||||
}
|
||||
|
||||
R Invoke(A1 a1, A2 a2) {
|
||||
return InvokeWith(ArgumentTuple(a1, a2));
|
||||
// Even though gcc and MSVC don't enforce it, 'this->' is required
|
||||
// by the C++ standard [14.6.4] here, as the base class type is
|
||||
// dependent on the template argument (and thus shouldn't be
|
||||
// looked into when resolving InvokeWith).
|
||||
return this->InvokeWith(ArgumentTuple(a1, a2));
|
||||
}
|
||||
};
|
||||
|
||||
@ -123,7 +131,11 @@ class FunctionMocker<R(A1, A2, A3)> : public
|
||||
}
|
||||
|
||||
R Invoke(A1 a1, A2 a2, A3 a3) {
|
||||
return InvokeWith(ArgumentTuple(a1, a2, a3));
|
||||
// Even though gcc and MSVC don't enforce it, 'this->' is required
|
||||
// by the C++ standard [14.6.4] here, as the base class type is
|
||||
// dependent on the template argument (and thus shouldn't be
|
||||
// looked into when resolving InvokeWith).
|
||||
return this->InvokeWith(ArgumentTuple(a1, a2, a3));
|
||||
}
|
||||
};
|
||||
|
||||
@ -141,7 +153,11 @@ class FunctionMocker<R(A1, A2, A3, A4)> : public
|
||||
}
|
||||
|
||||
R Invoke(A1 a1, A2 a2, A3 a3, A4 a4) {
|
||||
return InvokeWith(ArgumentTuple(a1, a2, a3, a4));
|
||||
// Even though gcc and MSVC don't enforce it, 'this->' is required
|
||||
// by the C++ standard [14.6.4] here, as the base class type is
|
||||
// dependent on the template argument (and thus shouldn't be
|
||||
// looked into when resolving InvokeWith).
|
||||
return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4));
|
||||
}
|
||||
};
|
||||
|
||||
@ -161,7 +177,11 @@ class FunctionMocker<R(A1, A2, A3, A4, A5)> : public
|
||||
}
|
||||
|
||||
R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) {
|
||||
return InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5));
|
||||
// Even though gcc and MSVC don't enforce it, 'this->' is required
|
||||
// by the C++ standard [14.6.4] here, as the base class type is
|
||||
// dependent on the template argument (and thus shouldn't be
|
||||
// looked into when resolving InvokeWith).
|
||||
return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5));
|
||||
}
|
||||
};
|
||||
|
||||
@ -182,7 +202,11 @@ class FunctionMocker<R(A1, A2, A3, A4, A5, A6)> : public
|
||||
}
|
||||
|
||||
R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) {
|
||||
return InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6));
|
||||
// Even though gcc and MSVC don't enforce it, 'this->' is required
|
||||
// by the C++ standard [14.6.4] here, as the base class type is
|
||||
// dependent on the template argument (and thus shouldn't be
|
||||
// looked into when resolving InvokeWith).
|
||||
return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6));
|
||||
}
|
||||
};
|
||||
|
||||
@ -203,7 +227,11 @@ class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7)> : public
|
||||
}
|
||||
|
||||
R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) {
|
||||
return InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6, a7));
|
||||
// Even though gcc and MSVC don't enforce it, 'this->' is required
|
||||
// by the C++ standard [14.6.4] here, as the base class type is
|
||||
// dependent on the template argument (and thus shouldn't be
|
||||
// looked into when resolving InvokeWith).
|
||||
return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6, a7));
|
||||
}
|
||||
};
|
||||
|
||||
@ -224,7 +252,11 @@ class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7, A8)> : public
|
||||
}
|
||||
|
||||
R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) {
|
||||
return InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6, a7, a8));
|
||||
// Even though gcc and MSVC don't enforce it, 'this->' is required
|
||||
// by the C++ standard [14.6.4] here, as the base class type is
|
||||
// dependent on the template argument (and thus shouldn't be
|
||||
// looked into when resolving InvokeWith).
|
||||
return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6, a7, a8));
|
||||
}
|
||||
};
|
||||
|
||||
@ -246,7 +278,11 @@ class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7, A8, A9)> : public
|
||||
}
|
||||
|
||||
R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9) {
|
||||
return InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6, a7, a8, a9));
|
||||
// Even though gcc and MSVC don't enforce it, 'this->' is required
|
||||
// by the C++ standard [14.6.4] here, as the base class type is
|
||||
// dependent on the template argument (and thus shouldn't be
|
||||
// looked into when resolving InvokeWith).
|
||||
return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6, a7, a8, a9));
|
||||
}
|
||||
};
|
||||
|
||||
@ -270,7 +306,12 @@ class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)> : public
|
||||
|
||||
R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9,
|
||||
A10 a10) {
|
||||
return InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10));
|
||||
// Even though gcc and MSVC don't enforce it, 'this->' is required
|
||||
// by the C++ standard [14.6.4] here, as the base class type is
|
||||
// dependent on the template argument (and thus shouldn't be
|
||||
// looked into when resolving InvokeWith).
|
||||
return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6, a7, a8, a9,
|
||||
a10));
|
||||
}
|
||||
};
|
||||
|
||||
@ -753,66 +794,116 @@ class MockFunction;
|
||||
template <typename R>
|
||||
class MockFunction<R()> {
|
||||
public:
|
||||
MockFunction() {}
|
||||
|
||||
MOCK_METHOD0_T(Call, R());
|
||||
|
||||
private:
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
|
||||
};
|
||||
|
||||
template <typename R, typename A0>
|
||||
class MockFunction<R(A0)> {
|
||||
public:
|
||||
MockFunction() {}
|
||||
|
||||
MOCK_METHOD1_T(Call, R(A0));
|
||||
|
||||
private:
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
|
||||
};
|
||||
|
||||
template <typename R, typename A0, typename A1>
|
||||
class MockFunction<R(A0, A1)> {
|
||||
public:
|
||||
MockFunction() {}
|
||||
|
||||
MOCK_METHOD2_T(Call, R(A0, A1));
|
||||
|
||||
private:
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
|
||||
};
|
||||
|
||||
template <typename R, typename A0, typename A1, typename A2>
|
||||
class MockFunction<R(A0, A1, A2)> {
|
||||
public:
|
||||
MockFunction() {}
|
||||
|
||||
MOCK_METHOD3_T(Call, R(A0, A1, A2));
|
||||
|
||||
private:
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
|
||||
};
|
||||
|
||||
template <typename R, typename A0, typename A1, typename A2, typename A3>
|
||||
class MockFunction<R(A0, A1, A2, A3)> {
|
||||
public:
|
||||
MockFunction() {}
|
||||
|
||||
MOCK_METHOD4_T(Call, R(A0, A1, A2, A3));
|
||||
|
||||
private:
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
|
||||
};
|
||||
|
||||
template <typename R, typename A0, typename A1, typename A2, typename A3,
|
||||
typename A4>
|
||||
class MockFunction<R(A0, A1, A2, A3, A4)> {
|
||||
public:
|
||||
MockFunction() {}
|
||||
|
||||
MOCK_METHOD5_T(Call, R(A0, A1, A2, A3, A4));
|
||||
|
||||
private:
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
|
||||
};
|
||||
|
||||
template <typename R, typename A0, typename A1, typename A2, typename A3,
|
||||
typename A4, typename A5>
|
||||
class MockFunction<R(A0, A1, A2, A3, A4, A5)> {
|
||||
public:
|
||||
MockFunction() {}
|
||||
|
||||
MOCK_METHOD6_T(Call, R(A0, A1, A2, A3, A4, A5));
|
||||
|
||||
private:
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
|
||||
};
|
||||
|
||||
template <typename R, typename A0, typename A1, typename A2, typename A3,
|
||||
typename A4, typename A5, typename A6>
|
||||
class MockFunction<R(A0, A1, A2, A3, A4, A5, A6)> {
|
||||
public:
|
||||
MockFunction() {}
|
||||
|
||||
MOCK_METHOD7_T(Call, R(A0, A1, A2, A3, A4, A5, A6));
|
||||
|
||||
private:
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
|
||||
};
|
||||
|
||||
template <typename R, typename A0, typename A1, typename A2, typename A3,
|
||||
typename A4, typename A5, typename A6, typename A7>
|
||||
class MockFunction<R(A0, A1, A2, A3, A4, A5, A6, A7)> {
|
||||
public:
|
||||
MockFunction() {}
|
||||
|
||||
MOCK_METHOD8_T(Call, R(A0, A1, A2, A3, A4, A5, A6, A7));
|
||||
|
||||
private:
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
|
||||
};
|
||||
|
||||
template <typename R, typename A0, typename A1, typename A2, typename A3,
|
||||
typename A4, typename A5, typename A6, typename A7, typename A8>
|
||||
class MockFunction<R(A0, A1, A2, A3, A4, A5, A6, A7, A8)> {
|
||||
public:
|
||||
MockFunction() {}
|
||||
|
||||
MOCK_METHOD9_T(Call, R(A0, A1, A2, A3, A4, A5, A6, A7, A8));
|
||||
|
||||
private:
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
|
||||
};
|
||||
|
||||
template <typename R, typename A0, typename A1, typename A2, typename A3,
|
||||
@ -820,7 +911,12 @@ template <typename R, typename A0, typename A1, typename A2, typename A3,
|
||||
typename A9>
|
||||
class MockFunction<R(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9)> {
|
||||
public:
|
||||
MockFunction() {}
|
||||
|
||||
MOCK_METHOD10_T(Call, R(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9));
|
||||
|
||||
private:
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
|
||||
};
|
||||
|
||||
} // namespace testing
|
||||
|
@ -45,10 +45,6 @@ $var n = 10 $$ The maximum arity we support.
|
||||
#include <gmock/internal/gmock-internal-utils.h>
|
||||
|
||||
namespace testing {
|
||||
|
||||
template <typename F>
|
||||
class MockSpec;
|
||||
|
||||
namespace internal {
|
||||
|
||||
template <typename F>
|
||||
@ -89,7 +85,11 @@ $if i >= 1 [[
|
||||
}
|
||||
|
||||
R Invoke($Aas) {
|
||||
return InvokeWith(ArgumentTuple($as));
|
||||
// Even though gcc and MSVC don't enforce it, 'this->' is required
|
||||
// by the C++ standard [14.6.4] here, as the base class type is
|
||||
// dependent on the template argument (and thus shouldn't be
|
||||
// looked into when resolving InvokeWith).
|
||||
return this->InvokeWith(ArgumentTuple($as));
|
||||
}
|
||||
};
|
||||
|
||||
@ -242,7 +242,12 @@ $range j 0..i-1
|
||||
template <typename R$for j [[, typename A$j]]>
|
||||
class MockFunction<R($for j, [[A$j]])> {
|
||||
public:
|
||||
MockFunction() {}
|
||||
|
||||
MOCK_METHOD$i[[]]_T(Call, R($for j, [[A$j]]));
|
||||
|
||||
private:
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
|
||||
};
|
||||
|
||||
|
||||
|
@ -89,7 +89,7 @@ template <class Tuple>
|
||||
class TupleFields<Tuple, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1> {
|
||||
public:
|
||||
typedef ::std::tr1::tuple<> type;
|
||||
static type GetSelectedFields(const Tuple& t) {
|
||||
static type GetSelectedFields(const Tuple& /* t */) {
|
||||
using ::std::tr1::get;
|
||||
return type();
|
||||
}
|
||||
@ -271,6 +271,8 @@ class ArgsMatcherImpl : public MatcherInterface<ArgsTuple> {
|
||||
}
|
||||
|
||||
const MonomorphicInnerMatcher inner_matcher_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(ArgsMatcherImpl);
|
||||
};
|
||||
|
||||
template <class InnerMatcher, int k0 = -1, int k1 = -1, int k2 = -1,
|
||||
@ -287,7 +289,10 @@ class ArgsMatcher {
|
||||
k6, k7, k8, k9>(inner_matcher_));
|
||||
}
|
||||
|
||||
private:
|
||||
const InnerMatcher inner_matcher_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(ArgsMatcher);
|
||||
};
|
||||
|
||||
// Implements ElementsAre() of 1-10 arguments.
|
||||
@ -317,6 +322,8 @@ class ElementsAreMatcher1 {
|
||||
|
||||
private:
|
||||
const T1& e1_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher1);
|
||||
};
|
||||
|
||||
template <typename T1, typename T2>
|
||||
@ -342,6 +349,8 @@ class ElementsAreMatcher2 {
|
||||
private:
|
||||
const T1& e1_;
|
||||
const T2& e2_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher2);
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3>
|
||||
@ -370,6 +379,8 @@ class ElementsAreMatcher3 {
|
||||
const T1& e1_;
|
||||
const T2& e2_;
|
||||
const T3& e3_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher3);
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4>
|
||||
@ -400,6 +411,8 @@ class ElementsAreMatcher4 {
|
||||
const T2& e2_;
|
||||
const T3& e3_;
|
||||
const T4& e4_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher4);
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5>
|
||||
@ -432,6 +445,8 @@ class ElementsAreMatcher5 {
|
||||
const T3& e3_;
|
||||
const T4& e4_;
|
||||
const T5& e5_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher5);
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5,
|
||||
@ -468,6 +483,8 @@ class ElementsAreMatcher6 {
|
||||
const T4& e4_;
|
||||
const T5& e5_;
|
||||
const T6& e6_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher6);
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5,
|
||||
@ -506,6 +523,8 @@ class ElementsAreMatcher7 {
|
||||
const T5& e5_;
|
||||
const T6& e6_;
|
||||
const T7& e7_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher7);
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5,
|
||||
@ -546,6 +565,8 @@ class ElementsAreMatcher8 {
|
||||
const T6& e6_;
|
||||
const T7& e7_;
|
||||
const T8& e8_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher8);
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5,
|
||||
@ -589,6 +610,8 @@ class ElementsAreMatcher9 {
|
||||
const T7& e7_;
|
||||
const T8& e8_;
|
||||
const T9& e9_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher9);
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3, typename T4, typename T5,
|
||||
@ -634,6 +657,8 @@ class ElementsAreMatcher10 {
|
||||
const T8& e8_;
|
||||
const T9& e9_;
|
||||
const T10& e10_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher10);
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
@ -1012,6 +1037,8 @@ ElementsAreArray(const T (&array)[N]) {
|
||||
#name, description, gmock_interp_, gmock_printed_params);\
|
||||
}\
|
||||
const ::testing::internal::Interpolations gmock_interp_;\
|
||||
private:\
|
||||
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
|
||||
};\
|
||||
template <typename arg_type>\
|
||||
operator ::testing::Matcher<arg_type>() const {\
|
||||
@ -1023,7 +1050,9 @@ ElementsAreArray(const T (&array)[N]) {
|
||||
gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\
|
||||
gmock_param_names, ("" description ""));\
|
||||
}\
|
||||
private:\
|
||||
::testing::internal::Interpolations gmock_interp_;\
|
||||
GTEST_DISALLOW_ASSIGN_(name##Matcher);\
|
||||
};\
|
||||
inline name##Matcher name() {\
|
||||
return name##Matcher();\
|
||||
@ -1052,6 +1081,8 @@ ElementsAreArray(const T (&array)[N]) {
|
||||
}\
|
||||
p0##_type p0;\
|
||||
const ::testing::internal::Interpolations gmock_interp_;\
|
||||
private:\
|
||||
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
|
||||
};\
|
||||
template <typename arg_type>\
|
||||
operator ::testing::Matcher<arg_type>() const {\
|
||||
@ -1064,7 +1095,9 @@ ElementsAreArray(const T (&array)[N]) {
|
||||
gmock_param_names, ("" description ""));\
|
||||
}\
|
||||
p0##_type p0;\
|
||||
private:\
|
||||
::testing::internal::Interpolations gmock_interp_;\
|
||||
GTEST_DISALLOW_ASSIGN_(name##MatcherP);\
|
||||
};\
|
||||
template <typename p0##_type>\
|
||||
inline name##MatcherP<p0##_type> name(p0##_type p0) {\
|
||||
@ -1096,6 +1129,8 @@ ElementsAreArray(const T (&array)[N]) {
|
||||
p0##_type p0;\
|
||||
p1##_type p1;\
|
||||
const ::testing::internal::Interpolations gmock_interp_;\
|
||||
private:\
|
||||
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
|
||||
};\
|
||||
template <typename arg_type>\
|
||||
operator ::testing::Matcher<arg_type>() const {\
|
||||
@ -1110,7 +1145,9 @@ ElementsAreArray(const T (&array)[N]) {
|
||||
}\
|
||||
p0##_type p0;\
|
||||
p1##_type p1;\
|
||||
private:\
|
||||
::testing::internal::Interpolations gmock_interp_;\
|
||||
GTEST_DISALLOW_ASSIGN_(name##MatcherP2);\
|
||||
};\
|
||||
template <typename p0##_type, typename p1##_type>\
|
||||
inline name##MatcherP2<p0##_type, p1##_type> name(p0##_type p0, \
|
||||
@ -1146,6 +1183,8 @@ ElementsAreArray(const T (&array)[N]) {
|
||||
p1##_type p1;\
|
||||
p2##_type p2;\
|
||||
const ::testing::internal::Interpolations gmock_interp_;\
|
||||
private:\
|
||||
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
|
||||
};\
|
||||
template <typename arg_type>\
|
||||
operator ::testing::Matcher<arg_type>() const {\
|
||||
@ -1161,7 +1200,9 @@ ElementsAreArray(const T (&array)[N]) {
|
||||
p0##_type p0;\
|
||||
p1##_type p1;\
|
||||
p2##_type p2;\
|
||||
private:\
|
||||
::testing::internal::Interpolations gmock_interp_;\
|
||||
GTEST_DISALLOW_ASSIGN_(name##MatcherP3);\
|
||||
};\
|
||||
template <typename p0##_type, typename p1##_type, typename p2##_type>\
|
||||
inline name##MatcherP3<p0##_type, p1##_type, p2##_type> name(p0##_type p0, \
|
||||
@ -1200,6 +1241,8 @@ ElementsAreArray(const T (&array)[N]) {
|
||||
p2##_type p2;\
|
||||
p3##_type p3;\
|
||||
const ::testing::internal::Interpolations gmock_interp_;\
|
||||
private:\
|
||||
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
|
||||
};\
|
||||
template <typename arg_type>\
|
||||
operator ::testing::Matcher<arg_type>() const {\
|
||||
@ -1217,7 +1260,9 @@ ElementsAreArray(const T (&array)[N]) {
|
||||
p1##_type p1;\
|
||||
p2##_type p2;\
|
||||
p3##_type p3;\
|
||||
private:\
|
||||
::testing::internal::Interpolations gmock_interp_;\
|
||||
GTEST_DISALLOW_ASSIGN_(name##MatcherP4);\
|
||||
};\
|
||||
template <typename p0##_type, typename p1##_type, typename p2##_type, \
|
||||
typename p3##_type>\
|
||||
@ -1261,6 +1306,8 @@ ElementsAreArray(const T (&array)[N]) {
|
||||
p3##_type p3;\
|
||||
p4##_type p4;\
|
||||
const ::testing::internal::Interpolations gmock_interp_;\
|
||||
private:\
|
||||
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
|
||||
};\
|
||||
template <typename arg_type>\
|
||||
operator ::testing::Matcher<arg_type>() const {\
|
||||
@ -1280,7 +1327,9 @@ ElementsAreArray(const T (&array)[N]) {
|
||||
p2##_type p2;\
|
||||
p3##_type p3;\
|
||||
p4##_type p4;\
|
||||
private:\
|
||||
::testing::internal::Interpolations gmock_interp_;\
|
||||
GTEST_DISALLOW_ASSIGN_(name##MatcherP5);\
|
||||
};\
|
||||
template <typename p0##_type, typename p1##_type, typename p2##_type, \
|
||||
typename p3##_type, typename p4##_type>\
|
||||
@ -1325,6 +1374,8 @@ ElementsAreArray(const T (&array)[N]) {
|
||||
p4##_type p4;\
|
||||
p5##_type p5;\
|
||||
const ::testing::internal::Interpolations gmock_interp_;\
|
||||
private:\
|
||||
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
|
||||
};\
|
||||
template <typename arg_type>\
|
||||
operator ::testing::Matcher<arg_type>() const {\
|
||||
@ -1345,7 +1396,9 @@ ElementsAreArray(const T (&array)[N]) {
|
||||
p3##_type p3;\
|
||||
p4##_type p4;\
|
||||
p5##_type p5;\
|
||||
private:\
|
||||
::testing::internal::Interpolations gmock_interp_;\
|
||||
GTEST_DISALLOW_ASSIGN_(name##MatcherP6);\
|
||||
};\
|
||||
template <typename p0##_type, typename p1##_type, typename p2##_type, \
|
||||
typename p3##_type, typename p4##_type, typename p5##_type>\
|
||||
@ -1396,6 +1449,8 @@ ElementsAreArray(const T (&array)[N]) {
|
||||
p5##_type p5;\
|
||||
p6##_type p6;\
|
||||
const ::testing::internal::Interpolations gmock_interp_;\
|
||||
private:\
|
||||
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
|
||||
};\
|
||||
template <typename arg_type>\
|
||||
operator ::testing::Matcher<arg_type>() const {\
|
||||
@ -1419,7 +1474,9 @@ ElementsAreArray(const T (&array)[N]) {
|
||||
p4##_type p4;\
|
||||
p5##_type p5;\
|
||||
p6##_type p6;\
|
||||
private:\
|
||||
::testing::internal::Interpolations gmock_interp_;\
|
||||
GTEST_DISALLOW_ASSIGN_(name##MatcherP7);\
|
||||
};\
|
||||
template <typename p0##_type, typename p1##_type, typename p2##_type, \
|
||||
typename p3##_type, typename p4##_type, typename p5##_type, \
|
||||
@ -1474,6 +1531,8 @@ ElementsAreArray(const T (&array)[N]) {
|
||||
p6##_type p6;\
|
||||
p7##_type p7;\
|
||||
const ::testing::internal::Interpolations gmock_interp_;\
|
||||
private:\
|
||||
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
|
||||
};\
|
||||
template <typename arg_type>\
|
||||
operator ::testing::Matcher<arg_type>() const {\
|
||||
@ -1500,7 +1559,9 @@ ElementsAreArray(const T (&array)[N]) {
|
||||
p5##_type p5;\
|
||||
p6##_type p6;\
|
||||
p7##_type p7;\
|
||||
private:\
|
||||
::testing::internal::Interpolations gmock_interp_;\
|
||||
GTEST_DISALLOW_ASSIGN_(name##MatcherP8);\
|
||||
};\
|
||||
template <typename p0##_type, typename p1##_type, typename p2##_type, \
|
||||
typename p3##_type, typename p4##_type, typename p5##_type, \
|
||||
@ -1557,6 +1618,8 @@ ElementsAreArray(const T (&array)[N]) {
|
||||
p7##_type p7;\
|
||||
p8##_type p8;\
|
||||
const ::testing::internal::Interpolations gmock_interp_;\
|
||||
private:\
|
||||
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
|
||||
};\
|
||||
template <typename arg_type>\
|
||||
operator ::testing::Matcher<arg_type>() const {\
|
||||
@ -1584,7 +1647,9 @@ ElementsAreArray(const T (&array)[N]) {
|
||||
p6##_type p6;\
|
||||
p7##_type p7;\
|
||||
p8##_type p8;\
|
||||
private:\
|
||||
::testing::internal::Interpolations gmock_interp_;\
|
||||
GTEST_DISALLOW_ASSIGN_(name##MatcherP9);\
|
||||
};\
|
||||
template <typename p0##_type, typename p1##_type, typename p2##_type, \
|
||||
typename p3##_type, typename p4##_type, typename p5##_type, \
|
||||
@ -1645,6 +1710,8 @@ ElementsAreArray(const T (&array)[N]) {
|
||||
p8##_type p8;\
|
||||
p9##_type p9;\
|
||||
const ::testing::internal::Interpolations gmock_interp_;\
|
||||
private:\
|
||||
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
|
||||
};\
|
||||
template <typename arg_type>\
|
||||
operator ::testing::Matcher<arg_type>() const {\
|
||||
@ -1673,7 +1740,9 @@ ElementsAreArray(const T (&array)[N]) {
|
||||
p7##_type p7;\
|
||||
p8##_type p8;\
|
||||
p9##_type p9;\
|
||||
private:\
|
||||
::testing::internal::Interpolations gmock_interp_;\
|
||||
GTEST_DISALLOW_ASSIGN_(name##MatcherP10);\
|
||||
};\
|
||||
template <typename p0##_type, typename p1##_type, typename p2##_type, \
|
||||
typename p3##_type, typename p4##_type, typename p5##_type, \
|
||||
|
@ -91,7 +91,7 @@ template <class Tuple$for j [[, int k$j]]>
|
||||
class TupleFields<Tuple, $for k, [[$if k < i [[k$k]] $else [[-1]]]]> {
|
||||
public:
|
||||
typedef ::std::tr1::tuple<$for j, [[GMOCK_FIELD_TYPE_(Tuple, k$j)]]> type;
|
||||
static type GetSelectedFields(const Tuple& t) {
|
||||
static type GetSelectedFields(const Tuple& $if i==0 [[/* t */]] $else [[t]]) {
|
||||
using ::std::tr1::get;
|
||||
return type($for j, [[get<k$j>(t)]]);
|
||||
}
|
||||
@ -157,6 +157,8 @@ class ArgsMatcherImpl : public MatcherInterface<ArgsTuple> {
|
||||
}
|
||||
|
||||
const MonomorphicInnerMatcher inner_matcher_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(ArgsMatcherImpl);
|
||||
};
|
||||
|
||||
template <class InnerMatcher$for i [[, int k$i = -1]]>
|
||||
@ -170,7 +172,10 @@ class ArgsMatcher {
|
||||
return MakeMatcher(new ArgsMatcherImpl<ArgsTuple, $ks>(inner_matcher_));
|
||||
}
|
||||
|
||||
private:
|
||||
const InnerMatcher inner_matcher_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(ArgsMatcher);
|
||||
};
|
||||
|
||||
// Implements ElementsAre() of 1-$n arguments.
|
||||
@ -224,6 +229,8 @@ $for j [[
|
||||
const T$j& e$j[[]]_;
|
||||
|
||||
]]
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher$i);
|
||||
};
|
||||
|
||||
|
||||
@ -512,6 +519,8 @@ $var param_field_decls2 = [[$for j
|
||||
#name, description, gmock_interp_, gmock_printed_params);\
|
||||
}\$param_field_decls
|
||||
const ::testing::internal::Interpolations gmock_interp_;\
|
||||
private:\
|
||||
GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
|
||||
};\
|
||||
template <typename arg_type>\
|
||||
operator ::testing::Matcher<arg_type>() const {\
|
||||
@ -523,7 +532,9 @@ $var param_field_decls2 = [[$for j
|
||||
gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\
|
||||
gmock_param_names, ("" description ""));\
|
||||
}\$param_field_decls2
|
||||
private:\
|
||||
::testing::internal::Interpolations gmock_interp_;\
|
||||
GTEST_DISALLOW_ASSIGN_($class_name);\
|
||||
};\$template
|
||||
inline $class_name$param_types name($param_types_and_names) {\
|
||||
return $class_name$param_types($params);\
|
||||
|
@ -155,6 +155,9 @@ class NiceMock : public MockClass {
|
||||
::testing::Mock::UnregisterCallReaction(
|
||||
internal::implicit_cast<MockClass*>(this));
|
||||
}
|
||||
|
||||
private:
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(NiceMock);
|
||||
};
|
||||
|
||||
template <class MockClass>
|
||||
@ -246,6 +249,9 @@ class StrictMock : public MockClass {
|
||||
::testing::Mock::UnregisterCallReaction(
|
||||
internal::implicit_cast<MockClass*>(this));
|
||||
}
|
||||
|
||||
private:
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(StrictMock);
|
||||
};
|
||||
|
||||
// The following specializations catch some (relatively more common)
|
||||
|
@ -100,6 +100,9 @@ $range j 1..i
|
||||
::testing::Mock::UnregisterCallReaction(
|
||||
internal::implicit_cast<MockClass*>(this));
|
||||
}
|
||||
|
||||
private:
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(NiceMock);
|
||||
};
|
||||
|
||||
template <class MockClass>
|
||||
@ -132,6 +135,9 @@ $range j 1..i
|
||||
::testing::Mock::UnregisterCallReaction(
|
||||
internal::implicit_cast<MockClass*>(this));
|
||||
}
|
||||
|
||||
private:
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(StrictMock);
|
||||
};
|
||||
|
||||
// The following specializations catch some (relatively more common)
|
||||
|
@ -121,6 +121,7 @@ class MatcherBase {
|
||||
void ExplainMatchResultTo(T x, ::std::ostream* os) const {
|
||||
impl_->ExplainMatchResultTo(x, os);
|
||||
}
|
||||
|
||||
protected:
|
||||
MatcherBase() {}
|
||||
|
||||
@ -129,6 +130,7 @@ class MatcherBase {
|
||||
: impl_(impl) {}
|
||||
|
||||
virtual ~MatcherBase() {}
|
||||
|
||||
private:
|
||||
// shared_ptr (util/gtl/shared_ptr.h) and linked_ptr have similar
|
||||
// interfaces. The former dynamically allocates a chunk of memory
|
||||
@ -234,7 +236,7 @@ class Matcher<internal::string>
|
||||
template <class Impl>
|
||||
class PolymorphicMatcher {
|
||||
public:
|
||||
explicit PolymorphicMatcher(const Impl& impl) : impl_(impl) {}
|
||||
explicit PolymorphicMatcher(const Impl& an_impl) : impl_(an_impl) {}
|
||||
|
||||
// Returns a mutable reference to the underlying matcher
|
||||
// implementation object.
|
||||
@ -248,6 +250,7 @@ class PolymorphicMatcher {
|
||||
operator Matcher<T>() const {
|
||||
return Matcher<T>(new MonomorphicImpl<T>(impl_));
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename T>
|
||||
class MonomorphicImpl : public MatcherInterface<T> {
|
||||
@ -284,9 +287,13 @@ class PolymorphicMatcher {
|
||||
|
||||
private:
|
||||
const Impl impl_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(MonomorphicImpl);
|
||||
};
|
||||
|
||||
Impl impl_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(PolymorphicMatcher);
|
||||
};
|
||||
|
||||
// Creates a matcher from its implementation. This is easier to use
|
||||
@ -522,6 +529,7 @@ class MatcherCastImpl<T, Matcher<U> > {
|
||||
static Matcher<T> Cast(const Matcher<U>& source_matcher) {
|
||||
return Matcher<T>(new Impl(source_matcher));
|
||||
}
|
||||
|
||||
private:
|
||||
class Impl : public MatcherInterface<T> {
|
||||
public:
|
||||
@ -544,8 +552,11 @@ class MatcherCastImpl<T, Matcher<U> > {
|
||||
virtual void ExplainMatchResultTo(T x, ::std::ostream* os) const {
|
||||
source_matcher_.ExplainMatchResultTo(static_cast<U>(x), os);
|
||||
}
|
||||
|
||||
private:
|
||||
const Matcher<U> source_matcher_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(Impl);
|
||||
};
|
||||
};
|
||||
|
||||
@ -618,8 +629,10 @@ class AnythingMatcher {
|
||||
} \
|
||||
private: \
|
||||
Rhs rhs_; \
|
||||
GTEST_DISALLOW_ASSIGN_(Impl); \
|
||||
}; \
|
||||
Rhs rhs_; \
|
||||
GTEST_DISALLOW_ASSIGN_(name##Matcher); \
|
||||
}
|
||||
|
||||
// Implements Eq(v), Ge(v), Gt(v), Le(v), Lt(v), and Ne(v)
|
||||
@ -633,12 +646,12 @@ GMOCK_IMPLEMENT_COMPARISON_MATCHER_(Ne, !=, "not equal to");
|
||||
|
||||
#undef GMOCK_IMPLEMENT_COMPARISON_MATCHER_
|
||||
|
||||
// Implements the polymorphic IsNull() matcher, which matches any
|
||||
// Implements the polymorphic IsNull() matcher, which matches any raw or smart
|
||||
// pointer that is NULL.
|
||||
class IsNullMatcher {
|
||||
public:
|
||||
template <typename T>
|
||||
bool Matches(T* p) const { return p == NULL; }
|
||||
template <typename Pointer>
|
||||
bool Matches(const Pointer& p) const { return GetRawPointer(p) == NULL; }
|
||||
|
||||
void DescribeTo(::std::ostream* os) const { *os << "is NULL"; }
|
||||
void DescribeNegationTo(::std::ostream* os) const {
|
||||
@ -646,12 +659,12 @@ class IsNullMatcher {
|
||||
}
|
||||
};
|
||||
|
||||
// Implements the polymorphic NotNull() matcher, which matches any
|
||||
// Implements the polymorphic NotNull() matcher, which matches any raw or smart
|
||||
// pointer that is not NULL.
|
||||
class NotNullMatcher {
|
||||
public:
|
||||
template <typename T>
|
||||
bool Matches(T* p) const { return p != NULL; }
|
||||
template <typename Pointer>
|
||||
bool Matches(const Pointer& p) const { return GetRawPointer(p) != NULL; }
|
||||
|
||||
void DescribeTo(::std::ostream* os) const { *os << "is not NULL"; }
|
||||
void DescribeNegationTo(::std::ostream* os) const {
|
||||
@ -697,6 +710,7 @@ class RefMatcher<T&> {
|
||||
// reference to a non-const reference.
|
||||
return MakeMatcher(new Impl<Super>(object_));
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename Super>
|
||||
class Impl : public MatcherInterface<Super&> {
|
||||
@ -721,11 +735,16 @@ class RefMatcher<T&> {
|
||||
::std::ostream* os) const {
|
||||
*os << "is located @" << static_cast<const void*>(&x);
|
||||
}
|
||||
|
||||
private:
|
||||
const Super& object_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(Impl);
|
||||
};
|
||||
|
||||
T& object_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(RefMatcher);
|
||||
};
|
||||
|
||||
// Polymorphic helper functions for narrow and wide string matchers.
|
||||
@ -795,6 +814,7 @@ class StrEqualityMatcher {
|
||||
void DescribeNegationTo(::std::ostream* os) const {
|
||||
DescribeToHelper(!expect_eq_, os);
|
||||
}
|
||||
|
||||
private:
|
||||
void DescribeToHelper(bool expect_eq, ::std::ostream* os) const {
|
||||
*os << "is ";
|
||||
@ -811,6 +831,8 @@ class StrEqualityMatcher {
|
||||
const StringType string_;
|
||||
const bool expect_eq_;
|
||||
const bool case_sensitive_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(StrEqualityMatcher);
|
||||
};
|
||||
|
||||
// Implements the polymorphic HasSubstr(substring) matcher, which
|
||||
@ -845,8 +867,11 @@ class HasSubstrMatcher {
|
||||
*os << "has no substring ";
|
||||
UniversalPrinter<StringType>::Print(substring_, os);
|
||||
}
|
||||
|
||||
private:
|
||||
const StringType substring_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(HasSubstrMatcher);
|
||||
};
|
||||
|
||||
// Implements the polymorphic StartsWith(substring) matcher, which
|
||||
@ -881,8 +906,11 @@ class StartsWithMatcher {
|
||||
*os << "doesn't start with ";
|
||||
UniversalPrinter<StringType>::Print(prefix_, os);
|
||||
}
|
||||
|
||||
private:
|
||||
const StringType prefix_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(StartsWithMatcher);
|
||||
};
|
||||
|
||||
// Implements the polymorphic EndsWith(substring) matcher, which
|
||||
@ -916,8 +944,11 @@ class EndsWithMatcher {
|
||||
*os << "doesn't end with ";
|
||||
UniversalPrinter<StringType>::Print(suffix_, os);
|
||||
}
|
||||
|
||||
private:
|
||||
const StringType suffix_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(EndsWithMatcher);
|
||||
};
|
||||
|
||||
#if GMOCK_HAS_REGEX
|
||||
@ -954,9 +985,12 @@ class MatchesRegexMatcher {
|
||||
<< " regular expression ";
|
||||
UniversalPrinter<internal::string>::Print(regex_->pattern(), os);
|
||||
}
|
||||
|
||||
private:
|
||||
const internal::linked_ptr<const RE> regex_;
|
||||
const bool full_match_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(MatchesRegexMatcher);
|
||||
};
|
||||
|
||||
#endif // GMOCK_HAS_REGEX
|
||||
@ -1030,8 +1064,11 @@ class NotMatcherImpl : public MatcherInterface<T> {
|
||||
virtual void ExplainMatchResultTo(T x, ::std::ostream* os) const {
|
||||
matcher_.ExplainMatchResultTo(x, os);
|
||||
}
|
||||
|
||||
private:
|
||||
const Matcher<T> matcher_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(NotMatcherImpl);
|
||||
};
|
||||
|
||||
// Implements the Not(m) matcher, which matches a value that doesn't
|
||||
@ -1047,8 +1084,11 @@ class NotMatcher {
|
||||
operator Matcher<T>() const {
|
||||
return Matcher<T>(new NotMatcherImpl<T>(SafeMatcherCast<T>(matcher_)));
|
||||
}
|
||||
|
||||
private:
|
||||
InnerMatcher matcher_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(NotMatcher);
|
||||
};
|
||||
|
||||
// Implements the AllOf(m1, m2) matcher for a particular argument type
|
||||
@ -1108,9 +1148,12 @@ class BothOfMatcherImpl : public MatcherInterface<T> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
const Matcher<T> matcher1_;
|
||||
const Matcher<T> matcher2_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(BothOfMatcherImpl);
|
||||
};
|
||||
|
||||
// Used for implementing the AllOf(m_1, ..., m_n) matcher, which
|
||||
@ -1129,9 +1172,12 @@ class BothOfMatcher {
|
||||
return Matcher<T>(new BothOfMatcherImpl<T>(SafeMatcherCast<T>(matcher1_),
|
||||
SafeMatcherCast<T>(matcher2_)));
|
||||
}
|
||||
|
||||
private:
|
||||
Matcher1 matcher1_;
|
||||
Matcher2 matcher2_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(BothOfMatcher);
|
||||
};
|
||||
|
||||
// Implements the AnyOf(m1, m2) matcher for a particular argument type
|
||||
@ -1190,9 +1236,12 @@ class EitherOfMatcherImpl : public MatcherInterface<T> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
const Matcher<T> matcher1_;
|
||||
const Matcher<T> matcher2_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(EitherOfMatcherImpl);
|
||||
};
|
||||
|
||||
// Used for implementing the AnyOf(m_1, ..., m_n) matcher, which
|
||||
@ -1212,9 +1261,12 @@ class EitherOfMatcher {
|
||||
return Matcher<T>(new EitherOfMatcherImpl<T>(
|
||||
SafeMatcherCast<T>(matcher1_), SafeMatcherCast<T>(matcher2_)));
|
||||
}
|
||||
|
||||
private:
|
||||
Matcher1 matcher1_;
|
||||
Matcher2 matcher2_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(EitherOfMatcher);
|
||||
};
|
||||
|
||||
// Used for implementing Truly(pred), which turns a predicate into a
|
||||
@ -1248,8 +1300,11 @@ class TrulyMatcher {
|
||||
void DescribeNegationTo(::std::ostream* os) const {
|
||||
*os << "doesn't satisfy the given predicate";
|
||||
}
|
||||
|
||||
private:
|
||||
Predicate predicate_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(TrulyMatcher);
|
||||
};
|
||||
|
||||
// Used for implementing Matches(matcher), which turns a matcher into
|
||||
@ -1283,8 +1338,11 @@ class MatcherAsPredicate {
|
||||
// in all of the above situations.
|
||||
return MatcherCast<const T&>(matcher_).Matches(x);
|
||||
}
|
||||
|
||||
private:
|
||||
M matcher_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(MatcherAsPredicate);
|
||||
};
|
||||
|
||||
// For implementing ASSERT_THAT() and EXPECT_THAT(). The template
|
||||
@ -1322,8 +1380,11 @@ class PredicateFormatterFromMatcher {
|
||||
return AssertionFailure(Message() << ss.str());
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
const M matcher_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(PredicateFormatterFromMatcher);
|
||||
};
|
||||
|
||||
// A helper function for converting a matcher to a predicate-formatter
|
||||
@ -1405,6 +1466,8 @@ class FloatingEqMatcher {
|
||||
private:
|
||||
const FloatType rhs_;
|
||||
const bool nan_eq_nan_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(Impl);
|
||||
};
|
||||
|
||||
// The following 3 type conversion operators allow FloatEq(rhs) and
|
||||
@ -1427,6 +1490,8 @@ class FloatingEqMatcher {
|
||||
private:
|
||||
const FloatType rhs_;
|
||||
const bool nan_eq_nan_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(FloatingEqMatcher);
|
||||
};
|
||||
|
||||
// Implements the Pointee(m) matcher for matching a pointer whose
|
||||
@ -1448,6 +1513,7 @@ class PointeeMatcher {
|
||||
operator Matcher<Pointer>() const {
|
||||
return MakeMatcher(new Impl<Pointer>(matcher_));
|
||||
}
|
||||
|
||||
private:
|
||||
// The monomorphic implementation that works for a particular pointer type.
|
||||
template <typename Pointer>
|
||||
@ -1485,11 +1551,16 @@ class PointeeMatcher {
|
||||
*os << "points to a value that " << s;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
const Matcher<const Pointee&> matcher_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(Impl);
|
||||
};
|
||||
|
||||
const InnerMatcher matcher_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(PointeeMatcher);
|
||||
};
|
||||
|
||||
// Implements the Field() matcher for matching a field (i.e. member
|
||||
@ -1543,9 +1614,12 @@ class FieldMatcher {
|
||||
ExplainMatchResultTo(false_type(), *p, os);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
const FieldType Class::*field_;
|
||||
const Matcher<const FieldType&> matcher_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(FieldMatcher);
|
||||
};
|
||||
|
||||
// Explains the result of matching an object or pointer against a field matcher.
|
||||
@ -1613,9 +1687,12 @@ class PropertyMatcher {
|
||||
ExplainMatchResultTo(false_type(), *p, os);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
PropertyType (Class::*property_)() const;
|
||||
const Matcher<RefToConstProperty> matcher_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(PropertyMatcher);
|
||||
};
|
||||
|
||||
// Explains the result of matching an object or pointer against a
|
||||
@ -1636,7 +1713,7 @@ struct CallableTraits {
|
||||
typedef typename Functor::result_type ResultType;
|
||||
typedef Functor StorageType;
|
||||
|
||||
static void CheckIsValid(Functor functor) {}
|
||||
static void CheckIsValid(Functor /* functor */) {}
|
||||
template <typename T>
|
||||
static ResultType Invoke(Functor f, T arg) { return f(arg); }
|
||||
};
|
||||
@ -1709,6 +1786,7 @@ class ResultOfMatcher {
|
||||
if (s != "")
|
||||
*os << "result of the given callable " << s;
|
||||
}
|
||||
|
||||
private:
|
||||
// Functors often define operator() as non-const method even though
|
||||
// they are actualy stateless. But we need to use them even when
|
||||
@ -1717,10 +1795,14 @@ class ResultOfMatcher {
|
||||
// how many times the callable will be invoked.
|
||||
mutable CallableStorageType callable_;
|
||||
const Matcher<ResultType> matcher_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(Impl);
|
||||
}; // class Impl
|
||||
|
||||
const CallableStorageType callable_;
|
||||
const Matcher<ResultType> matcher_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(ResultOfMatcher);
|
||||
};
|
||||
|
||||
// Explains the result of matching a value against a functor matcher.
|
||||
@ -1818,8 +1900,11 @@ class ContainerEqMatcher {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
const StlContainer rhs_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(ContainerEqMatcher);
|
||||
};
|
||||
|
||||
template <typename LhsContainer, typename Container>
|
||||
@ -1884,6 +1969,8 @@ class ContainsMatcherImpl : public MatcherInterface<Container> {
|
||||
|
||||
private:
|
||||
const Matcher<const Element&> inner_matcher_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(ContainsMatcherImpl);
|
||||
};
|
||||
|
||||
// Implements polymorphic Contains(element_matcher).
|
||||
@ -1899,6 +1986,8 @@ class ContainsMatcher {
|
||||
|
||||
private:
|
||||
const M inner_matcher_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(ContainsMatcher);
|
||||
};
|
||||
|
||||
// Implements Key(inner_matcher) for the given argument pair type.
|
||||
@ -1942,6 +2031,8 @@ class KeyMatcherImpl : public MatcherInterface<PairType> {
|
||||
|
||||
private:
|
||||
const Matcher<const KeyType&> inner_matcher_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(KeyMatcherImpl);
|
||||
};
|
||||
|
||||
// Implements polymorphic Key(matcher_for_key).
|
||||
@ -1957,6 +2048,8 @@ class KeyMatcher {
|
||||
|
||||
private:
|
||||
const M matcher_for_key_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(KeyMatcher);
|
||||
};
|
||||
|
||||
// Implements Pair(first_matcher, second_matcher) for the given argument pair
|
||||
@ -2026,6 +2119,8 @@ class PairMatcherImpl : public MatcherInterface<PairType> {
|
||||
private:
|
||||
const Matcher<const FirstType&> first_matcher_;
|
||||
const Matcher<const SecondType&> second_matcher_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(PairMatcherImpl);
|
||||
};
|
||||
|
||||
// Implements polymorphic Pair(first_matcher, second_matcher).
|
||||
@ -2045,6 +2140,8 @@ class PairMatcher {
|
||||
private:
|
||||
const FirstMatcher first_matcher_;
|
||||
const SecondMatcher second_matcher_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(PairMatcher);
|
||||
};
|
||||
|
||||
// Implements ElementsAre() and ElementsAreArray().
|
||||
@ -2060,10 +2157,10 @@ class ElementsAreMatcherImpl : public MatcherInterface<Container> {
|
||||
// Constructs the matcher from a sequence of element values or
|
||||
// element matchers.
|
||||
template <typename InputIter>
|
||||
ElementsAreMatcherImpl(InputIter first, size_t count) {
|
||||
matchers_.reserve(count);
|
||||
ElementsAreMatcherImpl(InputIter first, size_t a_count) {
|
||||
matchers_.reserve(a_count);
|
||||
InputIter it = first;
|
||||
for (size_t i = 0; i != count; ++i, ++it) {
|
||||
for (size_t i = 0; i != a_count; ++i, ++it) {
|
||||
matchers_.push_back(MatcherCast<const Element&>(*it));
|
||||
}
|
||||
}
|
||||
@ -2185,6 +2282,8 @@ class ElementsAreMatcherImpl : public MatcherInterface<Container> {
|
||||
|
||||
size_t count() const { return matchers_.size(); }
|
||||
std::vector<Matcher<const Element&> > matchers_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(ElementsAreMatcherImpl);
|
||||
};
|
||||
|
||||
// Implements ElementsAre() of 0 arguments.
|
||||
@ -2224,6 +2323,8 @@ class ElementsAreArrayMatcher {
|
||||
private:
|
||||
const T* const first_;
|
||||
const size_t count_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(ElementsAreArrayMatcher);
|
||||
};
|
||||
|
||||
// Constants denoting interpolations in a matcher description string.
|
||||
|
@ -58,8 +58,11 @@ class InvokeAction {
|
||||
Result Perform(const ArgumentTuple& args) {
|
||||
return InvokeHelper<Result, ArgumentTuple>::Invoke(function_impl_, args);
|
||||
}
|
||||
|
||||
private:
|
||||
FunctionImpl function_impl_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(InvokeAction);
|
||||
};
|
||||
|
||||
// Implements the Invoke(object_ptr, &Class::Method) action.
|
||||
@ -74,9 +77,12 @@ class InvokeMethodAction {
|
||||
return InvokeHelper<Result, ArgumentTuple>::InvokeMethod(
|
||||
obj_ptr_, method_ptr_, args);
|
||||
}
|
||||
|
||||
private:
|
||||
Class* const obj_ptr_;
|
||||
const MethodPtr method_ptr_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(InvokeMethodAction);
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
@ -122,6 +128,16 @@ WithArg(const InnerAction& action) {
|
||||
return internal::WithArgsAction<InnerAction, k>(action);
|
||||
}
|
||||
|
||||
// The ACTION*() macros trigger warning C4100 (unreferenced formal
|
||||
// parameter) in MSVC with -W4. Unfortunately they cannot be fixed in
|
||||
// the macro definition, as the warnings are generated when the macro
|
||||
// is expanded and macro expansion cannot contain #pragma. Therefore
|
||||
// we suppress them here.
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4100)
|
||||
#endif
|
||||
|
||||
// Action ReturnArg<k>() returns the k-th argument of the mock function.
|
||||
ACTION_TEMPLATE(ReturnArg,
|
||||
HAS_1_TEMPLATE_PARAMS(int, k),
|
||||
@ -185,6 +201,10 @@ ACTION_TEMPLATE(DeleteArg,
|
||||
ACTION_P(Throw, exception) { throw exception; }
|
||||
#endif // GTEST_HAS_EXCEPTIONS
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
} // namespace testing
|
||||
|
||||
#endif // GMOCK_INCLUDE_GMOCK_GMOCK_MORE_ACTIONS_H_
|
||||
|
@ -409,12 +409,10 @@ inline void PrintTo(const ::string& s, ::std::ostream* os) {
|
||||
}
|
||||
#endif // GTEST_HAS_GLOBAL_STRING
|
||||
|
||||
#if GTEST_HAS_STD_STRING
|
||||
void PrintStringTo(const ::std::string&s, ::std::ostream* os);
|
||||
inline void PrintTo(const ::std::string& s, ::std::ostream* os) {
|
||||
PrintStringTo(s, os);
|
||||
}
|
||||
#endif // GTEST_HAS_STD_STRING
|
||||
|
||||
// Overloads for ::wstring and ::std::wstring.
|
||||
#if GTEST_HAS_GLOBAL_WSTRING
|
||||
@ -434,63 +432,10 @@ inline void PrintTo(const ::std::wstring& s, ::std::ostream* os) {
|
||||
// Overload for ::std::tr1::tuple. Needed for printing function
|
||||
// arguments, which are packed as tuples.
|
||||
|
||||
typedef ::std::vector<string> Strings;
|
||||
|
||||
// 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);
|
||||
*os << ", ";
|
||||
UniversalPrinter<typename ::std::tr1::tuple_element<N - 1, Tuple>::type>
|
||||
::Print(::std::tr1::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(::std::tr1::get<N - 1>(t), &ss);
|
||||
strings->push_back(ss.str());
|
||||
}
|
||||
};
|
||||
|
||||
// Base cases.
|
||||
template <>
|
||||
struct TuplePrefixPrinter<0> {
|
||||
template <typename Tuple>
|
||||
static void PrintPrefixTo(const Tuple&, ::std::ostream*) {}
|
||||
|
||||
template <typename Tuple>
|
||||
static void TersePrintPrefixToStrings(const Tuple&, Strings*) {}
|
||||
};
|
||||
template <>
|
||||
template <typename Tuple>
|
||||
void TuplePrefixPrinter<1>::PrintPrefixTo(const Tuple& t, ::std::ostream* os) {
|
||||
UniversalPrinter<typename ::std::tr1::tuple_element<0, Tuple>::type>::
|
||||
Print(::std::tr1::get<0>(t), os);
|
||||
}
|
||||
|
||||
// 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) {
|
||||
*os << "(";
|
||||
TuplePrefixPrinter< ::std::tr1::tuple_size<T>::value>::
|
||||
PrintPrefixTo(t, os);
|
||||
*os << ")";
|
||||
}
|
||||
void PrintTupleTo(const T& t, ::std::ostream* os);
|
||||
|
||||
// Overloaded PrintTo() for tuples of various arities. We support
|
||||
// tuples of up-to 10 fields. The following implementation works
|
||||
@ -725,6 +670,64 @@ void UniversalPrint(const T& value, ::std::ostream* os) {
|
||||
UniversalPrinter<T>::Print(value, os);
|
||||
}
|
||||
|
||||
typedef ::std::vector<string> Strings;
|
||||
|
||||
// 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);
|
||||
*os << ", ";
|
||||
UniversalPrinter<typename ::std::tr1::tuple_element<N - 1, Tuple>::type>
|
||||
::Print(::std::tr1::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(::std::tr1::get<N - 1>(t), &ss);
|
||||
strings->push_back(ss.str());
|
||||
}
|
||||
};
|
||||
|
||||
// Base cases.
|
||||
template <>
|
||||
struct TuplePrefixPrinter<0> {
|
||||
template <typename Tuple>
|
||||
static void PrintPrefixTo(const Tuple&, ::std::ostream*) {}
|
||||
|
||||
template <typename Tuple>
|
||||
static void TersePrintPrefixToStrings(const Tuple&, Strings*) {}
|
||||
};
|
||||
template <>
|
||||
template <typename Tuple>
|
||||
void TuplePrefixPrinter<1>::PrintPrefixTo(const Tuple& t, ::std::ostream* os) {
|
||||
UniversalPrinter<typename ::std::tr1::tuple_element<0, Tuple>::type>::
|
||||
Print(::std::tr1::get<0>(t), os);
|
||||
}
|
||||
|
||||
// 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) {
|
||||
*os << "(";
|
||||
TuplePrefixPrinter< ::std::tr1::tuple_size<T>::value>::
|
||||
PrintPrefixTo(t, os);
|
||||
*os << ")";
|
||||
}
|
||||
|
||||
// Prints the fields of a tuple tersely to a string vector, one
|
||||
// element for each field. See the comment before
|
||||
// UniversalTersePrint() for how we define "tersely".
|
||||
|
@ -142,10 +142,10 @@ class DefaultActionSpec {
|
||||
|
||||
// Constructs a DefaultActionSpec object from the information inside
|
||||
// the parenthesis of an ON_CALL() statement.
|
||||
DefaultActionSpec(const char* file, int line,
|
||||
DefaultActionSpec(const char* a_file, int a_line,
|
||||
const ArgumentMatcherTuple& matchers)
|
||||
: file_(file),
|
||||
line_(line),
|
||||
: file_(a_file),
|
||||
line_(a_line),
|
||||
matchers_(matchers),
|
||||
// By default, extra_matcher_ should match anything. However,
|
||||
// we cannot initialize it with _ as that triggers a compiler
|
||||
@ -196,6 +196,7 @@ class DefaultActionSpec {
|
||||
"once in an ON_CALL().");
|
||||
return action_;
|
||||
}
|
||||
|
||||
private:
|
||||
// Gives each clause in the ON_CALL() statement a name.
|
||||
enum Clause {
|
||||
@ -561,14 +562,15 @@ extern ThreadLocal<Sequence*> g_gmock_implicit_sequence;
|
||||
// This class is internal and mustn't be used by user code directly.
|
||||
class ExpectationBase {
|
||||
public:
|
||||
ExpectationBase(const char* file, int line);
|
||||
// source_text is the EXPECT_CALL(...) source that created this Expectation.
|
||||
ExpectationBase(const char* file, int line, const string& source_text);
|
||||
|
||||
virtual ~ExpectationBase();
|
||||
|
||||
// Where in the source file was the expectation spec defined?
|
||||
const char* file() const { return file_; }
|
||||
int line() const { return line_; }
|
||||
|
||||
const char* source_text() const { return source_text_.c_str(); }
|
||||
// Returns the cardinality specified in the expectation spec.
|
||||
const Cardinality& cardinality() const { return cardinality_; }
|
||||
|
||||
@ -581,6 +583,7 @@ class ExpectationBase {
|
||||
// expectation has occurred.
|
||||
// L >= g_gmock_mutex
|
||||
virtual void DescribeCallCountTo(::std::ostream* os) const = 0;
|
||||
|
||||
protected:
|
||||
friend class ::testing::Expectation;
|
||||
|
||||
@ -619,8 +622,8 @@ class ExpectationBase {
|
||||
bool cardinality_specified() const { return cardinality_specified_; }
|
||||
|
||||
// Sets the cardinality of this expectation spec.
|
||||
void set_cardinality(const Cardinality& cardinality) {
|
||||
cardinality_ = cardinality;
|
||||
void set_cardinality(const Cardinality& a_cardinality) {
|
||||
cardinality_ = a_cardinality;
|
||||
}
|
||||
|
||||
// The following group of methods should only be called after the
|
||||
@ -697,8 +700,9 @@ class ExpectationBase {
|
||||
|
||||
// This group of fields are part of the spec and won't change after
|
||||
// an EXPECT_CALL() statement finishes.
|
||||
const char* file_; // The file that contains the expectation.
|
||||
int line_; // The line number of the expectation.
|
||||
const char* file_; // The file that contains the expectation.
|
||||
int line_; // The line number of the expectation.
|
||||
const string source_text_; // The EXPECT_CALL(...) source text.
|
||||
// True iff the cardinality is specified explicitly.
|
||||
bool cardinality_specified_;
|
||||
Cardinality cardinality_; // The cardinality of the expectation.
|
||||
@ -714,6 +718,8 @@ class ExpectationBase {
|
||||
// and can change as the mock function is called.
|
||||
int call_count_; // How many times this expectation has been invoked.
|
||||
bool retired_; // True iff this expectation has retired.
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(ExpectationBase);
|
||||
}; // class ExpectationBase
|
||||
|
||||
// Impements an expectation for the given function type.
|
||||
@ -724,11 +730,13 @@ class TypedExpectation : public ExpectationBase {
|
||||
typedef typename Function<F>::ArgumentMatcherTuple ArgumentMatcherTuple;
|
||||
typedef typename Function<F>::Result Result;
|
||||
|
||||
TypedExpectation(FunctionMockerBase<F>* owner, const char* file, int line,
|
||||
TypedExpectation(FunctionMockerBase<F>* owner,
|
||||
const char* a_file, int a_line, const string& a_source_text,
|
||||
const ArgumentMatcherTuple& m)
|
||||
: ExpectationBase(file, line),
|
||||
: ExpectationBase(a_file, a_line, a_source_text),
|
||||
owner_(owner),
|
||||
matchers_(m),
|
||||
extra_matcher_specified_(false),
|
||||
// By default, extra_matcher_ should match anything. However,
|
||||
// we cannot initialize it with _ as that triggers a compiler
|
||||
// bug in Symbian's C++ compiler (cannot decide between two
|
||||
@ -760,11 +768,12 @@ class TypedExpectation : public ExpectationBase {
|
||||
last_clause_ = kWith;
|
||||
|
||||
extra_matcher_ = m;
|
||||
extra_matcher_specified_ = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Implements the .Times() clause.
|
||||
TypedExpectation& Times(const Cardinality& cardinality) {
|
||||
TypedExpectation& Times(const Cardinality& a_cardinality) {
|
||||
if (last_clause_ ==kTimes) {
|
||||
ExpectSpecProperty(false,
|
||||
".Times() cannot appear "
|
||||
@ -777,7 +786,7 @@ class TypedExpectation : public ExpectationBase {
|
||||
}
|
||||
last_clause_ = kTimes;
|
||||
|
||||
ExpectationBase::SpecifyCardinality(cardinality);
|
||||
ExpectationBase::SpecifyCardinality(a_cardinality);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -938,6 +947,15 @@ class TypedExpectation : public ExpectationBase {
|
||||
<< " and "
|
||||
<< (is_retired() ? "retired" : "active");
|
||||
}
|
||||
|
||||
void MaybeDescribeExtraMatcherTo(::std::ostream* os) {
|
||||
if (extra_matcher_specified_) {
|
||||
*os << " Expected args: ";
|
||||
extra_matcher_.DescribeTo(os);
|
||||
*os << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename Function>
|
||||
friend class FunctionMockerBase;
|
||||
@ -1034,7 +1052,7 @@ class TypedExpectation : public ExpectationBase {
|
||||
// we warn the user when the WillOnce() clauses ran out.
|
||||
::std::stringstream ss;
|
||||
DescribeLocationTo(&ss);
|
||||
ss << "Actions ran out.\n"
|
||||
ss << "Actions ran out in " << source_text() << "...\n"
|
||||
<< "Called " << count << " times, but only "
|
||||
<< action_count << " WillOnce()"
|
||||
<< (action_count == 1 ? " is" : "s are") << " specified - ";
|
||||
@ -1078,7 +1096,7 @@ class TypedExpectation : public ExpectationBase {
|
||||
}
|
||||
|
||||
// Must be done after IncrementCount()!
|
||||
*what << "Expected mock function call.\n";
|
||||
*what << "Mock function call matches " << source_text() <<"...\n";
|
||||
return GetCurrentAction(mocker, args);
|
||||
}
|
||||
|
||||
@ -1123,7 +1141,7 @@ class TypedExpectation : public ExpectationBase {
|
||||
::std::stringstream ss;
|
||||
DescribeLocationTo(&ss);
|
||||
ss << "Too " << (too_many ? "many" : "few")
|
||||
<< " actions specified.\n"
|
||||
<< " actions specified in " << source_text() << "...\n"
|
||||
<< "Expected to be ";
|
||||
cardinality().DescribeTo(&ss);
|
||||
ss << ", but has " << (too_many ? "" : "only ")
|
||||
@ -1141,6 +1159,7 @@ class TypedExpectation : public ExpectationBase {
|
||||
// statement finishes.
|
||||
FunctionMockerBase<F>* const owner_;
|
||||
ArgumentMatcherTuple matchers_;
|
||||
bool extra_matcher_specified_;
|
||||
Matcher<const ArgumentTuple&> extra_matcher_;
|
||||
std::vector<Action<F> > actions_;
|
||||
bool repeated_action_specified_; // True if a WillRepeatedly() was specified.
|
||||
@ -1149,6 +1168,8 @@ class TypedExpectation : public ExpectationBase {
|
||||
Clause last_clause_;
|
||||
mutable bool action_count_checked_; // Under mutex_.
|
||||
mutable Mutex mutex_; // Protects action_count_checked_.
|
||||
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(TypedExpectation);
|
||||
}; // class TypedExpectation
|
||||
|
||||
// A MockSpec object is used by ON_CALL() or EXPECT_CALL() for
|
||||
@ -1186,9 +1207,10 @@ class MockSpec {
|
||||
// the newly created spec.
|
||||
internal::TypedExpectation<F>& InternalExpectedAt(
|
||||
const char* file, int line, const char* obj, const char* call) {
|
||||
LogWithLocation(internal::INFO, file, line,
|
||||
string("EXPECT_CALL(") + obj + ", " + call + ") invoked");
|
||||
return function_mocker_->AddNewExpectation(file, line, matchers_);
|
||||
const string source_text(string("EXPECT_CALL(") + obj + ", " + call + ")");
|
||||
LogWithLocation(internal::INFO, file, line, source_text + " invoked");
|
||||
return function_mocker_->AddNewExpectation(
|
||||
file, line, source_text, matchers_);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -1212,6 +1234,8 @@ class MockSpec {
|
||||
internal::FunctionMockerBase<F>* const function_mocker_;
|
||||
// The argument matchers specified in the spec.
|
||||
ArgumentMatcherTuple matchers_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(MockSpec);
|
||||
}; // class MockSpec
|
||||
|
||||
// MSVC warns about using 'this' in base member initializer list, so
|
||||
@ -1235,7 +1259,7 @@ class MockSpec {
|
||||
template <typename T>
|
||||
class ActionResultHolder {
|
||||
public:
|
||||
explicit ActionResultHolder(T value) : value_(value) {}
|
||||
explicit ActionResultHolder(T a_value) : value_(a_value) {}
|
||||
|
||||
// The compiler-generated copy constructor and assignment operator
|
||||
// are exactly what we need, so we don't need to define them.
|
||||
@ -1269,6 +1293,9 @@ class ActionResultHolder {
|
||||
|
||||
private:
|
||||
T value_;
|
||||
|
||||
// T could be a reference type, so = isn't supported.
|
||||
GTEST_DISALLOW_ASSIGN_(ActionResultHolder);
|
||||
};
|
||||
|
||||
// Specialization for T = void.
|
||||
@ -1417,6 +1444,7 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
protected:
|
||||
template <typename Function>
|
||||
friend class MockSpec;
|
||||
@ -1440,11 +1468,13 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
|
||||
// Adds and returns an expectation spec for this mock function.
|
||||
// L < g_gmock_mutex
|
||||
TypedExpectation<F>& AddNewExpectation(
|
||||
const char* file, int line,
|
||||
const char* file,
|
||||
int line,
|
||||
const string& source_text,
|
||||
const ArgumentMatcherTuple& m) {
|
||||
Mock::RegisterUseByOnCallOrExpectCall(MockObject(), file, line);
|
||||
const linked_ptr<TypedExpectation<F> > expectation(
|
||||
new TypedExpectation<F>(this, file, line, m));
|
||||
new TypedExpectation<F>(this, file, line, source_text, m));
|
||||
expectations_.push_back(expectation);
|
||||
|
||||
// Adds this expectation into the implicit sequence if there is one.
|
||||
@ -1459,6 +1489,7 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
|
||||
// The current spec (either default action spec or expectation spec)
|
||||
// being described on this function mocker.
|
||||
MockSpec<F>& current_spec() { return current_spec_; }
|
||||
|
||||
private:
|
||||
template <typename Func> friend class TypedExpectation;
|
||||
|
||||
@ -1584,9 +1615,9 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
|
||||
*why << "\n";
|
||||
expectations_[i]->DescribeLocationTo(why);
|
||||
if (count > 1) {
|
||||
*why << "tried expectation #" << i;
|
||||
*why << "tried expectation #" << i << ": ";
|
||||
}
|
||||
*why << "\n";
|
||||
*why << expectations_[i]->source_text() << "...\n";
|
||||
expectations_[i]->DescribeMatchResultTo(args, why);
|
||||
expectations_[i]->DescribeCallCountTo(why);
|
||||
}
|
||||
@ -1651,10 +1682,12 @@ bool FunctionMockerBase<F>::VerifyAndClearExpectationsLocked() {
|
||||
} else if (!exp->IsSatisfied()) {
|
||||
expectations_met = false;
|
||||
::std::stringstream ss;
|
||||
ss << "Actual function call count doesn't match this expectation.\n";
|
||||
ss << "Actual function call count doesn't match "
|
||||
<< exp->source_text() << "...\n";
|
||||
// No need to show the source file location of the expectation
|
||||
// in the description, as the Expect() call that follows already
|
||||
// takes care of it.
|
||||
exp->MaybeDescribeExtraMatcherTo(&ss);
|
||||
exp->DescribeCallCountTo(&ss);
|
||||
Expect(false, exp->file(), exp->line(), ss.str());
|
||||
}
|
||||
|
@ -640,15 +640,15 @@ class NativeArray {
|
||||
|
||||
// Initializes this object; makes a copy of the input array if
|
||||
// 'relation' is kCopy.
|
||||
void Init(const Element* array, size_t size, RelationToSource relation) {
|
||||
void Init(const Element* array, size_t a_size, RelationToSource relation) {
|
||||
if (relation == kReference) {
|
||||
array_ = array;
|
||||
} else {
|
||||
Element* const copy = new Element[size];
|
||||
CopyArray(array, size, copy);
|
||||
Element* const copy = new Element[a_size];
|
||||
CopyArray(array, a_size, copy);
|
||||
array_ = copy;
|
||||
}
|
||||
size_ = size;
|
||||
size_ = a_size;
|
||||
relation_to_source_ = relation;
|
||||
}
|
||||
|
||||
|
@ -81,27 +81,22 @@ namespace internal {
|
||||
#error "At least Visual C++ 2003 (7.1) is required to compile Google Mock."
|
||||
#endif
|
||||
|
||||
// Use implicit_cast as a safe version of static_cast or const_cast
|
||||
// for upcasting in the type hierarchy (i.e. casting a pointer to Foo
|
||||
// to a pointer to SuperclassOfFoo or casting a pointer to Foo to
|
||||
// a const pointer to Foo).
|
||||
// When you use implicit_cast, the compiler checks that the cast is safe.
|
||||
// Such explicit implicit_casts are necessary in surprisingly many
|
||||
// situations where C++ demands an exact type match instead of an
|
||||
// argument type convertable to a target type.
|
||||
// Use implicit_cast as a safe version of static_cast for upcasting in
|
||||
// the type hierarchy (e.g. casting a Foo* to a SuperclassOfFoo* or a
|
||||
// const Foo*). When you use implicit_cast, the compiler checks that
|
||||
// the cast is safe. Such explicit implicit_casts are necessary in
|
||||
// surprisingly many situations where C++ demands an exact type match
|
||||
// instead of an argument type convertable to a target type.
|
||||
//
|
||||
// The From type can be inferred, so the preferred syntax for using
|
||||
// implicit_cast is the same as for static_cast etc.:
|
||||
// The syntax for using implicit_cast is the same as for static_cast:
|
||||
//
|
||||
// implicit_cast<ToType>(expr)
|
||||
//
|
||||
// implicit_cast would have been part of the C++ standard library,
|
||||
// but the proposal was submitted too late. It will probably make
|
||||
// its way into the language in the future.
|
||||
template<typename To, typename From>
|
||||
inline To implicit_cast(From const &f) {
|
||||
return f;
|
||||
}
|
||||
template<typename To>
|
||||
inline To implicit_cast(To x) { return x; }
|
||||
|
||||
// When you upcast (that is, cast a pointer from type Foo to type
|
||||
// SuperclassOfFoo), it's fine to use implicit_cast<>, since upcasts
|
||||
@ -127,7 +122,8 @@ inline To down_cast(From* f) { // so we only accept pointers
|
||||
// optimized build at run-time, as it will be optimized away
|
||||
// completely.
|
||||
if (false) {
|
||||
implicit_cast<From*, To>(0);
|
||||
const To to = NULL;
|
||||
::testing::internal::implicit_cast<From*>(to);
|
||||
}
|
||||
|
||||
#if GTEST_HAS_RTTI
|
||||
@ -202,10 +198,8 @@ struct CompileAssert {
|
||||
|
||||
#if GTEST_HAS_GLOBAL_STRING
|
||||
typedef ::string string;
|
||||
#elif GTEST_HAS_STD_STRING
|
||||
typedef ::std::string string;
|
||||
#else
|
||||
#error "Google Mock requires ::std::string to compile."
|
||||
typedef ::std::string string;
|
||||
#endif // GTEST_HAS_GLOBAL_STRING
|
||||
|
||||
#if GTEST_HAS_GLOBAL_WSTRING
|
||||
|
0
testing/gmock/msvc/gmock-spec-builders_test.vcproj
Normal file → Executable file
0
testing/gmock/msvc/gmock-spec-builders_test.vcproj
Normal file → Executable file
@ -7,8 +7,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gmock_test", "gmock_test.vc
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gmock_link_test", "gmock_link_test.vcproj", "{ED597847-A714-4327-B569-70029D2311F0}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gmock_output_test_", "gmock_output_test_.vcproj", "{EDCE4C87-C2C0-4D22-98AC-7B6466F89A15}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gmock_main", "gmock_main.vcproj", "{E4EF614B-30DF-4954-8C53-580A0BF6B589}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gmock-spec-builders_test", "gmock-spec-builders_test.vcproj", "{46972604-5BE0-4493-BAE3-878DB825FDCB}"
|
||||
@ -31,10 +29,6 @@ Global
|
||||
{ED597847-A714-4327-B569-70029D2311F0}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{ED597847-A714-4327-B569-70029D2311F0}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{ED597847-A714-4327-B569-70029D2311F0}.Release|Win32.Build.0 = Release|Win32
|
||||
{EDCE4C87-C2C0-4D22-98AC-7B6466F89A15}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{EDCE4C87-C2C0-4D22-98AC-7B6466F89A15}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{EDCE4C87-C2C0-4D22-98AC-7B6466F89A15}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{EDCE4C87-C2C0-4D22-98AC-7B6466F89A15}.Release|Win32.Build.0 = Release|Win32
|
||||
{E4EF614B-30DF-4954-8C53-580A0BF6B589}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{E4EF614B-30DF-4954-8C53-580A0BF6B589}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{E4EF614B-30DF-4954-8C53-580A0BF6B589}.Release|Win32.ActiveCfg = Release|Win32
|
||||
|
@ -1,199 +0,0 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="8.00"
|
||||
Name="gmock_output_test_"
|
||||
ProjectGUID="{EDCE4C87-C2C0-4D22-98AC-7B6466F89A15}"
|
||||
RootNamespace="gmock_output_test_"
|
||||
Keyword="Win32Proj"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(OutDir)\$(ProjectName)"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets=".\gmock_config.vsprops"
|
||||
CharacterSet="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
LinkIncremental="2"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(OutDir)\$(ProjectName)"
|
||||
ConfigurationType="1"
|
||||
InheritedPropertySheets=".\gmock_config.vsprops"
|
||||
CharacterSet="1"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
RuntimeLibrary="0"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
LinkIncremental="1"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
<ProjectReference
|
||||
ReferencedProjectIdentifier="{34681F0D-CE45-415D-B5F2-5C662DFE3BD5}"
|
||||
RelativePathToProject=".\gmock.vcproj"
|
||||
/>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\test\gmock_output_test_.cc"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
0
testing/gmock/scripts/fuse_gmock_files.py
Normal file → Executable file
0
testing/gmock/scripts/fuse_gmock_files.py
Normal file → Executable file
0
testing/gmock/scripts/generator/cpp/__init__.py
Normal file → Executable file
0
testing/gmock/scripts/generator/cpp/__init__.py
Normal file → Executable file
0
testing/gmock/scripts/generator/cpp/ast.py
Normal file → Executable file
0
testing/gmock/scripts/generator/cpp/ast.py
Normal file → Executable file
0
testing/gmock/scripts/generator/cpp/gmock_class.py
Normal file → Executable file
0
testing/gmock/scripts/generator/cpp/gmock_class.py
Normal file → Executable file
0
testing/gmock/scripts/generator/cpp/gmock_class_test.py
Normal file → Executable file
0
testing/gmock/scripts/generator/cpp/gmock_class_test.py
Normal file → Executable file
0
testing/gmock/scripts/generator/cpp/keywords.py
Normal file → Executable file
0
testing/gmock/scripts/generator/cpp/keywords.py
Normal file → Executable file
0
testing/gmock/scripts/generator/cpp/tokenize.py
Normal file → Executable file
0
testing/gmock/scripts/generator/cpp/tokenize.py
Normal file → Executable file
0
testing/gmock/scripts/generator/cpp/utils.py
Normal file → Executable file
0
testing/gmock/scripts/generator/cpp/utils.py
Normal file → Executable file
0
testing/gmock/scripts/generator/gmock_gen.py
Normal file → Executable file
0
testing/gmock/scripts/generator/gmock_gen.py
Normal file → Executable file
0
testing/gmock/scripts/gmock-config.in
Normal file → Executable file
0
testing/gmock/scripts/gmock-config.in
Normal file → Executable file
42
testing/gmock/scripts/gmock_doctor.py
Normal file → Executable file
42
testing/gmock/scripts/gmock_doctor.py
Normal file → Executable file
@ -186,8 +186,9 @@ def _NeedToReturnNothingDiagnoser(msg):
|
||||
"""Diagnoses the NRN disease, given the error messages by gcc."""
|
||||
|
||||
regex = (_FILE_LINE_RE + r'instantiated from here\n'
|
||||
r'.*gmock-actions\.h.*error: return-statement with a value, '
|
||||
r'in function returning \'void\'')
|
||||
r'.*gmock-actions\.h.*error: instantiation of '
|
||||
r'\'testing::internal::ReturnAction<R>::Impl<F>::value_\' '
|
||||
r'as type \'void\'')
|
||||
diagnosis = """
|
||||
You are using an action that returns *something*, but it needs to return
|
||||
void. Please use a void-returning action instead.
|
||||
@ -336,12 +337,14 @@ Did you forget to write
|
||||
def _NeedToUseReturnNullDiagnoser(msg):
|
||||
"""Diagnoses the NRNULL disease, given the error messages by gcc."""
|
||||
|
||||
regex = (_FILE_LINE_RE + r'instantiated from here\n'
|
||||
r'.*gmock-actions\.h.*error: invalid conversion from '
|
||||
r'\'long int\' to \'(?P<type>.+\*)')
|
||||
regex = ('instantiated from \'testing::internal::ReturnAction<R>'
|
||||
'::operator testing::Action<Func>\(\) const.*\n' +
|
||||
_FILE_LINE_RE + r'instantiated from here\n'
|
||||
r'.*error: no matching function for call to \'implicit_cast\('
|
||||
r'long int&\)')
|
||||
diagnosis = """
|
||||
You are probably calling Return(NULL) and the compiler isn't sure how to turn
|
||||
NULL into a %(type)s*. Use ReturnNull() instead.
|
||||
NULL into the right type. Use ReturnNull() instead.
|
||||
Note: the line number may be off; please fix all instances of Return(NULL)."""
|
||||
return _GenericDiagnoser('NRNULL', 'Need to use ReturnNull',
|
||||
regex, diagnosis, msg)
|
||||
@ -363,11 +366,17 @@ def _TypeInTemplatedBaseDiagnoser1(msg):
|
||||
type.
|
||||
"""
|
||||
|
||||
regex = (r'In member function \'int .*\n' + _FILE_LINE_RE +
|
||||
r'error: a function call cannot appear in a constant-expression')
|
||||
gcc_4_3_1_regex = (
|
||||
r'In member function \'int .*\n' + _FILE_LINE_RE +
|
||||
r'error: a function call cannot appear in a constant-expression')
|
||||
gcc_4_4_0_regex = (
|
||||
r'error: a function call cannot appear in a constant-expression'
|
||||
+ _FILE_LINE_RE + r'error: template argument 1 is invalid\n')
|
||||
diagnosis = _TTB_DIAGNOSIS % {'type': 'Foo'}
|
||||
return _GenericDiagnoser('TTB', 'Type in Template Base',
|
||||
regex, diagnosis, msg)
|
||||
return (list(_GenericDiagnoser('TTB', 'Type in Template Base',
|
||||
gcc_4_3_1_regex, diagnosis, msg)) +
|
||||
list(_GenericDiagnoser('TTB', 'Type in Template Base',
|
||||
gcc_4_4_0_regex, diagnosis, msg)))
|
||||
|
||||
|
||||
def _TypeInTemplatedBaseDiagnoser2(msg):
|
||||
@ -377,8 +386,7 @@ def _TypeInTemplatedBaseDiagnoser2(msg):
|
||||
parameter type.
|
||||
"""
|
||||
|
||||
regex = (r'In member function \'int .*\n'
|
||||
+ _FILE_LINE_RE +
|
||||
regex = (_FILE_LINE_RE +
|
||||
r'error: \'(?P<type>.+)\' was not declared in this scope\n'
|
||||
r'.*error: template argument 1 is invalid\n')
|
||||
return _GenericDiagnoser('TTB', 'Type in Template Base',
|
||||
@ -455,9 +463,13 @@ _DIAGNOSERS = [
|
||||
def Diagnose(msg):
|
||||
"""Generates all possible diagnoses given the gcc error message."""
|
||||
|
||||
diagnoses = []
|
||||
for diagnoser in _DIAGNOSERS:
|
||||
for diagnosis in diagnoser(msg):
|
||||
yield '[%s - %s]\n%s' % diagnosis
|
||||
for diag in diagnoser(msg):
|
||||
diagnosis = '[%s - %s]\n%s' % diag
|
||||
if not diagnosis in diagnoses:
|
||||
diagnoses.append(diagnosis)
|
||||
return diagnoses
|
||||
|
||||
|
||||
def main():
|
||||
@ -471,7 +483,7 @@ def main():
|
||||
print 'Waiting for compiler errors on stdin . . .'
|
||||
|
||||
msg = sys.stdin.read().strip()
|
||||
diagnoses = list(Diagnose(msg))
|
||||
diagnoses = Diagnose(msg)
|
||||
count = len(diagnoses)
|
||||
if not count:
|
||||
print '\nGcc complained:'
|
||||
|
0
testing/gmock/scripts/upload.py
Normal file → Executable file
0
testing/gmock/scripts/upload.py
Normal file → Executable file
0
testing/gmock/scripts/upload_gmock.py
Normal file → Executable file
0
testing/gmock/scripts/upload_gmock.py
Normal file → Executable file
@ -35,6 +35,11 @@
|
||||
// purpose is to allow a user to build Google Mock by compiling this
|
||||
// file alone.
|
||||
|
||||
// This line ensures that gmock.h can be compiled on its own, even
|
||||
// when it's fused.
|
||||
#include <gmock/gmock.h>
|
||||
|
||||
// The following lines pull in the real gmock *.cc files.
|
||||
#include "src/gmock-cardinalities.cc"
|
||||
#include "src/gmock-internal-utils.cc"
|
||||
#include "src/gmock-matchers.cc"
|
||||
|
@ -64,7 +64,7 @@ string ConvertIdentifierNameToWords(const char* id_name) {
|
||||
if (isalnum(*p)) {
|
||||
if (starts_new_word && result != "")
|
||||
result += ' ';
|
||||
result += tolower(*p);
|
||||
result += static_cast<char>(tolower(*p));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
@ -83,18 +83,6 @@ int GetParamIndex(const char* param_names[], const string& param_name) {
|
||||
return kInvalidInterpolation;
|
||||
}
|
||||
|
||||
// If *pstr starts with the given prefix, modifies *pstr to be right
|
||||
// past the prefix and returns true; otherwise leaves *pstr unchanged
|
||||
// and returns false. None of pstr, *pstr, and prefix can be NULL.
|
||||
bool SkipPrefix(const char* prefix, const char** pstr) {
|
||||
const size_t prefix_len = strlen(prefix);
|
||||
if (strncmp(*pstr, prefix, prefix_len) == 0) {
|
||||
*pstr += prefix_len;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Helper function used by ValidateMatcherDescription() to format
|
||||
// error messages.
|
||||
string FormatMatcherDescriptionSyntaxError(const char* description,
|
||||
|
@ -296,11 +296,9 @@ void PrintStringTo(const ::string& s, ostream* os) {
|
||||
}
|
||||
#endif // GTEST_HAS_GLOBAL_STRING
|
||||
|
||||
#if GTEST_HAS_STD_STRING
|
||||
void PrintStringTo(const ::std::string& s, ostream* os) {
|
||||
PrintCharsAsStringTo(s.data(), s.size(), os);
|
||||
}
|
||||
#endif // GTEST_HAS_STD_STRING
|
||||
|
||||
// Prints a ::wstring object.
|
||||
#if GTEST_HAS_GLOBAL_WSTRING
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include <iostream> // NOLINT
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <gmock/gmock.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
@ -55,9 +56,12 @@ namespace internal {
|
||||
Mutex g_gmock_mutex(Mutex::NO_CONSTRUCTOR_NEEDED_FOR_STATIC_MUTEX);
|
||||
|
||||
// Constructs an ExpectationBase object.
|
||||
ExpectationBase::ExpectationBase(const char* file, int line)
|
||||
: file_(file),
|
||||
line_(line),
|
||||
ExpectationBase::ExpectationBase(const char* a_file,
|
||||
int a_line,
|
||||
const string& a_source_text)
|
||||
: file_(a_file),
|
||||
line_(a_line),
|
||||
source_text_(a_source_text),
|
||||
cardinality_specified_(false),
|
||||
cardinality_(Exactly(1)),
|
||||
call_count_(0),
|
||||
@ -69,9 +73,9 @@ ExpectationBase::~ExpectationBase() {}
|
||||
|
||||
// Explicitly specifies the cardinality of this expectation. Used by
|
||||
// the subclasses to implement the .Times() clause.
|
||||
void ExpectationBase::SpecifyCardinality(const Cardinality& cardinality) {
|
||||
void ExpectationBase::SpecifyCardinality(const Cardinality& a_cardinality) {
|
||||
cardinality_specified_ = true;
|
||||
cardinality_ = cardinality;
|
||||
cardinality_ = a_cardinality;
|
||||
}
|
||||
|
||||
// Retires all pre-requisites of this expectation.
|
||||
@ -423,8 +427,8 @@ void Mock::ClearDefaultActionsLocked(void* mock_obj) {
|
||||
Expectation::Expectation() {}
|
||||
|
||||
Expectation::Expectation(
|
||||
const internal::linked_ptr<internal::ExpectationBase>& expectation_base)
|
||||
: expectation_base_(expectation_base) {}
|
||||
const internal::linked_ptr<internal::ExpectationBase>& an_expectation_base)
|
||||
: expectation_base_(an_expectation_base) {}
|
||||
|
||||
Expectation::~Expectation() {}
|
||||
|
||||
|
@ -95,26 +95,26 @@ TEST(BuiltInDefaultValueTest, ExistsForPointerTypes) {
|
||||
// Tests that BuiltInDefaultValue<T>::Get() returns 0 when T is a
|
||||
// built-in numeric type.
|
||||
TEST(BuiltInDefaultValueTest, IsZeroForNumericTypes) {
|
||||
EXPECT_EQ(0, BuiltInDefaultValue<unsigned char>::Get());
|
||||
EXPECT_EQ(0U, BuiltInDefaultValue<unsigned char>::Get());
|
||||
EXPECT_EQ(0, BuiltInDefaultValue<signed char>::Get());
|
||||
EXPECT_EQ(0, BuiltInDefaultValue<char>::Get());
|
||||
#if GMOCK_HAS_SIGNED_WCHAR_T_
|
||||
EXPECT_EQ(0, BuiltInDefaultValue<unsigned wchar_t>::Get());
|
||||
EXPECT_EQ(0U, BuiltInDefaultValue<unsigned wchar_t>::Get());
|
||||
EXPECT_EQ(0, BuiltInDefaultValue<signed wchar_t>::Get());
|
||||
#endif
|
||||
#if GMOCK_WCHAR_T_IS_NATIVE_
|
||||
EXPECT_EQ(0, BuiltInDefaultValue<wchar_t>::Get());
|
||||
#endif
|
||||
EXPECT_EQ(0, BuiltInDefaultValue<unsigned short>::Get()); // NOLINT
|
||||
EXPECT_EQ(0U, BuiltInDefaultValue<unsigned short>::Get()); // NOLINT
|
||||
EXPECT_EQ(0, BuiltInDefaultValue<signed short>::Get()); // NOLINT
|
||||
EXPECT_EQ(0, BuiltInDefaultValue<short>::Get()); // NOLINT
|
||||
EXPECT_EQ(0, BuiltInDefaultValue<unsigned int>::Get());
|
||||
EXPECT_EQ(0U, BuiltInDefaultValue<unsigned int>::Get());
|
||||
EXPECT_EQ(0, BuiltInDefaultValue<signed int>::Get());
|
||||
EXPECT_EQ(0, BuiltInDefaultValue<int>::Get());
|
||||
EXPECT_EQ(0, BuiltInDefaultValue<unsigned long>::Get()); // NOLINT
|
||||
EXPECT_EQ(0U, BuiltInDefaultValue<unsigned long>::Get()); // NOLINT
|
||||
EXPECT_EQ(0, BuiltInDefaultValue<signed long>::Get()); // NOLINT
|
||||
EXPECT_EQ(0, BuiltInDefaultValue<long>::Get()); // NOLINT
|
||||
EXPECT_EQ(0, BuiltInDefaultValue<UInt64>::Get());
|
||||
EXPECT_EQ(0U, BuiltInDefaultValue<UInt64>::Get());
|
||||
EXPECT_EQ(0, BuiltInDefaultValue<Int64>::Get());
|
||||
EXPECT_EQ(0, BuiltInDefaultValue<float>::Get());
|
||||
EXPECT_EQ(0, BuiltInDefaultValue<double>::Get());
|
||||
@ -165,9 +165,7 @@ TEST(BuiltInDefaultValueTest, IsEmptyStringForString) {
|
||||
EXPECT_EQ("", BuiltInDefaultValue< ::string>::Get());
|
||||
#endif // GTEST_HAS_GLOBAL_STRING
|
||||
|
||||
#if GTEST_HAS_STD_STRING
|
||||
EXPECT_EQ("", BuiltInDefaultValue< ::std::string>::Get());
|
||||
#endif // GTEST_HAS_STD_STRING
|
||||
}
|
||||
|
||||
// Tests that BuiltInDefaultValue<T>::Exists() returns true when T is a
|
||||
@ -177,9 +175,7 @@ TEST(BuiltInDefaultValueTest, ExistsForString) {
|
||||
EXPECT_TRUE(BuiltInDefaultValue< ::string>::Exists());
|
||||
#endif // GTEST_HAS_GLOBAL_STRING
|
||||
|
||||
#if GTEST_HAS_STD_STRING
|
||||
EXPECT_TRUE(BuiltInDefaultValue< ::std::string>::Exists());
|
||||
#endif // GTEST_HAS_STD_STRING
|
||||
}
|
||||
|
||||
// Tests that BuiltInDefaultValue<const T>::Get() returns the same
|
||||
@ -515,6 +511,51 @@ TEST(ReturnTest, IsCovariant) {
|
||||
EXPECT_EQ(&derived, ret.Perform(make_tuple()));
|
||||
}
|
||||
|
||||
// Tests that the type of the value passed into Return is converted into T
|
||||
// when the action is cast to Action<T(...)> rather than when the action is
|
||||
// performed. See comments on testing::internal::ReturnAction in
|
||||
// gmock-actions.h for more information.
|
||||
class FromType {
|
||||
public:
|
||||
FromType(bool* is_converted) : converted_(is_converted) {}
|
||||
bool* converted() const { return converted_; }
|
||||
|
||||
private:
|
||||
bool* const converted_;
|
||||
|
||||
GTEST_DISALLOW_ASSIGN_(FromType);
|
||||
};
|
||||
|
||||
class ToType {
|
||||
public:
|
||||
ToType(const FromType& x) { *x.converted() = true; }
|
||||
};
|
||||
|
||||
TEST(ReturnTest, ConvertsArgumentWhenConverted) {
|
||||
bool converted = false;
|
||||
FromType x(&converted);
|
||||
Action<ToType()> action(Return(x));
|
||||
EXPECT_TRUE(converted) << "Return must convert its argument in its own "
|
||||
<< "conversion operator.";
|
||||
converted = false;
|
||||
action.Perform(tuple<>());
|
||||
EXPECT_FALSE(converted) << "Action must NOT convert its argument "
|
||||
<< "when performed." ;
|
||||
}
|
||||
|
||||
class DestinationType {};
|
||||
|
||||
class SourceType {
|
||||
public:
|
||||
// Note: a non-const typecast operator.
|
||||
operator DestinationType() { return DestinationType(); }
|
||||
};
|
||||
|
||||
TEST(ReturnTest, CanConvertArgumentUsingNonConstTypeCastOperator) {
|
||||
SourceType s;
|
||||
Action<DestinationType()> action(Return(s));
|
||||
}
|
||||
|
||||
// Tests that ReturnNull() returns NULL in a pointer-returning function.
|
||||
TEST(ReturnNullTest, WorksInPointerReturningFunction) {
|
||||
const Action<int*()> a1 = ReturnNull();
|
||||
@ -549,8 +590,13 @@ class MyClass {};
|
||||
|
||||
class MockClass {
|
||||
public:
|
||||
MockClass() {}
|
||||
|
||||
MOCK_METHOD1(IntFunc, int(bool flag)); // NOLINT
|
||||
MOCK_METHOD0(Foo, MyClass());
|
||||
|
||||
private:
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockClass);
|
||||
};
|
||||
|
||||
// Tests that DoDefault() returns the built-in default value for the
|
||||
@ -576,7 +622,7 @@ TEST(DoDefaultDeathTest, DiesForUnknowType) {
|
||||
// Tests that using DoDefault() inside a composite action leads to a
|
||||
// run-time error.
|
||||
|
||||
void VoidFunc(bool flag) {}
|
||||
void VoidFunc(bool /* flag */) {}
|
||||
|
||||
TEST(DoDefaultDeathTest, DiesIfUsedInCompositeAction) {
|
||||
MockClass mock;
|
||||
@ -762,7 +808,7 @@ bool Unary(int x) { return x < 0; }
|
||||
|
||||
const char* Plus1(const char* s) { return s + 1; }
|
||||
|
||||
void VoidUnary(int n) { g_done = true; }
|
||||
void VoidUnary(int /* n */) { g_done = true; }
|
||||
|
||||
bool ByConstRef(const std::string& s) { return s == "Hi"; }
|
||||
|
||||
@ -831,7 +877,7 @@ TEST(InvokeWithoutArgsTest, Function) {
|
||||
EXPECT_EQ(1, a.Perform(make_tuple(2)));
|
||||
|
||||
// As an action that takes two arguments.
|
||||
Action<short(int, double)> a2 = InvokeWithoutArgs(Nullary); // NOLINT
|
||||
Action<int(int, double)> a2 = InvokeWithoutArgs(Nullary); // NOLINT
|
||||
EXPECT_EQ(1, a2.Perform(make_tuple(2, 3.5)));
|
||||
|
||||
// As an action that returns void.
|
||||
@ -848,7 +894,7 @@ TEST(InvokeWithoutArgsTest, Functor) {
|
||||
EXPECT_EQ(2, a.Perform(make_tuple()));
|
||||
|
||||
// As an action that takes three arguments.
|
||||
Action<short(int, double, char)> a2 = // NOLINT
|
||||
Action<int(int, double, char)> a2 = // NOLINT
|
||||
InvokeWithoutArgs(NullaryFunctor());
|
||||
EXPECT_EQ(2, a2.Perform(make_tuple(3, 3.5, 'a')));
|
||||
|
||||
@ -889,7 +935,7 @@ TEST(IgnoreResultTest, MonomorphicAction) {
|
||||
|
||||
// Tests using IgnoreResult() on an action that returns a class type.
|
||||
|
||||
MyClass ReturnMyClass(double x) {
|
||||
MyClass ReturnMyClass(double /* x */) {
|
||||
g_done = true;
|
||||
return MyClass();
|
||||
}
|
||||
|
@ -52,7 +52,11 @@ using testing::MakeCardinality;
|
||||
|
||||
class MockFoo {
|
||||
public:
|
||||
MockFoo() {}
|
||||
MOCK_METHOD0(Bar, int()); // NOLINT
|
||||
|
||||
private:
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFoo);
|
||||
};
|
||||
|
||||
// Tests that Cardinality objects can be default constructed.
|
||||
@ -398,7 +402,9 @@ class EvenCardinality : public CardinalityInterface {
|
||||
}
|
||||
|
||||
// Returns true iff call_count calls will saturate this cardinality.
|
||||
virtual bool IsSaturatedByCallCount(int call_count) const { return false; }
|
||||
virtual bool IsSaturatedByCallCount(int /* call_count */) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Describes self to an ostream.
|
||||
virtual void DescribeTo(::std::ostream* ss) const {
|
||||
|
@ -63,6 +63,10 @@ using testing::StaticAssertTypeEq;
|
||||
using testing::Unused;
|
||||
using testing::WithArgs;
|
||||
|
||||
// For suppressing compiler warnings on conversion possibly losing precision.
|
||||
inline short Short(short n) { return n; } // NOLINT
|
||||
inline char Char(char ch) { return ch; }
|
||||
|
||||
// Sample functions and functors for testing various actions.
|
||||
int Nullary() { return 1; }
|
||||
|
||||
@ -242,7 +246,7 @@ TEST(InvokeArgumentTest, Function10) {
|
||||
// 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"), 1);
|
||||
InvokeArgument<0>(static_cast<const char*>("Hi"), Short(1));
|
||||
EXPECT_STREQ("i", a.Perform(make_tuple(&Binary)));
|
||||
}
|
||||
|
||||
@ -250,7 +254,7 @@ TEST(InvokeArgumentTest, ByPointerFunction) {
|
||||
// by passing it a C-string literal.
|
||||
TEST(InvokeArgumentTest, FunctionWithCStringLiteral) {
|
||||
Action<const char*(const char*(*)(const char* input, short n))> a = // NOLINT
|
||||
InvokeArgument<0>("Hi", 1);
|
||||
InvokeArgument<0>("Hi", Short(1));
|
||||
EXPECT_STREQ("i", a.Perform(make_tuple(&Binary)));
|
||||
}
|
||||
|
||||
@ -286,17 +290,17 @@ TEST(WithArgsTest, OneArg) {
|
||||
|
||||
// Tests using WithArgs with an action that takes 2 arguments.
|
||||
TEST(WithArgsTest, TwoArgs) {
|
||||
Action<const char*(const char* s, double x, int n)> a =
|
||||
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, 2)));
|
||||
EXPECT_EQ(s + 2, a.Perform(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, 20, 3)));
|
||||
EXPECT_EQ(123, a.Perform(make_tuple(100, 6.5, Char(20), Short(3))));
|
||||
}
|
||||
|
||||
// Tests using WithArgs with an action that takes 4 arguments.
|
||||
@ -379,7 +383,7 @@ 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, 20, 3)));
|
||||
EXPECT_EQ(123, a.Perform(make_tuple(100, Char(20), Short(3))));
|
||||
}
|
||||
|
||||
// Tests using WithArgs with repeated arguments.
|
||||
@ -394,14 +398,14 @@ 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(2, CharPtr(s))));
|
||||
EXPECT_EQ(s + 2, a.Perform(make_tuple(Short(2), CharPtr(s))));
|
||||
}
|
||||
|
||||
// Tests using WithArgs with compatible, but not identical, argument types.
|
||||
TEST(WithArgsTest, ArgsOfCompatibleTypes) {
|
||||
Action<long(short x, int y, double z, char c)> a = // NOLINT
|
||||
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(100, 20, 5.6, 3)));
|
||||
EXPECT_EQ(123, a.Perform(make_tuple(Short(100), Char(20), 5.6, Char(3))));
|
||||
}
|
||||
|
||||
// Tests using WithArgs with an action that returns void.
|
||||
@ -583,6 +587,16 @@ TEST(DoAllTest, TenActions) {
|
||||
EXPECT_EQ('g', g);
|
||||
}
|
||||
|
||||
// The ACTION*() macros trigger warning C4100 (unreferenced formal
|
||||
// parameter) in MSVC with -W4. Unfortunately they cannot be fixed in
|
||||
// the macro definition, as the warnings are generated when the macro
|
||||
// is expanded and macro expansion cannot contain #pragma. Therefore
|
||||
// we suppress them here.
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4100)
|
||||
#endif
|
||||
|
||||
// Tests the ACTION*() macro family.
|
||||
|
||||
// Tests that ACTION() can define an action that doesn't reference the
|
||||
@ -633,7 +647,7 @@ ACTION(Sum2) {
|
||||
TEST(ActionMacroTest, CanReferenceArgumentTuple) {
|
||||
Action<int(int, char, int*)> a1 = Sum2();
|
||||
int dummy = 0;
|
||||
EXPECT_EQ(11, a1.Perform(make_tuple(5, static_cast<char>(6), &dummy)));
|
||||
EXPECT_EQ(11, a1.Perform(make_tuple(5, Char(6), &dummy)));
|
||||
}
|
||||
|
||||
// Tests that the body of ACTION() can reference the mock function
|
||||
@ -731,7 +745,7 @@ ACTION_P(TypedPlus, n) {
|
||||
|
||||
TEST(ActionPMacroTest, CanReferenceArgumentAndParameterTypes) {
|
||||
Action<int(char m, bool t)> a1 = TypedPlus(9);
|
||||
EXPECT_EQ(10, a1.Perform(make_tuple(static_cast<char>(1), true)));
|
||||
EXPECT_EQ(10, a1.Perform(make_tuple(Char(1), true)));
|
||||
}
|
||||
|
||||
// Tests that a parameterized action can be used in any mock function
|
||||
@ -851,7 +865,7 @@ TEST(ActionPnMacroTest, WorksFor10Parameters) {
|
||||
ACTION_P2(PadArgument, prefix, suffix) {
|
||||
// The following lines promote the two parameters to desired types.
|
||||
std::string prefix_str(prefix);
|
||||
char suffix_char(suffix);
|
||||
char suffix_char = static_cast<char>(suffix);
|
||||
return prefix_str + arg0 + suffix_char;
|
||||
}
|
||||
|
||||
@ -1078,7 +1092,7 @@ class BoolResetter {
|
||||
explicit BoolResetter(bool* value) : value_(value) {}
|
||||
~BoolResetter() { *value_ = false; }
|
||||
private:
|
||||
bool* const value_;
|
||||
bool* value_;
|
||||
};
|
||||
|
||||
TEST(ActionTemplateTest, WorksForIntegralTemplateParams) {
|
||||
@ -1190,5 +1204,9 @@ TEST(ActionTemplateTest, CanBeOverloadedOnNumberOfValueParameters) {
|
||||
EXPECT_EQ(12345, a4.Perform(make_tuple()));
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
} // namespace gmock_generated_actions_test
|
||||
} // namespace testing
|
||||
|
@ -114,6 +114,8 @@ class FooInterface {
|
||||
|
||||
class MockFoo : public FooInterface {
|
||||
public:
|
||||
MockFoo() {}
|
||||
|
||||
// Makes sure that a mock function parameter can be named.
|
||||
MOCK_METHOD1(VoidReturning, void(int n)); // NOLINT
|
||||
|
||||
@ -149,6 +151,9 @@ class MockFoo : public FooInterface {
|
||||
const string& k));
|
||||
MOCK_CONST_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, CTConst, char(int));
|
||||
#endif // GTEST_OS_WINDOWS
|
||||
|
||||
private:
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFoo);
|
||||
};
|
||||
|
||||
class FunctionMockerTest : public testing::Test {
|
||||
@ -305,7 +310,12 @@ TEST_F(FunctionMockerTest, MocksFunctionsConstFunctionWithCallType) {
|
||||
|
||||
class MockB {
|
||||
public:
|
||||
MockB() {}
|
||||
|
||||
MOCK_METHOD0(DoB, void());
|
||||
|
||||
private:
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockB);
|
||||
};
|
||||
|
||||
// Tests that functions with no EXPECT_CALL() ruls can be called any
|
||||
@ -345,10 +355,15 @@ class StackInterface {
|
||||
template <typename T>
|
||||
class MockStack : public StackInterface<T> {
|
||||
public:
|
||||
MockStack() {}
|
||||
|
||||
MOCK_METHOD1_T(Push, void(const T& elem));
|
||||
MOCK_METHOD0_T(Pop, void());
|
||||
MOCK_CONST_METHOD0_T(GetSize, int()); // NOLINT
|
||||
MOCK_CONST_METHOD0_T(GetTop, const T&());
|
||||
|
||||
private:
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockStack);
|
||||
};
|
||||
|
||||
// Tests that template mock works.
|
||||
@ -393,10 +408,15 @@ class StackInterfaceWithCallType {
|
||||
template <typename T>
|
||||
class MockStackWithCallType : public StackInterfaceWithCallType<T> {
|
||||
public:
|
||||
MockStackWithCallType() {}
|
||||
|
||||
MOCK_METHOD1_T_WITH_CALLTYPE(STDMETHODCALLTYPE, Push, void(const T& elem));
|
||||
MOCK_METHOD0_T_WITH_CALLTYPE(STDMETHODCALLTYPE, Pop, void());
|
||||
MOCK_CONST_METHOD0_T_WITH_CALLTYPE(STDMETHODCALLTYPE, GetSize, int());
|
||||
MOCK_CONST_METHOD0_T_WITH_CALLTYPE(STDMETHODCALLTYPE, GetTop, const T&());
|
||||
|
||||
private:
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockStackWithCallType);
|
||||
};
|
||||
|
||||
// Tests that template mock with calltype works.
|
||||
@ -430,7 +450,12 @@ TEST(TemplateMockTestWithCallType, Works) {
|
||||
|
||||
class MockOverloadedOnArgNumber {
|
||||
public:
|
||||
MockOverloadedOnArgNumber() {}
|
||||
|
||||
MY_MOCK_METHODS1_;
|
||||
|
||||
private:
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockOverloadedOnArgNumber);
|
||||
};
|
||||
|
||||
TEST(OverloadedMockMethodTest, CanOverloadOnArgNumberInMacroBody) {
|
||||
@ -450,7 +475,12 @@ TEST(OverloadedMockMethodTest, CanOverloadOnArgNumberInMacroBody) {
|
||||
|
||||
class MockOverloadedOnConstness {
|
||||
public:
|
||||
MockOverloadedOnConstness() {}
|
||||
|
||||
MY_MOCK_METHODS2_;
|
||||
|
||||
private:
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockOverloadedOnConstness);
|
||||
};
|
||||
|
||||
TEST(OverloadedMockMethodTest, CanOverloadOnConstnessInMacroBody) {
|
||||
|
@ -223,8 +223,9 @@ class GreaterThanMatcher : public MatcherInterface<int> {
|
||||
*os << "is " << -diff << " less than " << rhs_;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
const int rhs_;
|
||||
int rhs_;
|
||||
};
|
||||
|
||||
Matcher<int> GreaterThan(int n) {
|
||||
@ -411,7 +412,7 @@ TEST(ElementsAreTest, WorksForNestedContainer) {
|
||||
};
|
||||
|
||||
vector<list<char> > nested;
|
||||
for (int i = 0; i < GMOCK_ARRAY_SIZE_(strings); i++) {
|
||||
for (size_t i = 0; i < GMOCK_ARRAY_SIZE_(strings); i++) {
|
||||
nested.push_back(list<char>(strings[i], strings[i] + strlen(strings[i])));
|
||||
}
|
||||
|
||||
@ -446,7 +447,12 @@ TEST(ElementsAreTest, WorksWithNativeArrayPassedByReference) {
|
||||
|
||||
class NativeArrayPassedAsPointerAndSize {
|
||||
public:
|
||||
NativeArrayPassedAsPointerAndSize() {}
|
||||
|
||||
MOCK_METHOD2(Helper, void(int* array, int size));
|
||||
|
||||
private:
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(NativeArrayPassedAsPointerAndSize);
|
||||
};
|
||||
|
||||
TEST(ElementsAreTest, WorksWithNativeArrayPassedAsPointerAndSize) {
|
||||
@ -550,7 +556,10 @@ TEST(MatcherMacroTest, Works) {
|
||||
// Tests that the description string supplied to MATCHER() must be
|
||||
// valid.
|
||||
|
||||
MATCHER(HasBadDescription, "Invalid%") { return true; }
|
||||
MATCHER(HasBadDescription, "Invalid%") {
|
||||
// Uses arg to suppress "unused parameter" warning.
|
||||
return arg==arg;
|
||||
}
|
||||
|
||||
TEST(MatcherMacroTest,
|
||||
CreatingMatcherWithBadDescriptionGeneratesNonfatalFailure) {
|
||||
@ -560,7 +569,7 @@ TEST(MatcherMacroTest,
|
||||
"use \"%%\" instead of \"%\" to print \"%\".");
|
||||
}
|
||||
|
||||
MATCHER(HasGoodDescription, "good") { return true; }
|
||||
MATCHER(HasGoodDescription, "good") { return arg==arg; }
|
||||
|
||||
TEST(MatcherMacroTest, AcceptsValidDescription) {
|
||||
const Matcher<int> m = HasGoodDescription();
|
||||
@ -642,7 +651,7 @@ TEST(MatcherPMacroTest,
|
||||
}
|
||||
|
||||
|
||||
MATCHER_P(HasGoodDescription1, n, "good %(n)s") { return true; }
|
||||
MATCHER_P(HasGoodDescription1, n, "good %(n)s") { return arg==arg; }
|
||||
|
||||
TEST(MatcherPMacroTest, AcceptsValidDescription) {
|
||||
const Matcher<int> m = HasGoodDescription1(5);
|
||||
@ -709,7 +718,7 @@ TEST(MatcherPnMacroTest,
|
||||
|
||||
MATCHER_P2(HasComplexDescription, foo, bar,
|
||||
"is as complex as %(foo)s %(bar)s (i.e. %(*)s or %%%(foo)s!)") {
|
||||
return true;
|
||||
return arg==arg;
|
||||
}
|
||||
|
||||
TEST(MatcherPnMacroTest, AcceptsValidDescription) {
|
||||
@ -861,7 +870,7 @@ TEST(MatcherPnMacroTest, WorksForDifferentParameterTypes) {
|
||||
MATCHER_P2(EqConcat, prefix, suffix, "") {
|
||||
// The following lines promote the two parameters to desired types.
|
||||
std::string prefix_str(prefix);
|
||||
char suffix_char(suffix);
|
||||
char suffix_char = static_cast<char>(suffix);
|
||||
return arg == prefix_str + suffix_char;
|
||||
}
|
||||
|
||||
|
@ -819,7 +819,7 @@ TEST(CopyArrayTest, WorksForTwoDimensionalArrays) {
|
||||
TEST(NativeArrayTest, ConstructorFromArrayWorks) {
|
||||
const int a[3] = { 0, 1, 2 };
|
||||
NativeArray<int> na(a, 3, kReference);
|
||||
EXPECT_EQ(3, na.size());
|
||||
EXPECT_EQ(3U, na.size());
|
||||
EXPECT_EQ(a, na.begin());
|
||||
}
|
||||
|
||||
@ -849,7 +849,7 @@ TEST(NativeArrayTest, TypeMembersAreCorrect) {
|
||||
TEST(NativeArrayTest, MethodsWork) {
|
||||
const int a[3] = { 0, 1, 2 };
|
||||
NativeArray<int> na(a, 3, kCopy);
|
||||
ASSERT_EQ(3, na.size());
|
||||
ASSERT_EQ(3U, na.size());
|
||||
EXPECT_EQ(3, na.end() - na.begin());
|
||||
|
||||
NativeArray<int>::const_iterator it = na.begin();
|
||||
@ -875,7 +875,7 @@ TEST(NativeArrayTest, MethodsWork) {
|
||||
TEST(NativeArrayTest, WorksForTwoDimensionalArray) {
|
||||
const char a[2][3] = { "hi", "lo" };
|
||||
NativeArray<char[3]> na(a, 2, kReference);
|
||||
ASSERT_EQ(2, na.size());
|
||||
ASSERT_EQ(2U, na.size());
|
||||
EXPECT_EQ(a, na.begin());
|
||||
}
|
||||
|
||||
@ -910,11 +910,11 @@ TEST(StlContainerViewTest, WorksForStaticNativeArray) {
|
||||
|
||||
int a1[3] = { 0, 1, 2 };
|
||||
NativeArray<int> a2 = StlContainerView<int[3]>::ConstReference(a1);
|
||||
EXPECT_EQ(3, a2.size());
|
||||
EXPECT_EQ(3U, a2.size());
|
||||
EXPECT_EQ(a1, a2.begin());
|
||||
|
||||
const NativeArray<int> a3 = StlContainerView<int[3]>::Copy(a1);
|
||||
ASSERT_EQ(3, a3.size());
|
||||
ASSERT_EQ(3U, a3.size());
|
||||
EXPECT_EQ(0, a3.begin()[0]);
|
||||
EXPECT_EQ(1, a3.begin()[1]);
|
||||
EXPECT_EQ(2, a3.begin()[2]);
|
||||
@ -937,12 +937,12 @@ TEST(StlContainerViewTest, WorksForDynamicNativeArray) {
|
||||
const int* const p1 = a1;
|
||||
NativeArray<int> a2 = StlContainerView<tuple<const int*, int> >::
|
||||
ConstReference(make_tuple(p1, 3));
|
||||
EXPECT_EQ(3, a2.size());
|
||||
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));
|
||||
ASSERT_EQ(3, a3.size());
|
||||
ASSERT_EQ(3U, a3.size());
|
||||
EXPECT_EQ(0, a3.begin()[0]);
|
||||
EXPECT_EQ(1, a3.begin()[1]);
|
||||
EXPECT_EQ(2, a3.begin()[2]);
|
||||
|
@ -121,6 +121,8 @@ using testing::internal::ValidateMatcherDescription;
|
||||
using testing::internal::kInvalidInterpolation;
|
||||
using testing::internal::kPercentInterpolation;
|
||||
using testing::internal::kTupleInterpolation;
|
||||
using testing::internal::linked_ptr;
|
||||
using testing::internal::scoped_ptr;
|
||||
using testing::internal::string;
|
||||
|
||||
#ifdef GMOCK_HAS_REGEX
|
||||
@ -150,8 +152,9 @@ class GreaterThanMatcher : public MatcherInterface<int> {
|
||||
*os << "is " << -diff << " less than " << rhs_;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
const int rhs_;
|
||||
int rhs_;
|
||||
};
|
||||
|
||||
Matcher<int> GreaterThan(int n) {
|
||||
@ -333,7 +336,7 @@ class IntValue {
|
||||
public:
|
||||
// An int can be statically (although not implicitly) cast to a
|
||||
// IntValue.
|
||||
explicit IntValue(int value) : value_(value) {}
|
||||
explicit IntValue(int a_value) : value_(a_value) {}
|
||||
|
||||
int value() const { return value_; }
|
||||
private:
|
||||
@ -558,7 +561,7 @@ class Unprintable {
|
||||
public:
|
||||
Unprintable() : c_('a') {}
|
||||
|
||||
bool operator==(const Unprintable& rhs) { return true; }
|
||||
bool operator==(const Unprintable& /* rhs */) { return true; }
|
||||
private:
|
||||
char c_;
|
||||
};
|
||||
@ -604,7 +607,7 @@ TEST(TypedEqTest, CanDescribeSelf) {
|
||||
// "undefined referece".
|
||||
template <typename T>
|
||||
struct Type {
|
||||
static bool IsTypeOf(const T& v) { return true; }
|
||||
static bool IsTypeOf(const T& /* v */) { return true; }
|
||||
|
||||
template <typename T2>
|
||||
static void IsTypeOf(T2 v);
|
||||
@ -715,6 +718,33 @@ TEST(IsNullTest, MatchesNullPointer) {
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(IsNullTest, LinkedPtr) {
|
||||
const Matcher<linked_ptr<int> > m = IsNull();
|
||||
const linked_ptr<int> null_p;
|
||||
const linked_ptr<int> non_null_p(new int);
|
||||
|
||||
EXPECT_TRUE(m.Matches(null_p));
|
||||
EXPECT_FALSE(m.Matches(non_null_p));
|
||||
}
|
||||
|
||||
TEST(IsNullTest, ReferenceToConstLinkedPtr) {
|
||||
const Matcher<const linked_ptr<double>&> m = IsNull();
|
||||
const linked_ptr<double> null_p;
|
||||
const linked_ptr<double> non_null_p(new double);
|
||||
|
||||
EXPECT_TRUE(m.Matches(null_p));
|
||||
EXPECT_FALSE(m.Matches(non_null_p));
|
||||
}
|
||||
|
||||
TEST(IsNullTest, ReferenceToConstScopedPtr) {
|
||||
const Matcher<const scoped_ptr<double>&> m = IsNull();
|
||||
const scoped_ptr<double> null_p;
|
||||
const scoped_ptr<double> non_null_p(new double);
|
||||
|
||||
EXPECT_TRUE(m.Matches(null_p));
|
||||
EXPECT_FALSE(m.Matches(non_null_p));
|
||||
}
|
||||
|
||||
// Tests that IsNull() describes itself properly.
|
||||
TEST(IsNullTest, CanDescribeSelf) {
|
||||
Matcher<int*> m = IsNull();
|
||||
@ -736,6 +766,33 @@ TEST(NotNullTest, MatchesNonNullPointer) {
|
||||
EXPECT_TRUE(m2.Matches("hi"));
|
||||
}
|
||||
|
||||
TEST(NotNullTest, LinkedPtr) {
|
||||
const Matcher<linked_ptr<int> > m = NotNull();
|
||||
const linked_ptr<int> null_p;
|
||||
const linked_ptr<int> non_null_p(new int);
|
||||
|
||||
EXPECT_FALSE(m.Matches(null_p));
|
||||
EXPECT_TRUE(m.Matches(non_null_p));
|
||||
}
|
||||
|
||||
TEST(NotNullTest, ReferenceToConstLinkedPtr) {
|
||||
const Matcher<const linked_ptr<double>&> m = NotNull();
|
||||
const linked_ptr<double> null_p;
|
||||
const linked_ptr<double> non_null_p(new double);
|
||||
|
||||
EXPECT_FALSE(m.Matches(null_p));
|
||||
EXPECT_TRUE(m.Matches(non_null_p));
|
||||
}
|
||||
|
||||
TEST(NotNullTest, ReferenceToConstScopedPtr) {
|
||||
const Matcher<const scoped_ptr<double>&> m = NotNull();
|
||||
const scoped_ptr<double> null_p;
|
||||
const scoped_ptr<double> non_null_p(new double);
|
||||
|
||||
EXPECT_FALSE(m.Matches(null_p));
|
||||
EXPECT_TRUE(m.Matches(non_null_p));
|
||||
}
|
||||
|
||||
// Tests that NotNull() describes itself properly.
|
||||
TEST(NotNullTest, CanDescribeSelf) {
|
||||
Matcher<int*> m = NotNull();
|
||||
@ -1805,8 +1862,9 @@ class IsGreaterThan {
|
||||
explicit IsGreaterThan(int threshold) : threshold_(threshold) {}
|
||||
|
||||
bool operator()(int n) const { return n > threshold_; }
|
||||
|
||||
private:
|
||||
const int threshold_;
|
||||
int threshold_;
|
||||
};
|
||||
|
||||
// For testing Truly().
|
||||
@ -1903,7 +1961,12 @@ TEST(AllArgsTest, WorksForNonTuple) {
|
||||
|
||||
class AllArgsHelper {
|
||||
public:
|
||||
AllArgsHelper() {}
|
||||
|
||||
MOCK_METHOD2(Helper, int(char x, int y));
|
||||
|
||||
private:
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(AllArgsHelper);
|
||||
};
|
||||
|
||||
TEST(AllArgsTest, WorksInWithClause) {
|
||||
@ -2328,7 +2391,7 @@ TEST(PointeeTest, CanExplainMatchResult) {
|
||||
// An uncopyable class.
|
||||
class Uncopyable {
|
||||
public:
|
||||
explicit Uncopyable(int value) : value_(value) {}
|
||||
explicit Uncopyable(int a_value) : value_(a_value) {}
|
||||
|
||||
int value() const { return value_; }
|
||||
private:
|
||||
@ -2349,11 +2412,17 @@ struct AStruct {
|
||||
const double y; // A const field.
|
||||
Uncopyable z; // An uncopyable field.
|
||||
const char* p; // A pointer field.
|
||||
|
||||
private:
|
||||
GTEST_DISALLOW_ASSIGN_(AStruct);
|
||||
};
|
||||
|
||||
// A derived struct for testing Field().
|
||||
struct DerivedStruct : public AStruct {
|
||||
char ch;
|
||||
|
||||
private:
|
||||
GTEST_DISALLOW_ASSIGN_(DerivedStruct);
|
||||
};
|
||||
|
||||
// Tests that Field(&Foo::field, ...) works when field is non-const.
|
||||
@ -2887,7 +2956,7 @@ TEST(ResultOfTest, WorksForReferencingCallables) {
|
||||
|
||||
class DivisibleByImpl {
|
||||
public:
|
||||
explicit DivisibleByImpl(int divider) : divider_(divider) {}
|
||||
explicit DivisibleByImpl(int a_divider) : divider_(a_divider) {}
|
||||
|
||||
template <typename T>
|
||||
bool Matches(const T& n) const {
|
||||
@ -2902,7 +2971,7 @@ class DivisibleByImpl {
|
||||
*os << "is not divisible by " << divider_;
|
||||
}
|
||||
|
||||
void set_divider(int divider) { divider_ = divider; }
|
||||
void set_divider(int a_divider) { divider_ = a_divider; }
|
||||
int divider() const { return divider_; }
|
||||
|
||||
private:
|
||||
@ -2965,7 +3034,7 @@ TEST(ExplainmatcherResultTest, MonomorphicMatcher) {
|
||||
|
||||
class NotCopyable {
|
||||
public:
|
||||
explicit NotCopyable(int value) : value_(value) {}
|
||||
explicit NotCopyable(int a_value) : value_(a_value) {}
|
||||
|
||||
int value() const { return value_; }
|
||||
|
||||
|
@ -65,6 +65,10 @@ using testing::Unused;
|
||||
using testing::WithArg;
|
||||
using testing::WithoutArgs;
|
||||
|
||||
// For suppressing compiler warnings on conversion possibly losing precision.
|
||||
inline short Short(short n) { return n; } // NOLINT
|
||||
inline char Char(char ch) { return ch; }
|
||||
|
||||
// Sample functions and functors for testing Invoke() and etc.
|
||||
int Nullary() { return 1; }
|
||||
|
||||
@ -85,7 +89,7 @@ bool Unary(int x) { return x < 0; }
|
||||
|
||||
const char* Plus1(const char* s) { return s + 1; }
|
||||
|
||||
void VoidUnary(int n) { g_done = true; }
|
||||
void VoidUnary(int /* n */) { g_done = true; }
|
||||
|
||||
bool ByConstRef(const string& s) { return s == "Hi"; }
|
||||
|
||||
@ -239,13 +243,13 @@ TEST(InvokeTest, Unary) {
|
||||
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, 2)));
|
||||
EXPECT_EQ(p + 2, a.Perform(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', 3)));
|
||||
EXPECT_EQ(6, a.Perform(make_tuple(1, '\2', Short(3))));
|
||||
}
|
||||
|
||||
// Tests using Invoke() with a 4-argument function.
|
||||
@ -340,14 +344,14 @@ TEST(InvokeTest, MethodWithUnusedParameters) {
|
||||
|
||||
// Tests using Invoke() with a functor.
|
||||
TEST(InvokeTest, Functor) {
|
||||
Action<int(short, char)> a = Invoke(plus<short>()); // NOLINT
|
||||
EXPECT_EQ(3, a.Perform(make_tuple(1, 2)));
|
||||
Action<long(long, int)> a = Invoke(plus<long>()); // NOLINT
|
||||
EXPECT_EQ(3L, a.Perform(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, 300, 20, true)));
|
||||
EXPECT_EQ(4321, a.Perform(make_tuple(4000, Short(300), Char(20), true)));
|
||||
}
|
||||
|
||||
// Tests using Invoke() with an object pointer and a method pointer.
|
||||
@ -378,7 +382,7 @@ 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, 1)));
|
||||
EXPECT_EQ(1124, a.Perform(make_tuple(1000, true, Char(1))));
|
||||
}
|
||||
|
||||
// Tests using Invoke() with a 4-argument method.
|
||||
@ -457,7 +461,7 @@ 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, 300, 20, true)));
|
||||
EXPECT_EQ(4444, a.Perform(make_tuple(4000, Short(300), Char(20), true)));
|
||||
}
|
||||
|
||||
// Tests using WithoutArgs with an action that takes no argument.
|
||||
|
@ -40,7 +40,12 @@
|
||||
// clash with ::testing::Mock.
|
||||
class Mock {
|
||||
public:
|
||||
Mock() {}
|
||||
|
||||
MOCK_METHOD0(DoThis, void());
|
||||
|
||||
private:
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(Mock);
|
||||
};
|
||||
|
||||
namespace testing {
|
||||
@ -64,10 +69,14 @@ class Foo {
|
||||
|
||||
class MockFoo : public Foo {
|
||||
public:
|
||||
MockFoo() {}
|
||||
void Delete() { delete this; }
|
||||
|
||||
MOCK_METHOD0(DoThis, void());
|
||||
MOCK_METHOD1(DoThat, int(bool flag));
|
||||
|
||||
private:
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFoo);
|
||||
};
|
||||
|
||||
class MockBar {
|
||||
@ -89,6 +98,8 @@ class MockBar {
|
||||
|
||||
private:
|
||||
string str_;
|
||||
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockBar);
|
||||
};
|
||||
|
||||
// TODO(wan@google.com): find a way to re-enable these tests.
|
||||
@ -173,21 +184,21 @@ TEST(NiceMockTest, NonDefaultConstructor10) {
|
||||
nice_bar.That(5, true);
|
||||
}
|
||||
|
||||
#if !GTEST_OS_SYMBIAN
|
||||
#if !GTEST_OS_SYMBIAN && !GTEST_OS_WINDOWS_MOBILE
|
||||
// Tests that NiceMock<Mock> compiles where Mock is a user-defined
|
||||
// class (as opposed to ::testing::Mock). We had to workaround an
|
||||
// MSVC 8.0 bug that caused the symbol Mock used in the definition of
|
||||
// NiceMock to be looked up in the wrong context, and this test
|
||||
// ensures that our fix works.
|
||||
//
|
||||
// We have to skip this test on Symbian, as it causes the program to
|
||||
// crash there, for reasons unclear to us yet.
|
||||
// We have to skip this test on Symbian and Windows Mobile, as it
|
||||
// causes the program to crash there, for reasons unclear to us yet.
|
||||
TEST(NiceMockTest, AcceptsClassNamedMock) {
|
||||
NiceMock< ::Mock> nice;
|
||||
EXPECT_CALL(nice, DoThis());
|
||||
nice.DoThis();
|
||||
}
|
||||
#endif // !GTEST_OS_SYMBIAN
|
||||
#endif // !GTEST_OS_SYMBIAN && !GTEST_OS_WINDOWS_MOBILE
|
||||
|
||||
// Tests that a strict mock allows expected calls.
|
||||
TEST(StrictMockTest, AllowsExpectedCall) {
|
||||
@ -247,21 +258,21 @@ TEST(StrictMockTest, NonDefaultConstructor10) {
|
||||
"Uninteresting mock function call");
|
||||
}
|
||||
|
||||
#if !GTEST_OS_SYMBIAN
|
||||
#if !GTEST_OS_SYMBIAN && !GTEST_OS_WINDOWS_MOBILE
|
||||
// Tests that StrictMock<Mock> compiles where Mock is a user-defined
|
||||
// class (as opposed to ::testing::Mock). We had to workaround an
|
||||
// MSVC 8.0 bug that caused the symbol Mock used in the definition of
|
||||
// StrictMock to be looked up in the wrong context, and this test
|
||||
// ensures that our fix works.
|
||||
//
|
||||
// We have to skip this test on Symbian, as it causes the program to
|
||||
// crash there, for reasons unclear to us yet.
|
||||
// We have to skip this test on Symbian and Windows Mobile, as it
|
||||
// causes the program to crash there, for reasons unclear to us yet.
|
||||
TEST(StrictMockTest, AcceptsClassNamedMock) {
|
||||
StrictMock< ::Mock> strict;
|
||||
EXPECT_CALL(strict, DoThis());
|
||||
strict.DoThis();
|
||||
}
|
||||
#endif // !GTEST_OS_SYMBIAN
|
||||
#endif // !GTEST_OS_SYMBIAN && !GTEST_OS_WINDOWS_MOBILE
|
||||
|
||||
} // namespace gmock_nice_strict_test
|
||||
} // namespace testing
|
||||
|
@ -36,4 +36,129 @@
|
||||
#include <gmock/internal/gmock-port.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
// This file intentionally contains no test at this moment.
|
||||
// NOTE: if this file is left without tests for some reason, put a dummy
|
||||
// test here to make references to symbols in the gtest library and avoid
|
||||
// 'undefined symbol' linker errors in gmock_main:
|
||||
//
|
||||
// TEST(DummyTest, Dummy) {}
|
||||
|
||||
namespace testing {
|
||||
namespace internal {
|
||||
// Needed to avoid name collisions in gmock_all_test.cc.
|
||||
namespace gmock_port_test {
|
||||
|
||||
class Base {
|
||||
public:
|
||||
// Copy constructor and assignment operator do exactly what we need, so we
|
||||
// use them.
|
||||
Base() : member_(0) {}
|
||||
explicit Base(int n) : member_(n) {}
|
||||
virtual ~Base() {}
|
||||
int member() { return member_; }
|
||||
|
||||
private:
|
||||
int member_;
|
||||
};
|
||||
|
||||
class Derived : public Base {
|
||||
public:
|
||||
explicit Derived(int n) : Base(n) {}
|
||||
};
|
||||
|
||||
TEST(ImplicitCastTest, ConvertsPointers) {
|
||||
Derived derived(0);
|
||||
EXPECT_TRUE(&derived == ::testing::internal::implicit_cast<Base*>(&derived));
|
||||
}
|
||||
|
||||
TEST(ImplicitCastTest, CanUseInheritance) {
|
||||
Derived derived(1);
|
||||
Base base = ::testing::internal::implicit_cast<Base>(derived);
|
||||
EXPECT_EQ(derived.member(), base.member());
|
||||
}
|
||||
|
||||
class Castable {
|
||||
public:
|
||||
Castable(bool* converted) : converted_(converted) {}
|
||||
operator Base() {
|
||||
*converted_ = true;
|
||||
return Base();
|
||||
}
|
||||
|
||||
private:
|
||||
bool* converted_;
|
||||
};
|
||||
|
||||
TEST(ImplicitCastTest, CanUseNonConstCastOperator) {
|
||||
bool converted = false;
|
||||
Castable castable(&converted);
|
||||
Base base = ::testing::internal::implicit_cast<Base>(castable);
|
||||
EXPECT_TRUE(converted);
|
||||
}
|
||||
|
||||
class ConstCastable {
|
||||
public:
|
||||
ConstCastable(bool* converted) : converted_(converted) {}
|
||||
operator Base() const {
|
||||
*converted_ = true;
|
||||
return Base();
|
||||
}
|
||||
|
||||
private:
|
||||
bool* converted_;
|
||||
};
|
||||
|
||||
TEST(ImplicitCastTest, CanUseConstCastOperatorOnConstValues) {
|
||||
bool converted = false;
|
||||
const ConstCastable const_castable(&converted);
|
||||
Base base = ::testing::internal::implicit_cast<Base>(const_castable);
|
||||
EXPECT_TRUE(converted);
|
||||
}
|
||||
|
||||
class ConstAndNonConstCastable {
|
||||
public:
|
||||
ConstAndNonConstCastable(bool* converted, bool* const_converted)
|
||||
: converted_(converted), const_converted_(const_converted) {}
|
||||
operator Base() {
|
||||
*converted_ = true;
|
||||
return Base();
|
||||
}
|
||||
operator Base() const {
|
||||
*const_converted_ = true;
|
||||
return Base();
|
||||
}
|
||||
|
||||
private:
|
||||
bool* converted_;
|
||||
bool* const_converted_;
|
||||
};
|
||||
|
||||
TEST(ImplicitCastTest, CanSelectBetweenConstAndNonConstCasrAppropriately) {
|
||||
bool converted = false;
|
||||
bool const_converted = false;
|
||||
ConstAndNonConstCastable castable(&converted, &const_converted);
|
||||
Base base = ::testing::internal::implicit_cast<Base>(castable);
|
||||
EXPECT_TRUE(converted);
|
||||
EXPECT_FALSE(const_converted);
|
||||
|
||||
converted = false;
|
||||
const_converted = false;
|
||||
const ConstAndNonConstCastable const_castable(&converted, &const_converted);
|
||||
base = ::testing::internal::implicit_cast<Base>(const_castable);
|
||||
EXPECT_FALSE(converted);
|
||||
EXPECT_TRUE(const_converted);
|
||||
}
|
||||
|
||||
class To {
|
||||
public:
|
||||
To(bool* converted) { *converted = true; } // NOLINT
|
||||
};
|
||||
|
||||
TEST(ImplicitCastTest, CanUseImplicitConstructor) {
|
||||
bool converted = false;
|
||||
To to = ::testing::internal::implicit_cast<To>(&converted);
|
||||
EXPECT_TRUE(converted);
|
||||
}
|
||||
|
||||
} // namespace gmock_port_test
|
||||
} // namespace internal
|
||||
} // namespace testing
|
||||
|
@ -77,7 +77,7 @@ class StreamableInGlobal {
|
||||
virtual ~StreamableInGlobal() {}
|
||||
};
|
||||
|
||||
inline void operator<<(::std::ostream& os, const StreamableInGlobal& x) {
|
||||
inline void operator<<(::std::ostream& os, const StreamableInGlobal& /* x */) {
|
||||
os << "StreamableInGlobal";
|
||||
}
|
||||
|
||||
@ -107,7 +107,7 @@ void PrintTo(const PrintableViaPrintTo& x, ::std::ostream* os) {
|
||||
template <typename T>
|
||||
class PrintableViaPrintToTemplate {
|
||||
public:
|
||||
explicit PrintableViaPrintToTemplate(const T& value) : value_(value) {}
|
||||
explicit PrintableViaPrintToTemplate(const T& a_value) : value_(a_value) {}
|
||||
|
||||
const T& value() const { return value_; }
|
||||
private:
|
||||
@ -440,11 +440,17 @@ TEST(PrintPointerToPointerTest, IntPointerPointer) {
|
||||
|
||||
// Tests printing (non-member) function pointers.
|
||||
|
||||
void MyFunction(int n) {}
|
||||
void MyFunction(int /* n */) {}
|
||||
|
||||
TEST(PrintPointerTest, NonMemberFunctionPointer) {
|
||||
EXPECT_EQ(PrintPointer(reinterpret_cast<const void*>(&MyFunction)),
|
||||
Print(&MyFunction));
|
||||
// We cannot directly cast &MyFunction to const void* because the
|
||||
// standard disallows casting between pointers to functions and
|
||||
// pointers to objects, and some compilers (e.g. GCC 3.4) enforce
|
||||
// this limitation.
|
||||
EXPECT_EQ(
|
||||
PrintPointer(reinterpret_cast<const void*>(
|
||||
reinterpret_cast<internal::BiggestInt>(&MyFunction))),
|
||||
Print(&MyFunction));
|
||||
int (*p)(bool) = NULL; // NOLINT
|
||||
EXPECT_EQ("NULL", Print(p));
|
||||
}
|
||||
@ -458,7 +464,7 @@ struct Foo {
|
||||
public:
|
||||
virtual ~Foo() {}
|
||||
int MyMethod(char x) { return x + 1; }
|
||||
virtual char MyVirtualMethod(int n) { return 'a'; }
|
||||
virtual char MyVirtualMethod(int /* n */) { return 'a'; }
|
||||
|
||||
int value;
|
||||
};
|
||||
@ -554,7 +560,6 @@ TEST(PrintStringTest, StringInGlobalNamespace) {
|
||||
}
|
||||
#endif // GTEST_HAS_GLOBAL_STRING
|
||||
|
||||
#if GTEST_HAS_STD_STRING
|
||||
// ::std::string.
|
||||
TEST(PrintStringTest, StringInStdNamespace) {
|
||||
const char s[] = "'\"\?\\\a\b\f\n\0\r\t\v\x7F\xFF a";
|
||||
@ -562,7 +567,6 @@ TEST(PrintStringTest, StringInStdNamespace) {
|
||||
EXPECT_EQ("\"'\\\"\\?\\\\\\a\\b\\f\\n\\0\\r\\t\\v\\x7F\\xFF a\\0\"",
|
||||
Print(str));
|
||||
}
|
||||
#endif // GTEST_HAS_STD_STRING
|
||||
|
||||
// Tests printing ::wstring and ::std::wstring.
|
||||
|
||||
@ -599,7 +603,7 @@ class AllowsGenericStreaming {};
|
||||
template <typename Char, typename CharTraits>
|
||||
std::basic_ostream<Char, CharTraits>& operator<<(
|
||||
std::basic_ostream<Char, CharTraits>& os,
|
||||
const AllowsGenericStreaming& a) {
|
||||
const AllowsGenericStreaming& /* a */) {
|
||||
return os << "AllowsGenericStreaming";
|
||||
}
|
||||
|
||||
@ -616,7 +620,7 @@ class AllowsGenericStreamingTemplate {};
|
||||
template <typename Char, typename CharTraits, typename T>
|
||||
std::basic_ostream<Char, CharTraits>& operator<<(
|
||||
std::basic_ostream<Char, CharTraits>& os,
|
||||
const AllowsGenericStreamingTemplate<T>& a) {
|
||||
const AllowsGenericStreamingTemplate<T>& /* a */) {
|
||||
return os << "AllowsGenericStreamingTemplate";
|
||||
}
|
||||
|
||||
@ -637,7 +641,7 @@ class AllowsGenericStreamingAndImplicitConversionTemplate {
|
||||
template <typename Char, typename CharTraits, typename T>
|
||||
std::basic_ostream<Char, CharTraits>& operator<<(
|
||||
std::basic_ostream<Char, CharTraits>& os,
|
||||
const AllowsGenericStreamingAndImplicitConversionTemplate<T>& a) {
|
||||
const AllowsGenericStreamingAndImplicitConversionTemplate<T>& /* a */) {
|
||||
return os << "AllowsGenericStreamingAndImplicitConversionTemplate";
|
||||
}
|
||||
|
||||
@ -973,7 +977,12 @@ TEST(PrintReferenceTest, HandlesFunctionPointer) {
|
||||
void (*fp)(int n) = &MyFunction;
|
||||
const string fp_pointer_string =
|
||||
PrintPointer(reinterpret_cast<const void*>(&fp));
|
||||
const string fp_string = PrintPointer(reinterpret_cast<const void*>(fp));
|
||||
// We cannot directly cast &MyFunction to const void* because the
|
||||
// standard disallows casting between pointers to functions and
|
||||
// pointers to objects, and some compilers (e.g. GCC 3.4) enforce
|
||||
// this limitation.
|
||||
const string fp_string = PrintPointer(reinterpret_cast<const void*>(
|
||||
reinterpret_cast<internal::BiggestInt>(fp)));
|
||||
EXPECT_EQ("@" + fp_pointer_string + " " + fp_string,
|
||||
PrintByRef(fp));
|
||||
}
|
||||
|
@ -97,16 +97,26 @@ class Result {};
|
||||
|
||||
class MockA {
|
||||
public:
|
||||
MockA() {}
|
||||
|
||||
MOCK_METHOD1(DoA, void(int n)); // NOLINT
|
||||
MOCK_METHOD1(ReturnResult, Result(int n)); // NOLINT
|
||||
MOCK_METHOD2(Binary, bool(int x, int y)); // NOLINT
|
||||
MOCK_METHOD2(ReturnInt, int(int x, int y)); // NOLINT
|
||||
|
||||
private:
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockA);
|
||||
};
|
||||
|
||||
class MockB {
|
||||
public:
|
||||
MockB() {}
|
||||
|
||||
MOCK_CONST_METHOD0(DoB, int()); // NOLINT
|
||||
MOCK_METHOD1(DoB, int(int n)); // NOLINT
|
||||
|
||||
private:
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockB);
|
||||
};
|
||||
|
||||
// Tests that EXPECT_CALL and ON_CALL compile in a presence of macro
|
||||
@ -123,7 +133,12 @@ class CC {
|
||||
};
|
||||
class MockCC : public CC {
|
||||
public:
|
||||
MockCC() {}
|
||||
|
||||
MOCK_METHOD0(Method, int());
|
||||
|
||||
private:
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockCC);
|
||||
};
|
||||
|
||||
// Tests that a method with expanded name compiles.
|
||||
@ -571,29 +586,34 @@ TEST(ExpectCallSyntaxTest, WarnsOnTooManyActions) {
|
||||
b.DoB(2);
|
||||
}
|
||||
const string& output = GetCapturedTestStdout();
|
||||
EXPECT_PRED_FORMAT2(IsSubstring,
|
||||
"Too many actions specified.\n"
|
||||
"Expected to be never called, but has 1 WillOnce().",
|
||||
output); // #1
|
||||
EXPECT_PRED_FORMAT2(IsSubstring,
|
||||
"Too many actions specified.\n"
|
||||
"Expected to be called at most once, "
|
||||
"but has 2 WillOnce()s.",
|
||||
output); // #2
|
||||
EXPECT_PRED_FORMAT2(IsSubstring,
|
||||
"Too many actions specified.\n"
|
||||
"Expected to be called once, but has 2 WillOnce()s.",
|
||||
output); // #3
|
||||
EXPECT_PRED_FORMAT2(IsSubstring,
|
||||
"Too many actions specified.\n"
|
||||
"Expected to be never called, but has 0 WillOnce()s "
|
||||
"and a WillRepeatedly().",
|
||||
output); // #4
|
||||
EXPECT_PRED_FORMAT2(IsSubstring,
|
||||
"Too many actions specified.\n"
|
||||
"Expected to be called once, but has 1 WillOnce() "
|
||||
"and a WillRepeatedly().",
|
||||
output); // #5
|
||||
EXPECT_PRED_FORMAT2(
|
||||
IsSubstring,
|
||||
"Too many actions specified in EXPECT_CALL(b, DoB())...\n"
|
||||
"Expected to be never called, but has 1 WillOnce().",
|
||||
output); // #1
|
||||
EXPECT_PRED_FORMAT2(
|
||||
IsSubstring,
|
||||
"Too many actions specified in EXPECT_CALL(b, DoB())...\n"
|
||||
"Expected to be called at most once, "
|
||||
"but has 2 WillOnce()s.",
|
||||
output); // #2
|
||||
EXPECT_PRED_FORMAT2(
|
||||
IsSubstring,
|
||||
"Too many actions specified in EXPECT_CALL(b, DoB(1))...\n"
|
||||
"Expected to be called once, but has 2 WillOnce()s.",
|
||||
output); // #3
|
||||
EXPECT_PRED_FORMAT2(
|
||||
IsSubstring,
|
||||
"Too many actions specified in EXPECT_CALL(b, DoB())...\n"
|
||||
"Expected to be never called, but has 0 WillOnce()s "
|
||||
"and a WillRepeatedly().",
|
||||
output); // #4
|
||||
EXPECT_PRED_FORMAT2(
|
||||
IsSubstring,
|
||||
"Too many actions specified in EXPECT_CALL(b, DoB(2))...\n"
|
||||
"Expected to be called once, but has 1 WillOnce() "
|
||||
"and a WillRepeatedly().",
|
||||
output); // #5
|
||||
}
|
||||
|
||||
// Tests that Google Mock warns on having too few actions in an
|
||||
@ -608,11 +628,12 @@ TEST(ExpectCallSyntaxTest, WarnsOnTooFewActions) {
|
||||
CaptureTestStdout();
|
||||
b.DoB();
|
||||
const string& output = GetCapturedTestStdout();
|
||||
EXPECT_PRED_FORMAT2(IsSubstring,
|
||||
"Too few actions specified.\n"
|
||||
"Expected to be called between 2 and 3 times, "
|
||||
"but has only 1 WillOnce().",
|
||||
output);
|
||||
EXPECT_PRED_FORMAT2(
|
||||
IsSubstring,
|
||||
"Too few actions specified in EXPECT_CALL(b, DoB())...\n"
|
||||
"Expected to be called between 2 and 3 times, "
|
||||
"but has only 1 WillOnce().",
|
||||
output);
|
||||
b.DoB();
|
||||
}
|
||||
|
||||
@ -688,7 +709,7 @@ TEST(ExpectCallTest, CatchesTooFewCalls) {
|
||||
.Times(AtLeast(2));
|
||||
|
||||
b.DoB(5);
|
||||
}, "Actual function call count doesn't match this expectation.\n"
|
||||
}, "Actual function call count doesn't match EXPECT_CALL(b, DoB(5))...\n"
|
||||
" Expected: to be called at least twice\n"
|
||||
" Actual: called once - unsatisfied and active");
|
||||
}
|
||||
@ -895,14 +916,14 @@ TEST(UnexpectedCallTest, GeneratesFailureForVoidFunction) {
|
||||
"Google Mock tried the following 2 expectations, but none matched:");
|
||||
EXPECT_NONFATAL_FAILURE(
|
||||
a2.DoA(2),
|
||||
"tried expectation #0\n"
|
||||
"tried expectation #0: EXPECT_CALL(a2, DoA(1))...\n"
|
||||
" Expected arg #0: is equal to 1\n"
|
||||
" Actual: 2\n"
|
||||
" Expected: to be called once\n"
|
||||
" Actual: called once - saturated and active");
|
||||
EXPECT_NONFATAL_FAILURE(
|
||||
a2.DoA(2),
|
||||
"tried expectation #1\n"
|
||||
"tried expectation #1: EXPECT_CALL(a2, DoA(3))...\n"
|
||||
" Expected arg #0: is equal to 3\n"
|
||||
" Actual: 2\n"
|
||||
" Expected: to be called once\n"
|
||||
@ -1611,8 +1632,19 @@ TEST(DeletingMockEarlyTest, Success2) {
|
||||
|
||||
// Tests that it's OK to delete a mock object itself in its action.
|
||||
|
||||
// Suppresses warning on unreferenced formal parameter in MSVC with
|
||||
// -W4.
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4100)
|
||||
#endif
|
||||
|
||||
ACTION_P(Delete, ptr) { delete ptr; }
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
TEST(DeletingMockEarlyTest, CanDeleteSelfInActionReturningVoid) {
|
||||
MockA* const a = new MockA;
|
||||
EXPECT_CALL(*a, DoA(_)).WillOnce(Delete(a));
|
||||
@ -1685,7 +1717,9 @@ class EvenNumberCardinality : public CardinalityInterface {
|
||||
}
|
||||
|
||||
// Returns true iff call_count calls will saturate this cardinality.
|
||||
virtual bool IsSaturatedByCallCount(int call_count) const { return false; }
|
||||
virtual bool IsSaturatedByCallCount(int /* call_count */) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Describes self to an ostream.
|
||||
virtual void DescribeTo(::std::ostream* os) const {
|
||||
@ -1734,9 +1768,14 @@ struct Unprintable {
|
||||
|
||||
class MockC {
|
||||
public:
|
||||
MockC() {}
|
||||
|
||||
MOCK_METHOD6(VoidMethod, void(bool cond, int n, string s, void* p,
|
||||
const Printable& x, Unprintable y));
|
||||
MOCK_METHOD0(NonVoidMethod, int()); // NOLINT
|
||||
|
||||
private:
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockC);
|
||||
};
|
||||
|
||||
// TODO(wan@google.com): find a way to re-enable these tests.
|
||||
@ -1929,7 +1968,12 @@ void PrintTo(PrintMeNot /* dummy */, ::std::ostream* /* os */) {
|
||||
|
||||
class LogTestHelper {
|
||||
public:
|
||||
LogTestHelper() {}
|
||||
|
||||
MOCK_METHOD1(Foo, PrintMeNot(PrintMeNot));
|
||||
|
||||
private:
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(LogTestHelper);
|
||||
};
|
||||
|
||||
class GMockLogTest : public ::testing::Test {
|
||||
@ -2046,7 +2090,7 @@ TEST(VerifyAndClearExpectationsTest, SomeMethodsHaveExpectationsAndFail) {
|
||||
MockB b;
|
||||
EXPECT_CALL(b, DoB())
|
||||
.WillOnce(Return(1));
|
||||
bool result;
|
||||
bool result = true;
|
||||
EXPECT_NONFATAL_FAILURE(result = Mock::VerifyAndClearExpectations(&b),
|
||||
"Actual: never called");
|
||||
ASSERT_FALSE(result);
|
||||
@ -2084,7 +2128,7 @@ TEST(VerifyAndClearExpectationsTest, AMethodHasManyExpectations) {
|
||||
EXPECT_CALL(b, DoB(_))
|
||||
.WillOnce(Return(2));
|
||||
b.DoB(1);
|
||||
bool result;
|
||||
bool result = true;
|
||||
EXPECT_NONFATAL_FAILURE(result = Mock::VerifyAndClearExpectations(&b),
|
||||
"Actual: never called");
|
||||
ASSERT_FALSE(result);
|
||||
@ -2216,7 +2260,7 @@ TEST(VerifyAndClearTest, Failure) {
|
||||
.WillOnce(Return(2));
|
||||
|
||||
b.DoB(1);
|
||||
bool result;
|
||||
bool result = true;
|
||||
EXPECT_NONFATAL_FAILURE(result = Mock::VerifyAndClear(&b),
|
||||
"Actual: never called");
|
||||
ASSERT_FALSE(result);
|
||||
|
58
testing/gmock/test/gmock_leak_test.py
Normal file → Executable file
58
testing/gmock/test/gmock_leak_test.py
Normal file → Executable file
@ -33,51 +33,57 @@
|
||||
|
||||
__author__ = 'wan@google.com (Zhanyong Wan)'
|
||||
|
||||
|
||||
import gmock_test_utils
|
||||
import os
|
||||
import unittest
|
||||
|
||||
IS_WINDOWS = os.name == 'nt'
|
||||
|
||||
if IS_WINDOWS:
|
||||
# TODO(wan@google.com): test the opt build too. We should do it
|
||||
# when Vlad Losev's work on Google Test's Python test driver is
|
||||
# done, such that we can reuse the work.
|
||||
PROGRAM = r'..\build.dbg\gmock_leak_test_.exe'
|
||||
else:
|
||||
PROGRAM = 'gmock_leak_test_'
|
||||
|
||||
PROGRAM_PATH = os.path.join(gmock_test_utils.GetBuildDir(), PROGRAM)
|
||||
TEST_WITH_EXPECT_CALL = PROGRAM_PATH + ' --gtest_filter=*ExpectCall*'
|
||||
TEST_WITH_ON_CALL = PROGRAM_PATH + ' --gtest_filter=*OnCall*'
|
||||
TEST_MULTIPLE_LEAKS = PROGRAM_PATH + ' --gtest_filter=*MultipleLeaked*'
|
||||
|
||||
|
||||
class GMockLeakTest(unittest.TestCase):
|
||||
PROGRAM_PATH = gmock_test_utils.GetTestExecutablePath('gmock_leak_test_')
|
||||
TEST_WITH_EXPECT_CALL = [PROGRAM_PATH, '--gtest_filter=*ExpectCall*']
|
||||
TEST_WITH_ON_CALL = [PROGRAM_PATH, '--gtest_filter=*OnCall*']
|
||||
TEST_MULTIPLE_LEAKS = [PROGRAM_PATH, '--gtest_filter=*MultipleLeaked*']
|
||||
|
||||
|
||||
class GMockLeakTest(gmock_test_utils.TestCase):
|
||||
|
||||
def testCatchesLeakedMockByDefault(self):
|
||||
self.assertNotEqual(os.system(TEST_WITH_EXPECT_CALL), 0)
|
||||
self.assertNotEqual(os.system(TEST_WITH_ON_CALL), 0)
|
||||
self.assertNotEqual(
|
||||
0,
|
||||
gmock_test_utils.Subprocess(TEST_WITH_EXPECT_CALL).exit_code)
|
||||
self.assertNotEqual(
|
||||
0,
|
||||
gmock_test_utils.Subprocess(TEST_WITH_ON_CALL).exit_code)
|
||||
|
||||
def testDoesNotCatchLeakedMockWhenDisabled(self):
|
||||
self.assertEquals(
|
||||
0, os.system(TEST_WITH_EXPECT_CALL + ' --gmock_catch_leaked_mocks=0'))
|
||||
0,
|
||||
gmock_test_utils.Subprocess(TEST_WITH_EXPECT_CALL +
|
||||
['--gmock_catch_leaked_mocks=0']).exit_code)
|
||||
self.assertEquals(
|
||||
0, os.system(TEST_WITH_ON_CALL + ' --gmock_catch_leaked_mocks=0'))
|
||||
0,
|
||||
gmock_test_utils.Subprocess(TEST_WITH_ON_CALL +
|
||||
['--gmock_catch_leaked_mocks=0']).exit_code)
|
||||
|
||||
def testCatchesLeakedMockWhenEnabled(self):
|
||||
self.assertNotEqual(
|
||||
os.system(TEST_WITH_EXPECT_CALL + ' --gmock_catch_leaked_mocks'), 0)
|
||||
0,
|
||||
gmock_test_utils.Subprocess(TEST_WITH_EXPECT_CALL +
|
||||
['--gmock_catch_leaked_mocks']).exit_code)
|
||||
self.assertNotEqual(
|
||||
os.system(TEST_WITH_ON_CALL + ' --gmock_catch_leaked_mocks'), 0)
|
||||
0,
|
||||
gmock_test_utils.Subprocess(TEST_WITH_ON_CALL +
|
||||
['--gmock_catch_leaked_mocks']).exit_code)
|
||||
|
||||
def testCatchesLeakedMockWhenEnabledWithExplictFlagValue(self):
|
||||
self.assertNotEqual(
|
||||
os.system(TEST_WITH_EXPECT_CALL + ' --gmock_catch_leaked_mocks=1'), 0)
|
||||
0,
|
||||
gmock_test_utils.Subprocess(TEST_WITH_EXPECT_CALL +
|
||||
['--gmock_catch_leaked_mocks=1']).exit_code)
|
||||
|
||||
def testCatchesMultipleLeakedMocks(self):
|
||||
self.assertNotEqual(
|
||||
os.system(TEST_MULTIPLE_LEAKS + ' --gmock_catch_leaked_mocks'), 0)
|
||||
0,
|
||||
gmock_test_utils.Subprocess(TEST_MULTIPLE_LEAKS +
|
||||
['--gmock_catch_leaked_mocks']).exit_code)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -48,7 +48,12 @@ class FooInterface {
|
||||
|
||||
class MockFoo : public FooInterface {
|
||||
public:
|
||||
MockFoo() {}
|
||||
|
||||
MOCK_METHOD0(DoThis, void());
|
||||
|
||||
private:
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFoo);
|
||||
};
|
||||
|
||||
TEST(LeakTest, LeakedMockWithExpectCallCausesFailureWhenLeakCheckingIsEnabled) {
|
||||
|
@ -206,6 +206,8 @@ class Interface {
|
||||
|
||||
class Mock: public Interface {
|
||||
public:
|
||||
Mock() {}
|
||||
|
||||
MOCK_METHOD1(VoidFromString, void(char* str));
|
||||
MOCK_METHOD1(StringFromString, char*(char* str));
|
||||
MOCK_METHOD1(IntFromString, int(char* str));
|
||||
@ -215,6 +217,9 @@ class Mock: public Interface {
|
||||
MOCK_METHOD1(VoidFromFloat, void(float n));
|
||||
MOCK_METHOD1(VoidFromDouble, void(double n));
|
||||
MOCK_METHOD1(VoidFromVector, void(const std::vector<int>& v));
|
||||
|
||||
private:
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(Mock);
|
||||
};
|
||||
|
||||
class InvokeHelper {
|
||||
@ -229,7 +234,7 @@ class InvokeHelper {
|
||||
|
||||
class FieldHelper {
|
||||
public:
|
||||
FieldHelper(int field) : field_(field) {}
|
||||
FieldHelper(int a_field) : field_(a_field) {}
|
||||
int field() const { return field_; }
|
||||
int field_; // NOLINT -- need external access to field_ to test
|
||||
// the Field matcher.
|
||||
@ -410,6 +415,16 @@ TEST(LinkTest, TestThrow) {
|
||||
}
|
||||
#endif // GTEST_HAS_EXCEPTIONS
|
||||
|
||||
// The ACTION*() macros trigger warning C4100 (unreferenced formal
|
||||
// parameter) in MSVC with -W4. Unfortunately they cannot be fixed in
|
||||
// the macro definition, as the warnings are generated when the macro
|
||||
// is expanded and macro expansion cannot contain #pragma. Therefore
|
||||
// we suppress them here.
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4100)
|
||||
#endif
|
||||
|
||||
// Tests the linkage of actions created using ACTION macro.
|
||||
namespace {
|
||||
ACTION(Return1) { return 1; }
|
||||
@ -441,6 +456,10 @@ ACTION_P2(ReturnEqualsEitherOf, first, second) {
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
TEST(LinkTest, TestActionP2Macro) {
|
||||
Mock mock;
|
||||
char ch = 'x';
|
||||
|
70
testing/gmock/test/gmock_output_test.py
Normal file → Executable file
70
testing/gmock/test/gmock_output_test.py
Normal file → Executable file
@ -40,29 +40,20 @@ SYNOPSIS
|
||||
|
||||
__author__ = 'wan@google.com (Zhanyong Wan)'
|
||||
|
||||
import gmock_test_utils
|
||||
import os
|
||||
import re
|
||||
import string
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
import gmock_test_utils
|
||||
|
||||
|
||||
# The flag for generating the golden file
|
||||
GENGOLDEN_FLAG = '--gengolden'
|
||||
|
||||
IS_WINDOWS = os.name == 'nt'
|
||||
|
||||
if IS_WINDOWS:
|
||||
PROGRAM = r'..\build.dbg\gmock_output_test_.exe'
|
||||
else:
|
||||
PROGRAM = 'gmock_output_test_'
|
||||
|
||||
PROGRAM_PATH = os.path.join(gmock_test_utils.GetBuildDir(), PROGRAM)
|
||||
COMMAND = PROGRAM_PATH + ' --gtest_stack_trace_depth=0 --gtest_print_time=0'
|
||||
PROGRAM_PATH = gmock_test_utils.GetTestExecutablePath('gmock_output_test_')
|
||||
COMMAND = [PROGRAM_PATH, '--gtest_stack_trace_depth=0', '--gtest_print_time=0']
|
||||
GOLDEN_NAME = 'gmock_output_test_golden.txt'
|
||||
GOLDEN_PATH = os.path.join(gmock_test_utils.GetSourceDir(),
|
||||
GOLDEN_NAME)
|
||||
GOLDEN_PATH = os.path.join(gmock_test_utils.GetSourceDir(), GOLDEN_NAME)
|
||||
|
||||
|
||||
def ToUnixLineEnding(s):
|
||||
@ -144,51 +135,10 @@ def GetNormalizedOutputAndLeakyTests(output):
|
||||
return (RemoveTestNamesOfLeakedMocks(output), GetLeakyTests(output))
|
||||
|
||||
|
||||
def IterShellCommandOutput(cmd, stdin_string=None):
|
||||
"""Runs a command in a sub-process, and iterates the lines in its STDOUT.
|
||||
def GetShellCommandOutput(cmd):
|
||||
"""Runs a command in a sub-process, and returns its STDOUT in a string."""
|
||||
|
||||
Args:
|
||||
|
||||
cmd: The shell command.
|
||||
stdin_string: The string to be fed to the STDIN of the sub-process;
|
||||
If None, the sub-process will inherit the STDIN
|
||||
from the parent process.
|
||||
"""
|
||||
|
||||
# Spawns cmd in a sub-process, and gets its standard I/O file objects.
|
||||
stdin_file, stdout_file = os.popen2(cmd, 'b')
|
||||
|
||||
# If the caller didn't specify a string for STDIN, gets it from the
|
||||
# parent process.
|
||||
if stdin_string is None:
|
||||
stdin_string = sys.stdin.read()
|
||||
|
||||
# Feeds the STDIN string to the sub-process.
|
||||
stdin_file.write(stdin_string)
|
||||
stdin_file.close()
|
||||
|
||||
while True:
|
||||
line = stdout_file.readline()
|
||||
if not line: # EOF
|
||||
stdout_file.close()
|
||||
break
|
||||
|
||||
yield line
|
||||
|
||||
|
||||
def GetShellCommandOutput(cmd, stdin_string=None):
|
||||
"""Runs a command in a sub-process, and returns its STDOUT in a string.
|
||||
|
||||
Args:
|
||||
|
||||
cmd: The shell command.
|
||||
stdin_string: The string to be fed to the STDIN of the sub-process;
|
||||
If None, the sub-process will inherit the STDIN
|
||||
from the parent process.
|
||||
"""
|
||||
|
||||
lines = list(IterShellCommandOutput(cmd, stdin_string))
|
||||
return string.join(lines, '')
|
||||
return gmock_test_utils.Subprocess(cmd, capture_stderr=False).output
|
||||
|
||||
|
||||
def GetNormalizedCommandOutputAndLeakyTests(cmd):
|
||||
@ -200,10 +150,10 @@ def GetNormalizedCommandOutputAndLeakyTests(cmd):
|
||||
|
||||
# Disables exception pop-ups on Windows.
|
||||
os.environ['GTEST_CATCH_EXCEPTIONS'] = '1'
|
||||
return GetNormalizedOutputAndLeakyTests(GetShellCommandOutput(cmd, ''))
|
||||
return GetNormalizedOutputAndLeakyTests(GetShellCommandOutput(cmd))
|
||||
|
||||
|
||||
class GMockOutputTest(unittest.TestCase):
|
||||
class GMockOutputTest(gmock_test_utils.TestCase):
|
||||
def testOutput(self):
|
||||
(output, leaky_tests) = GetNormalizedCommandOutputAndLeakyTests(COMMAND)
|
||||
golden_file = open(GOLDEN_PATH, 'rb')
|
||||
|
@ -49,9 +49,14 @@ using testing::Sequence;
|
||||
|
||||
class MockFoo {
|
||||
public:
|
||||
MockFoo() {}
|
||||
|
||||
MOCK_METHOD3(Bar, char(const std::string& s, int i, double x));
|
||||
MOCK_METHOD2(Bar2, bool(int x, int y));
|
||||
MOCK_METHOD2(Bar3, void(int x, int y));
|
||||
|
||||
private:
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFoo);
|
||||
};
|
||||
|
||||
class GMockOutputTest : public testing::Test {
|
||||
@ -161,6 +166,10 @@ TEST_F(GMockOutputTest, UnsatisfiedPrerequisites) {
|
||||
foo_.Bar2(1, 0);
|
||||
}
|
||||
|
||||
TEST_F(GMockOutputTest, UnsatisfiedWith) {
|
||||
EXPECT_CALL(foo_, Bar2(_, _)).With(Ge());
|
||||
}
|
||||
|
||||
TEST_F(GMockOutputTest, UnsatisfiedExpectation) {
|
||||
EXPECT_CALL(foo_, Bar(_, _, _));
|
||||
EXPECT_CALL(foo_, Bar2(0, _))
|
||||
|
@ -3,7 +3,7 @@
|
||||
FILE:#: EXPECT_CALL(foo_, Bar2(0, _)) invoked
|
||||
Stack trace:
|
||||
|
||||
FILE:#: Expected mock function call.
|
||||
FILE:#: Mock function call matches EXPECT_CALL(foo_, Bar2(0, _))...
|
||||
Function call: Bar2(0, 0)
|
||||
Returns: false
|
||||
Stack trace:
|
||||
@ -13,17 +13,17 @@ Stack trace:
|
||||
FILE:#: EXPECT_CALL(foo_, Bar3(0, _)) invoked
|
||||
Stack trace:
|
||||
|
||||
FILE:#: Expected mock function call.
|
||||
FILE:#: Mock function call matches EXPECT_CALL(foo_, Bar3(0, _))...
|
||||
Function call: Bar3(0, 0)
|
||||
Stack trace:
|
||||
[ OK ] GMockOutputTest.ExpectedCallToVoidFunction
|
||||
[ RUN ] GMockOutputTest.ExplicitActionsRunOut
|
||||
|
||||
GMOCK WARNING:
|
||||
FILE:#: Too few actions specified.
|
||||
FILE:#: Too few actions specified in EXPECT_CALL(foo_, Bar2(_, _))...
|
||||
Expected to be called twice, but has only 1 WillOnce().
|
||||
GMOCK WARNING:
|
||||
FILE:#: Actions ran out.
|
||||
FILE:#: Actions ran out in EXPECT_CALL(foo_, Bar2(_, _))...
|
||||
Called 2 times, but only 1 WillOnce() is specified - returning default value.
|
||||
Stack trace:
|
||||
[ OK ] GMockOutputTest.ExplicitActionsRunOut
|
||||
@ -35,7 +35,7 @@ Unexpected mock function call - returning default value.
|
||||
Returns: false
|
||||
Google Mock tried the following 1 expectation, but it didn't match:
|
||||
|
||||
FILE:#:
|
||||
FILE:#: EXPECT_CALL(foo_, Bar2(0, _))...
|
||||
Expected arg #0: is equal to 0
|
||||
Actual: 1
|
||||
Expected: to be called once
|
||||
@ -48,7 +48,7 @@ Unexpected mock function call - returning directly.
|
||||
Function call: Bar3(1, 0)
|
||||
Google Mock tried the following 1 expectation, but it didn't match:
|
||||
|
||||
FILE:#:
|
||||
FILE:#: EXPECT_CALL(foo_, Bar3(0, _))...
|
||||
Expected arg #0: is equal to 0
|
||||
Actual: 1
|
||||
Expected: to be called once
|
||||
@ -92,12 +92,12 @@ Unexpected mock function call - returning default value.
|
||||
Returns: false
|
||||
Google Mock tried the following 2 expectations, but none matched:
|
||||
|
||||
FILE:#: tried expectation #0
|
||||
FILE:#: tried expectation #0: EXPECT_CALL(foo_, Bar2(_, _))...
|
||||
Expected: the expectation is active
|
||||
Actual: it is retired
|
||||
Expected: to be called once
|
||||
Actual: called once - saturated and retired
|
||||
FILE:#: tried expectation #1
|
||||
FILE:#: tried expectation #1: EXPECT_CALL(foo_, Bar2(0, 0))...
|
||||
Expected arg #0: is equal to 0
|
||||
Actual: 1
|
||||
Expected arg #1: is equal to 0
|
||||
@ -113,12 +113,12 @@ Unexpected mock function call - returning default value.
|
||||
Returns: false
|
||||
Google Mock tried the following 2 expectations, but none matched:
|
||||
|
||||
FILE:#: tried expectation #0
|
||||
FILE:#: tried expectation #0: EXPECT_CALL(foo_, Bar2(0, 0))...
|
||||
Expected arg #0: is equal to 0
|
||||
Actual: 1
|
||||
Expected: to be called once
|
||||
Actual: never called - unsatisfied and active
|
||||
FILE:#: tried expectation #1
|
||||
FILE:#: tried expectation #1: EXPECT_CALL(foo_, Bar2(1, _))...
|
||||
Expected: all pre-requisites are satisfied
|
||||
Actual: the following immediate pre-requisites are not satisfied:
|
||||
FILE:#: pre-requisite #0
|
||||
@ -134,12 +134,12 @@ Unexpected mock function call - returning default value.
|
||||
Returns: false
|
||||
Google Mock tried the following 2 expectations, but none matched:
|
||||
|
||||
FILE:#: tried expectation #0
|
||||
FILE:#: tried expectation #0: EXPECT_CALL(foo_, Bar2(0, 0))...
|
||||
Expected arg #0: is equal to 0
|
||||
Actual: 1
|
||||
Expected: to be called once
|
||||
Actual: never called - unsatisfied and active
|
||||
FILE:#: tried expectation #1
|
||||
FILE:#: tried expectation #1: EXPECT_CALL(foo_, Bar2(1, _))...
|
||||
Expected: all pre-requisites are satisfied
|
||||
Actual: the following immediate pre-requisites are not satisfied:
|
||||
FILE:#: pre-requisite #0
|
||||
@ -148,13 +148,20 @@ FILE:#: pre-requisite #1
|
||||
Expected: to be called once
|
||||
Actual: never called - unsatisfied and active
|
||||
[ FAILED ] GMockOutputTest.UnsatisfiedPrerequisites
|
||||
[ RUN ] GMockOutputTest.UnsatisfiedWith
|
||||
FILE:#: Failure
|
||||
Actual function call count doesn't match EXPECT_CALL(foo_, Bar2(_, _))...
|
||||
Expected args: are a pair (x, y) where x >= y
|
||||
Expected: to be called once
|
||||
Actual: never called - unsatisfied and active
|
||||
[ FAILED ] GMockOutputTest.UnsatisfiedWith
|
||||
[ RUN ] GMockOutputTest.UnsatisfiedExpectation
|
||||
FILE:#: Failure
|
||||
Actual function call count doesn't match this expectation.
|
||||
Actual function call count doesn't match EXPECT_CALL(foo_, Bar2(0, _))...
|
||||
Expected: to be called twice
|
||||
Actual: called once - unsatisfied and active
|
||||
FILE:#: Failure
|
||||
Actual function call count doesn't match this expectation.
|
||||
Actual function call count doesn't match EXPECT_CALL(foo_, Bar(_, _, _))...
|
||||
Expected: to be called once
|
||||
Actual: never called - unsatisfied and active
|
||||
[ FAILED ] GMockOutputTest.UnsatisfiedExpectation
|
||||
@ -166,7 +173,7 @@ Unexpected mock function call - returning default value.
|
||||
Returns: '\0'
|
||||
Google Mock tried the following 1 expectation, but it didn't match:
|
||||
|
||||
FILE:#:
|
||||
FILE:#: EXPECT_CALL(foo_, Bar(Ref(s), _, Ge(0)))...
|
||||
Expected arg #0: references the variable @0x# "Hi"
|
||||
Actual: "Ho" (is located @0x#)
|
||||
Expected arg #2: is greater than or equal to 0
|
||||
@ -182,7 +189,7 @@ Unexpected mock function call - returning default value.
|
||||
Returns: false
|
||||
Google Mock tried the following 1 expectation, but it didn't match:
|
||||
|
||||
FILE:#:
|
||||
FILE:#: EXPECT_CALL(foo_, Bar2(Ge(2), Ge(1)))...
|
||||
Expected args: are a pair (x, y) where x >= y
|
||||
Actual: don't match
|
||||
Expected: to be called once
|
||||
@ -196,7 +203,7 @@ Unexpected mock function call - returning default value.
|
||||
Returns: false
|
||||
Google Mock tried the following 1 expectation, but it didn't match:
|
||||
|
||||
FILE:#:
|
||||
FILE:#: EXPECT_CALL(foo_, Bar2(Ge(2), Ge(1)))...
|
||||
Expected arg #0: is greater than or equal to 2
|
||||
Actual: 1
|
||||
Expected args: are a pair (x, y) where x >= y
|
||||
@ -213,7 +220,7 @@ FILE:#:
|
||||
Returns: false
|
||||
Google Mock tried the following 1 expectation, but it didn't match:
|
||||
|
||||
FILE:#:
|
||||
FILE:#: EXPECT_CALL(foo_, Bar2(2, 2))...
|
||||
Expected arg #0: is equal to 2
|
||||
Actual: 1
|
||||
Expected arg #1: is equal to 2
|
||||
@ -228,7 +235,7 @@ FILE:#:
|
||||
Returns: true
|
||||
Google Mock tried the following 1 expectation, but it didn't match:
|
||||
|
||||
FILE:#:
|
||||
FILE:#: EXPECT_CALL(foo_, Bar2(2, 2))...
|
||||
Expected arg #0: is equal to 2
|
||||
Actual: 0
|
||||
Expected arg #1: is equal to 2
|
||||
@ -271,10 +278,10 @@ Stack trace:
|
||||
[ RUN ] GMockOutputTest.ExplicitActionsRunOutWithDefaultAction
|
||||
|
||||
GMOCK WARNING:
|
||||
FILE:#: Too few actions specified.
|
||||
FILE:#: Too few actions specified in EXPECT_CALL(foo_, Bar2(_, _))...
|
||||
Expected to be called twice, but has only 1 WillOnce().
|
||||
GMOCK WARNING:
|
||||
FILE:#: Actions ran out.
|
||||
FILE:#: Actions ran out in EXPECT_CALL(foo_, Bar2(_, _))...
|
||||
Called 2 times, but only 1 WillOnce() is specified - taking default action specified at:
|
||||
FILE:#:
|
||||
Stack trace:
|
||||
@ -288,6 +295,7 @@ Stack trace:
|
||||
[ FAILED ] GMockOutputTest.RetiredExpectation
|
||||
[ FAILED ] GMockOutputTest.UnsatisfiedPrerequisite
|
||||
[ FAILED ] GMockOutputTest.UnsatisfiedPrerequisites
|
||||
[ FAILED ] GMockOutputTest.UnsatisfiedWith
|
||||
[ FAILED ] GMockOutputTest.UnsatisfiedExpectation
|
||||
[ FAILED ] GMockOutputTest.MismatchArguments
|
||||
[ FAILED ] GMockOutputTest.MismatchWith
|
||||
|
49
testing/gmock/test/gmock_test_utils.py
Normal file → Executable file
49
testing/gmock/test/gmock_test_utils.py
Normal file → Executable file
@ -35,7 +35,20 @@ __author__ = 'wan@google.com (Zhanyong Wan)'
|
||||
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
|
||||
# Determines path to gtest_test_utils and imports it.
|
||||
SCRIPT_DIR = os.path.dirname(__file__) or '.'
|
||||
|
||||
# isdir resolves symbolic links.
|
||||
gtest_tests_util_dir = os.path.join(SCRIPT_DIR, '../gtest/test')
|
||||
if os.path.isdir(gtest_tests_util_dir):
|
||||
GTEST_TESTS_UTIL_DIR = gtest_tests_util_dir
|
||||
else:
|
||||
GTEST_TESTS_UTIL_DIR = os.path.join(SCRIPT_DIR, '../../gtest/test')
|
||||
|
||||
sys.path.append(GTEST_TESTS_UTIL_DIR)
|
||||
import gtest_test_utils # pylint: disable-msg=C6204
|
||||
|
||||
|
||||
# Initially maps a flag to its default value. After
|
||||
@ -96,6 +109,22 @@ def GetBuildDir():
|
||||
return os.path.abspath(GetFlag('gmock_build_dir'))
|
||||
|
||||
|
||||
def GetTestExecutablePath(executable_name):
|
||||
"""Returns the absolute path of the test binary given its name.
|
||||
|
||||
The function will print a message and abort the program if the resulting file
|
||||
doesn't exist.
|
||||
|
||||
Args:
|
||||
executable_name: name of the test binary that the test script runs.
|
||||
|
||||
Returns:
|
||||
The absolute path of the test binary.
|
||||
"""
|
||||
|
||||
return gtest_test_utils.GetTestExecutablePath(executable_name, GetBuildDir())
|
||||
|
||||
|
||||
def GetExitStatus(exit_code):
|
||||
"""Returns the argument to exit(), or -1 if exit() wasn't called.
|
||||
|
||||
@ -116,11 +145,23 @@ def GetExitStatus(exit_code):
|
||||
return -1
|
||||
|
||||
|
||||
# Suppresses the "Invalid const name" lint complaint
|
||||
# pylint: disable-msg=C6409
|
||||
|
||||
# Exposes Subprocess from gtest_test_utils.
|
||||
Subprocess = gtest_test_utils.Subprocess
|
||||
|
||||
# Exposes TestCase from gtest_test_utils.
|
||||
TestCase = gtest_test_utils.TestCase
|
||||
|
||||
# pylint: enable-msg=C6409
|
||||
|
||||
|
||||
def Main():
|
||||
"""Runs the unit test."""
|
||||
|
||||
# We must call _ParseAndStripGMockFlags() before calling
|
||||
# unittest.main(). Otherwise the latter will be confused by the
|
||||
# --gmock_* flags.
|
||||
# gtest_test_utils.Main(). Otherwise unittest.main it calls will be
|
||||
# confused by the --gmock_* flags.
|
||||
_ParseAndStripGMockFlags(sys.argv)
|
||||
unittest.main()
|
||||
gtest_test_utils.Main()
|
||||
|
Reference in New Issue
Block a user