60 #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_SPEC_BUILDERS_H_ 61 #define GMOCK_INCLUDE_GMOCK_GMOCK_SPEC_BUILDERS_H_ 69 #if GTEST_HAS_EXCEPTIONS 78 #include "gtest/gtest.h" 95 template <
typename F>
class FunctionMocker;
98 class ExpectationBase;
101 template <
typename F>
class TypedExpectation;
104 class ExpectationTester;
107 template <
typename F>
class FunctionMockerBase;
123 class UntypedActionResultHolderBase;
131 UntypedFunctionMockerBase();
132 virtual ~UntypedFunctionMockerBase();
137 bool VerifyAndClearExpectationsLocked()
141 virtual
void ClearDefaultActionsLocked()
153 virtual UntypedActionResultHolderBase * UntypedPerformDefaultAction(
154 const
void * untyped_args,
155 const
string & call_description) const = 0;
160 virtual UntypedActionResultHolderBase * UntypedPerformAction(
161 const
void * untyped_action,
162 const
void * untyped_args) const = 0;
167 virtual
void UntypedDescribeUninterestingCall(
168 const
void * untyped_args,
169 ::
std::ostream * os) const
178 virtual const ExpectationBase * UntypedFindMatchingExpectation(
179 const
void * untyped_args,
180 const
void ** untyped_action,
bool * is_excessive,
185 virtual
void UntypedPrintArgs(const
void * untyped_args,
186 ::
std::ostream * os) const = 0;
193 void RegisterOwner(const
void * mock_obj)
199 void SetOwnerAndName(const
void * mock_obj, const
char *
name)
205 const
void * MockObject() const
210 const
char * Name() const
217 const UntypedActionResultHolderBase * UntypedInvokeWith(
218 const
void * untyped_args)
234 const
void * mock_obj_;
241 UntypedOnCallSpecs untyped_on_call_specs_;
253 : file_(a_file), line_(a_line), last_clause_(kNone) {}
256 const char *
file()
const {
return file_; }
257 int line()
const {
return line_; }
273 Assert(property, file_, line_, failure_message);
279 Expect(property, file_, line_, failure_message);
291 template <
typename F>
301 const ArgumentMatcherTuple & matchers)
308 extra_matcher_(
A<const ArgumentTuple & >())
316 ExpectSpecProperty(last_clause_ < kWith,
317 ".With() cannot appear " 318 "more than once in an ON_CALL().");
319 last_clause_ = kWith;
328 ExpectSpecProperty(last_clause_ < kWillByDefault,
329 ".WillByDefault() must appear " 330 "exactly once in an ON_CALL().");
331 last_clause_ = kWillByDefault;
334 "DoDefault() cannot be used in ON_CALL().");
340 bool Matches(
const ArgumentTuple & args)
const 342 return TupleMatches(matchers_, args) && extra_matcher_.Matches(args);
348 AssertSpecProperty(last_clause_ == kWillByDefault,
349 ".WillByDefault() must appear exactly " 350 "once in an ON_CALL().");
368 ArgumentMatcherTuple matchers_;
392 static void AllowLeak(
const void * mock_obj)
398 static bool VerifyAndClearExpectations(
void * mock_obj)
404 static bool VerifyAndClear(
void * mock_obj)
412 template <
typename F>
415 template <
typename M>
418 template <
typename M>
421 template <
typename M>
426 static void AllowUninterestingCalls(
const void * mock_obj)
431 static void WarnUninterestingCalls(
const void * mock_obj)
436 static void FailUninterestingCalls(
const void * mock_obj)
441 static void UnregisterCallReaction(
const void * mock_obj)
447 const void * mock_obj)
453 static bool VerifyAndClearExpectationsLocked(
void * mock_obj)
457 static void ClearDefaultActionsLocked(
void * mock_obj)
461 static void Register(
462 const void * mock_obj,
469 static void RegisterUseByOnCallOrExpectCall(
470 const void * mock_obj,
const char * file,
int line)
535 friend class ::testing::internal::ExpectationBase;
536 friend class ::testing::internal::UntypedFunctionMockerBase;
538 template <
typename F>
539 friend class ::testing::internal::FunctionMockerBase;
541 template <
typename F>
542 friend class ::testing::internal::TypedExpectation;
554 typedef ::std::set<Expectation, Less>
Set;
563 return expectation_base_;
627 expectations_.insert(e);
631 int size()
const {
return static_cast<int>(expectations_.size()); }
633 const_iterator
begin()
const {
return expectations_.begin(); }
634 const_iterator
end()
const {
return expectations_.end(); }
652 void AddExpectation(
const Expectation & expectation)
const;
692 bool sequence_created_;
722 ExpectationBase(
const char * file,
int line,
const string & source_text);
724 virtual ~ExpectationBase();
727 const char *
file()
const {
return file_; }
728 int line()
const {
return line_; }
741 void DescribeCallCountTo(::std::ostream * os)
const 746 virtual void MaybeDescribeExtraMatcherTo(::std::ostream * os) = 0;
749 friend class ::testing::Expectation;
774 Assert(property, file_, line_, failure_message);
780 Expect(property, file_, line_, failure_message);
785 void SpecifyCardinality(
const Cardinality & cardinality);
794 cardinality_ = a_cardinality;
802 void RetireAllPreRequisites()
807 GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
809 g_gmock_mutex.AssertHeld();
815 GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
817 g_gmock_mutex.AssertHeld();
823 GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
825 g_gmock_mutex.AssertHeld();
831 GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
833 g_gmock_mutex.AssertHeld();
839 GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
841 g_gmock_mutex.AssertHeld();
846 bool AllPrerequisitesAreSatisfied()
const 855 GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
857 g_gmock_mutex.AssertHeld();
863 GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
865 g_gmock_mutex.AssertHeld();
873 void CheckActionCountIfNotDone()
const 876 friend class ::testing::Sequence;
877 friend class ::testing::internal::ExpectationTester;
879 template <
typename Function>
883 void UntypedTimes(
const Cardinality & a_cardinality);
889 const string source_text_;
891 bool cardinality_specified_;
905 UntypedActions untyped_actions_;
906 bool extra_matcher_specified_;
907 bool repeated_action_specified_;
908 bool retires_on_saturation_;
910 mutable bool action_count_checked_;
911 mutable Mutex mutex_;
917 template <
typename F>
926 const char * a_file,
int a_line,
const string & a_source_text,
927 const ArgumentMatcherTuple & m)
928 : ExpectationBase(a_file, a_line, a_source_text),
935 extra_matcher_(
A<const ArgumentTuple & >()),
942 CheckActionCountIfNotDone();
944 for (UntypedActions::const_iterator it = untyped_actions_.begin();
945 it != untyped_actions_.end(); ++it)
947 delete static_cast<const Action<F>*
>(*it);
954 if (last_clause_ == kWith)
956 ExpectSpecProperty(
false,
957 ".With() cannot appear " 958 "more than once in an EXPECT_CALL().");
963 ExpectSpecProperty(last_clause_ < kWith,
964 ".With() must be the first " 965 "clause in an EXPECT_CALL().");
968 last_clause_ = kWith;
971 extra_matcher_specified_ =
true;
991 ExpectSpecProperty(last_clause_ <= kInSequence,
992 ".InSequence() cannot appear after .After()," 993 " .WillOnce(), .WillRepeatedly(), or " 994 ".RetiresOnSaturation().");
995 last_clause_ = kInSequence;
1002 return InSequence(s1).InSequence(s2);
1005 const Sequence & s3)
1007 return InSequence(s1, s2).InSequence(s3);
1010 const Sequence & s3,
const Sequence & s4)
1012 return InSequence(s1, s2, s3).InSequence(s4);
1015 const Sequence & s3,
const Sequence & s4,
1016 const Sequence & s5)
1018 return InSequence(s1, s2, s3, s4).InSequence(s5);
1024 ExpectSpecProperty(last_clause_ <= kAfter,
1025 ".After() cannot appear after .WillOnce()," 1026 " .WillRepeatedly(), or " 1027 ".RetiresOnSaturation().");
1028 last_clause_ = kAfter;
1032 immediate_prerequisites_ += *it;
1039 return After(s1).
After(s2);
1044 return After(s1, s2).
After(s3);
1049 return After(s1, s2, s3).
After(s4);
1055 return After(s1, s2, s3, s4).
After(s5);
1061 ExpectSpecProperty(last_clause_ <= kWillOnce,
1062 ".WillOnce() cannot appear after " 1063 ".WillRepeatedly() or .RetiresOnSaturation().");
1064 last_clause_ = kWillOnce;
1066 untyped_actions_.push_back(
new Action<F>(action));
1068 if (!cardinality_specified())
1070 set_cardinality(
Exactly(static_cast<int>(untyped_actions_.size())));
1079 if (last_clause_ == kWillRepeatedly)
1081 ExpectSpecProperty(
false,
1082 ".WillRepeatedly() cannot appear " 1083 "more than once in an EXPECT_CALL().");
1088 ExpectSpecProperty(last_clause_ < kWillRepeatedly,
1089 ".WillRepeatedly() cannot appear " 1090 "after .RetiresOnSaturation().");
1093 last_clause_ = kWillRepeatedly;
1094 repeated_action_specified_ =
true;
1096 repeated_action_ = action;
1098 if (!cardinality_specified())
1100 set_cardinality(
AtLeast(static_cast<int>(untyped_actions_.size())));
1105 CheckActionCountIfNotDone();
1112 ExpectSpecProperty(last_clause_ < kRetiresOnSaturation,
1113 ".RetiresOnSaturation() cannot appear " 1115 last_clause_ = kRetiresOnSaturation;
1116 retires_on_saturation_ =
true;
1120 CheckActionCountIfNotDone();
1134 return extra_matcher_;
1144 if (extra_matcher_specified_)
1146 *os <<
" Expected args: ";
1147 extra_matcher_.DescribeTo(os);
1153 template <
typename Function>
1160 return owner_->GetHandleOf(
this);
1171 g_gmock_mutex.AssertHeld();
1172 return TupleMatches(matchers_, args) && extra_matcher_.Matches(args);
1179 g_gmock_mutex.AssertHeld();
1185 CheckActionCountIfNotDone();
1186 return !is_retired() && AllPrerequisitesAreSatisfied() &&
Matches(args);
1192 const ArgumentTuple & args,
1193 ::std::ostream * os)
const 1196 g_gmock_mutex.AssertHeld();
1200 *os <<
" Expected: the expectation is active\n" 1201 <<
" Actual: it is retired\n";
1213 if (!extra_matcher_.MatchAndExplain(args, &listener))
1215 *os <<
" Expected args: ";
1216 extra_matcher_.DescribeTo(os);
1217 *os <<
"\n Actual: don't match";
1224 else if (!AllPrerequisitesAreSatisfied())
1226 *os <<
" Expected: all pre-requisites are satisfied\n" 1227 <<
" Actual: the following immediate pre-requisites " 1228 <<
"are not satisfied:\n";
1230 FindUnsatisfiedPrerequisites(&unsatisfied_prereqs);
1234 it != unsatisfied_prereqs.
end(); ++it)
1236 it->expectation_base()->DescribeLocationTo(os);
1237 *os <<
"pre-requisite #" << i++ <<
"\n";
1240 *os <<
" (end of pre-requisites)\n";
1249 *os <<
"The call matches the expectation.\n";
1256 const ArgumentTuple & args)
const 1259 g_gmock_mutex.AssertHeld();
1260 const int count = call_count();
1261 Assert(count >= 1, __FILE__, __LINE__,
1262 "call_count() is <= 0 when GetCurrentAction() is " 1263 "called - this should never happen.");
1265 const int action_count =
static_cast<int>(untyped_actions_.size());
1267 if (action_count > 0 && !repeated_action_specified_ &&
1268 count > action_count)
1272 ::std::stringstream ss;
1273 DescribeLocationTo(&ss);
1274 ss <<
"Actions ran out in " << source_text() <<
"...\n" 1275 <<
"Called " << count <<
" times, but only " 1276 << action_count <<
" WillOnce()" 1277 << (action_count == 1 ?
" is" :
"s are") <<
" specified - ";
1278 mocker->DescribeDefaultActionTo(args, &ss);
1282 return count <= action_count ?
1283 *
static_cast<const Action<F>*
>(untyped_actions_[count - 1]) :
1296 const ArgumentTuple & args,
1297 ::std::ostream *
what,
1298 ::std::ostream * why)
1301 g_gmock_mutex.AssertHeld();
1306 IncrementCallCount();
1307 *
what <<
"Mock function called more times than expected - ";
1308 mocker->DescribeDefaultActionTo(args,
what);
1309 DescribeCallCountTo(why);
1317 IncrementCallCount();
1318 RetireAllPreRequisites();
1320 if (retires_on_saturation_ && IsSaturated())
1326 *
what <<
"Mock function call matches " << source_text() <<
"...\n";
1327 return &(GetCurrentAction(mocker, args));
1333 ArgumentMatcherTuple matchers_;
1352 const char * file,
int line,
1355 template <
typename F>
1366 : function_mocker_(function_mocker) {}
1371 const char * file,
int line,
const char * obj,
const char *
call)
1374 string(
"ON_CALL(") + obj +
", " + call +
") invoked");
1375 return function_mocker_->AddNewOnCallSpec(file, line, matchers_);
1381 const char * file,
int line,
const char * obj,
const char *
call)
1383 const string source_text(
string(
"EXPECT_CALL(") + obj +
", " + call +
")");
1385 return function_mocker_->AddNewExpectation(
1386 file, line, source_text, matchers_);
1390 template <
typename Function>
1395 matchers_ = matchers;
1412 # pragma warning(push) // Saves the current warning state. 1413 # pragma warning(disable:4355) // Temporarily disables warning 4355. 1431 virtual void PrintAsActionResult(::std::ostream * os)
const = 0;
1435 template <
typename T>
1455 *os <<
"\n Returns: ";
1462 template <
typename F>
1466 const string & call_description)
1474 template <
typename F>
1499 template <
typename F>
1503 const string & call_description)
1510 template <
typename F>
1523 template <
typename F>
1540 VerifyAndClearExpectationsLocked();
1541 Mock::UnregisterLocked(
this);
1542 ClearDefaultActionsLocked();
1549 const ArgumentTuple & args)
const 1551 for (UntypedOnCallSpecs::const_reverse_iterator it
1552 = untyped_on_call_specs_.rbegin();
1553 it != untyped_on_call_specs_.rend(); ++it)
1572 const string & call_description)
const 1575 this->FindOnCallSpec(args);
1582 const string message = call_description +
1583 "\n The mock function has no default action " 1584 "set, and its return type has no default value set.";
1585 #if GTEST_HAS_EXCEPTIONS 1589 throw std::runtime_error(message);
1604 const void * untyped_args,
1605 const string & call_description)
const 1607 const ArgumentTuple & args =
1608 *
static_cast<const ArgumentTuple *
>(untyped_args);
1609 return ResultHolder::PerformDefaultAction(
this, args, call_description);
1617 const void * untyped_action,
const void * untyped_args)
const 1622 const ArgumentTuple & args =
1623 *
static_cast<const ArgumentTuple *
>(untyped_args);
1624 return ResultHolder::PerformAction(action, args);
1632 g_gmock_mutex.AssertHeld();
1642 untyped_on_call_specs_.swap(specs_to_delete);
1644 g_gmock_mutex.Unlock();
1646 for (UntypedOnCallSpecs::const_iterator it =
1647 specs_to_delete.begin();
1648 it != specs_to_delete.end(); ++it)
1655 g_gmock_mutex.Lock();
1659 template <
typename Function>
1670 return static_cast<const ResultHolder *
>(
1671 this->UntypedInvokeWith(&args))->GetValueAndDelete();
1676 const char * file,
int line,
1677 const ArgumentMatcherTuple & m)
1680 Mock::RegisterUseByOnCallOrExpectCall(MockObject(), file, line);
1682 untyped_on_call_specs_.push_back(on_call_spec);
1683 return *on_call_spec;
1690 const string & source_text,
1691 const ArgumentMatcherTuple & m)
1694 Mock::RegisterUseByOnCallOrExpectCall(MockObject(), file, line);
1698 untyped_expectations_.push_back(untyped_expectation);
1701 Sequence *
const implicit_sequence = g_gmock_implicit_sequence.get();
1703 if (implicit_sequence != NULL)
1708 return *expectation;
1724 ::std::ostream * os)
const 1730 *os << (internal::type_equals<Result, void>::value ?
1731 "returning directly.\n" :
1732 "returning default value.\n");
1737 *os <<
"taking default action specified at:\n" 1746 const void * untyped_args,
1747 ::std::ostream * os)
const 1750 const ArgumentTuple & args =
1751 *
static_cast<const ArgumentTuple *
>(untyped_args);
1752 *os <<
"Uninteresting mock function call - ";
1753 DescribeDefaultActionTo(args, os);
1754 *os <<
" Function call: " << Name();
1775 const void * untyped_args,
1776 const void ** untyped_action,
bool * is_excessive,
1777 ::std::ostream *
what, ::std::ostream * why)
1780 const ArgumentTuple & args =
1781 *
static_cast<const ArgumentTuple *
>(untyped_args);
1787 this->FormatUnexpectedCallMessageLocked(args,
what, why);
1800 *untyped_action = action;
1806 ::std::ostream * os)
const 1808 const ArgumentTuple & args =
1809 *
static_cast<const ArgumentTuple *
>(untyped_args);
1816 const ArgumentTuple & args)
const 1819 g_gmock_mutex.AssertHeld();
1821 for (
typename UntypedExpectations::const_reverse_iterator it =
1822 untyped_expectations_.rbegin();
1823 it != untyped_expectations_.rend(); ++it)
1839 const ArgumentTuple & args,
1840 ::std::ostream * os,
1841 ::std::ostream * why)
const 1844 g_gmock_mutex.AssertHeld();
1845 *os <<
"\nUnexpected mock function call - ";
1846 DescribeDefaultActionTo(args, os);
1847 PrintTriedExpectationsLocked(args, why);
1853 const ArgumentTuple & args,
1854 ::std::ostream * why)
const 1857 g_gmock_mutex.AssertHeld();
1858 const int count =
static_cast<int>(untyped_expectations_.size());
1859 *why <<
"Google Mock tried the following " << count <<
" " 1860 << (count == 1 ?
"expectation, but it didn't match" :
1861 "expectations, but none matched")
1864 for (
int i = 0; i <
count; i++)
1873 *why <<
"tried expectation #" << i <<
": ";
1902 # pragma warning(pop) // Restores the warning state. 1939 template <
typename T>
1940 inline const T &
Const(
const T & x) {
return x; }
1952 #define GMOCK_ON_CALL_IMPL_(obj, call) \ 1953 ((obj).gmock_##call).InternalDefaultActionSetAt(__FILE__, __LINE__, \ 1955 #define ON_CALL(obj, call) GMOCK_ON_CALL_IMPL_(obj, call) 1957 #define GMOCK_EXPECT_CALL_IMPL_(obj, call) \ 1958 ((obj).gmock_##call).InternalExpectedAt(__FILE__, __LINE__, #obj, #call) 1959 #define EXPECT_CALL(obj, call) GMOCK_EXPECT_CALL_IMPL_(obj, call) 1961 #endif // GMOCK_INCLUDE_GMOCK_GMOCK_SPEC_BUILDERS_H_ void ExpectSpecProperty(bool property, const string &failure_message) const
virtual ~TypedExpectation()
Function< F >::ArgumentMatcherTuple ArgumentMatcherTuple
void ExpectSpecProperty(bool property, const string &failure_message) const
GTEST_API_ ThreadLocal< Sequence * > g_gmock_implicit_sequence
virtual void UntypedDescribeUninterestingCall(const void *untyped_args,::std::ostream *os) const GTEST_LOCK_EXCLUDED_(g_gmock_mutex)
void AssertSpecProperty(bool property, const string &failure_message) const
bool Matches(const ArgumentTuple &args) const GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
OnCallSpec(const char *a_file, int a_line, const ArgumentMatcherTuple &matchers)
virtual ~UntypedActionResultHolderBase()
virtual ~FunctionMockerBase() GTEST_LOCK_EXCLUDED_(g_gmock_mutex)
ExpectationSet(const Expectation &e)
const internal::linked_ptr< internal::ExpectationBase > & expectation_base() const
#define GTEST_DISALLOW_COPY_AND_ASSIGN_(type)
virtual Expectation GetHandle()=0
TypedExpectation & Times(int n)
GTEST_API_ Cardinality AtLeast(int n)
TypedExpectation(FunctionMockerBase< F > *owner, const char *a_file, int a_line, const string &a_source_text, const ArgumentMatcherTuple &m)
virtual void UntypedPrintArgs(const void *untyped_args,::std::ostream *os) const
class testing::internal::GTestFlagSaver GTEST_ATTRIBUTE_UNUSED_
ExpectationSet(internal::ExpectationBase &exp)
TypedExpectation & WillOnce(const Action< F > &action)
static ActionResultHolder * PerformAction(const Action< F > &action, const typename Function< F >::ArgumentTuple &args)
bool IsSatisfied() const GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
bool ShouldHandleArguments(const ArgumentTuple &args) const GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
bool cardinality_specified() const
const Action< F > & GetAction() const
void DescribeLocationTo(::std::ostream *os) const
std::vector< internal::linked_ptr< ExpectationBase > > UntypedExpectations
GTEST_API_::std::string FormatFileLocation(const char *file, int line)
TypedExpectation< F > * FindMatchingExpectationLocked(const ArgumentTuple &args) const GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
MockSpec(internal::FunctionMockerBase< F > *function_mocker)
TypedExpectation & Times(const Cardinality &a_cardinality)
TypedExpectation< F > & AddNewExpectation(const char *file, int line, const string &source_text, const ArgumentMatcherTuple &m) GTEST_LOCK_EXCLUDED_(g_gmock_mutex)
internal::OnCallSpec< F > & InternalDefaultActionSetAt(const char *file, int line, const char *obj, const char *call)
std::vector< const void * > UntypedActions
OnCallSpec & With(const Matcher< const ArgumentTuple & > &m)
const Matcher< const ArgumentTuple & > & extra_matcher() const
static ActionResultHolder * PerformDefaultAction(const FunctionMockerBase< F > *func_mocker, const typename Function< F >::ArgumentTuple &args, const string &call_description)
const Action< F > & repeated_action() const
TypedExpectation & InSequence(const Sequence &s1, const Sequence &s2, const Sequence &s3, const Sequence &s4)
internal::string str() const
GTEST_API_ GTEST_DECLARE_STATIC_MUTEX_(g_gmock_mutex)
bool is_retired() const GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
TypedExpectation & After(const ExpectationSet &s1, const ExpectationSet &s2)
Function< F >::ArgumentTuple ArgumentTuple
void IncrementCallCount() GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
bool IsOverSaturatedByCallCount(int call_count) const
void GetValueAndDelete() const
bool operator==(const ExpectationSet &rhs) const
bool TupleMatches(const MatcherTuple &matcher_tuple, const ValueTuple &value_tuple)
void UntypedTimes(const Cardinality &a_cardinality)
const OnCallSpec< F > * FindOnCallSpec(const ArgumentTuple &args) const
static ActionResultHolder * PerformAction(const Action< F > &action, const typename Function< F >::ArgumentTuple &args)
Result InvokeWith(const ArgumentTuple &args) GTEST_LOCK_EXCLUDED_(g_gmock_mutex)
Function< F >::ArgumentTuple ArgumentTuple
virtual void PrintAsActionResult(::std::ostream *os) const
TypedExpectation & After(const ExpectationSet &s1, const ExpectationSet &s2, const ExpectationSet &s3, const ExpectationSet &s4, const ExpectationSet &s5)
TypedExpectation & After(const ExpectationSet &s1, const ExpectationSet &s2, const ExpectationSet &s3, const ExpectationSet &s4)
virtual Expectation GetHandle()
bool operator==(const Expectation &rhs) const
TypedExpectation & InSequence(const Sequence &s1, const Sequence &s2)
Expectation::Set::const_iterator const_iterator
OnCallSpec< F > & AddNewOnCallSpec(const char *file, int line, const ArgumentMatcherTuple &m) GTEST_LOCK_EXCLUDED_(g_gmock_mutex)
int call_count() const GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
const char * source_text() const
TypedExpectation & RetiresOnSaturation()
void ReportUninterestingCall(CallReaction reaction, const string &msg)
internal::TypedExpectation< F > & InternalExpectedAt(const char *file, int line, const char *obj, const char *call)
std::vector< const void * > UntypedOnCallSpecs
Expectation::Set::value_type value_type
internal::linked_ptr< internal::ExpectationBase > expectation_base_
internal::Function< F >::ArgumentTuple ArgumentTuple
TypedExpectation & InSequence(const Sequence &s)
void Expect(bool condition, const char *file, int line, const string &msg)
const Action< F > * GetActionForArguments(const FunctionMockerBase< F > *mocker, const ArgumentTuple &args,::std::ostream *what,::std::ostream *why) GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
#define GTEST_EXCLUSIVE_LOCK_REQUIRED_(locks)
bool operator()(const Expectation &lhs, const Expectation &rhs) const
virtual void PrintAsActionResult(::std::ostream *) const
const char * file() const
void AddExpectation(const Expectation &expectation) const
void PrintIfNotEmpty(const internal::string &explanation,::std::ostream *os)
bool operator!=(const ExpectationSet &rhs) const
bool Matches(const ArgumentTuple &args) const
GTEST_API_ void LogWithLocation(testing::internal::LogSeverity severity, const char *file, int line, const string &message)
internal::MatcherAsPredicate< M > Matches(M matcher)
Function< F >::Result Result
TypedExpectation & WillRepeatedly(const Action< F > &action)
GTEST_API_ void Log(LogSeverity severity, const string &message, int stack_frames_to_skip)
UntypedOnCallSpecBase(const char *a_file, int a_line)
void UniversalPrint(const T &value,::std::ostream *os)
#define GTEST_DISALLOW_ASSIGN_(type)
ActionResultHolder(T a_value)
virtual const ExpectationBase * UntypedFindMatchingExpectation(const void *untyped_args, const void **untyped_action, bool *is_excessive,::std::ostream *what,::std::ostream *why) GTEST_LOCK_EXCLUDED_(g_gmock_mutex)
Result PerformDefaultAction(const ArgumentTuple &args, const string &call_description) const
Function< F >::ArgumentTuple ArgumentTuple
T GetValueAndDelete() const
TypedExpectation & After(const ExpectationSet &s1, const ExpectationSet &s2, const ExpectationSet &s3)
internal::Function< F >::ArgumentMatcherTuple ArgumentMatcherTuple
void ExplainMatchFailureTupleTo(const MatcherTuple &matchers, const ValueTuple &values,::std::ostream *os)
void Retire() GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
void AssertSpecProperty(bool property, const string &failure_message) const
ExpectationSet & operator+=(const Expectation &e)
Function< F >::ArgumentMatcherTuple ArgumentMatcherTuple
virtual void ClearDefaultActionsLocked() GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
bool IsSaturated() const GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
GTEST_API_ Cardinality Exactly(int n)
bool IsSaturatedByCallCount(int call_count) const
void set_cardinality(const Cardinality &a_cardinality)
const_iterator end() const
ActionResultHolder< Result > ResultHolder
const_iterator begin() const
internal::DoDefaultAction DoDefault()
TypedExpectation & InSequence(const Sequence &s1, const Sequence &s2, const Sequence &s3, const Sequence &s4, const Sequence &s5)
MockSpec< F > & current_spec()
OnCallSpec & WillByDefault(const Action< F > &action)
void Assert(bool condition, const char *file, int line)
Result Perform(const ArgumentTuple &args) const
TypedExpectation & After(const ExpectationSet &s)
void FormatUnexpectedCallMessageLocked(const ArgumentTuple &args,::std::ostream *os,::std::ostream *why) const GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
void SetMatchers(const ArgumentMatcherTuple &matchers)
void ExplainMatchResultTo(const ArgumentTuple &args,::std::ostream *os) const GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
static ActionResultHolder * PerformDefaultAction(const FunctionMockerBase< F > *func_mocker, const typename Function< F >::ArgumentTuple &args, const string &call_description)
const char * file() const
bool IsSatisfiedByCallCount(int call_count) const
const ArgumentMatcherTuple & matchers() const
static void Print(const T &value,::std::ostream *os)
TypedExpectation & With(const Matcher< const ArgumentTuple & > &m)
::std::set< Expectation, Less > Set
const Action< F > & GetCurrentAction(const FunctionMockerBase< F > *mocker, const ArgumentTuple &args) const GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
const Cardinality & cardinality() const
bool operator!=(const Expectation &rhs) const
void DescribeCallCountTo(::std::ostream *os) const GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
bool IsOverSaturated() const GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
void DescribeDefaultActionTo(const ArgumentTuple &args,::std::ostream *os) const
TypedExpectation & InSequence(const Sequence &s1, const Sequence &s2, const Sequence &s3)
void PrintTriedExpectationsLocked(const ArgumentTuple &args,::std::ostream *why) const GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex)
const T & Const(const T &x)
Expectation::Set expectations_
Function< F >::Result Result
Function< F >::ArgumentMatcherTuple ArgumentMatcherTuple
virtual UntypedActionResultHolderBase * UntypedPerformDefaultAction(const void *untyped_args, const string &call_description) const
virtual void MaybeDescribeExtraMatcherTo(::std::ostream *os)
virtual UntypedActionResultHolderBase * UntypedPerformAction(const void *untyped_action, const void *untyped_args) const
#define GTEST_LOCK_EXCLUDED_(locks)