1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038 |
- #ifndef GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_SPEC_BUILDERS_H_
- #define GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_SPEC_BUILDERS_H_
- #include <functional>
- #include <map>
- #include <memory>
- #include <set>
- #include <sstream>
- #include <string>
- #include <type_traits>
- #include <utility>
- #include <vector>
- #include "gmock/gmock-actions.h"
- #include "gmock/gmock-cardinalities.h"
- #include "gmock/gmock-matchers.h"
- #include "gmock/internal/gmock-internal-utils.h"
- #include "gmock/internal/gmock-port.h"
- #include "gtest/gtest.h"
- #if GTEST_HAS_EXCEPTIONS
- # include <stdexcept> // NOLINT
- #endif
- GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \
- )
- namespace testing {
- class Expectation;
- class ExpectationSet;
- namespace internal {
- template <typename F> class FunctionMocker;
- class ExpectationBase;
- template <typename F> class TypedExpectation;
- class ExpectationTester;
- template <typename MockClass>
- class NiceMockImpl;
- template <typename MockClass>
- class StrictMockImpl;
- template <typename MockClass>
- class NaggyMockImpl;
- GTEST_API_ GTEST_DECLARE_STATIC_MUTEX_(g_gmock_mutex);
- class UntypedActionResultHolderBase;
- class GTEST_API_ UntypedFunctionMockerBase {
- public:
- UntypedFunctionMockerBase();
- virtual ~UntypedFunctionMockerBase();
-
-
-
- bool VerifyAndClearExpectationsLocked()
- GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex);
-
- virtual void ClearDefaultActionsLocked()
- GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) = 0;
-
-
-
-
-
-
-
-
- virtual UntypedActionResultHolderBase* UntypedPerformDefaultAction(
- void* untyped_args, const std::string& call_description) const = 0;
-
-
-
- virtual UntypedActionResultHolderBase* UntypedPerformAction(
- const void* untyped_action, void* untyped_args) const = 0;
-
-
-
- virtual void UntypedDescribeUninterestingCall(
- const void* untyped_args,
- ::std::ostream* os) const
- GTEST_LOCK_EXCLUDED_(g_gmock_mutex) = 0;
-
-
-
-
-
-
- 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) = 0;
-
- virtual void UntypedPrintArgs(const void* untyped_args,
- ::std::ostream* os) const = 0;
-
-
-
-
- void RegisterOwner(const void* mock_obj)
- GTEST_LOCK_EXCLUDED_(g_gmock_mutex);
-
-
-
- void SetOwnerAndName(const void* mock_obj, const char* name)
- GTEST_LOCK_EXCLUDED_(g_gmock_mutex);
-
-
-
- const void* MockObject() const
- GTEST_LOCK_EXCLUDED_(g_gmock_mutex);
-
-
- const char* Name() const
- GTEST_LOCK_EXCLUDED_(g_gmock_mutex);
-
-
-
-
- UntypedActionResultHolderBase* UntypedInvokeWith(void* untyped_args)
- GTEST_LOCK_EXCLUDED_(g_gmock_mutex);
- protected:
- typedef std::vector<const void*> UntypedOnCallSpecs;
- using UntypedExpectations = std::vector<std::shared_ptr<ExpectationBase>>;
-
-
- Expectation GetHandleOf(ExpectationBase* exp);
-
-
-
- const void* mock_obj_;
-
-
- const char* name_;
-
- UntypedOnCallSpecs untyped_on_call_specs_;
-
-
-
-
-
-
-
-
-
- UntypedExpectations untyped_expectations_;
- };
- class UntypedOnCallSpecBase {
- public:
-
- UntypedOnCallSpecBase(const char* a_file, int a_line)
- : file_(a_file), line_(a_line), last_clause_(kNone) {}
-
- const char* file() const { return file_; }
- int line() const { return line_; }
- protected:
-
- enum Clause {
-
-
- kNone,
- kWith,
- kWillByDefault
- };
-
- void AssertSpecProperty(bool property,
- const std::string& failure_message) const {
- Assert(property, file_, line_, failure_message);
- }
-
- void ExpectSpecProperty(bool property,
- const std::string& failure_message) const {
- Expect(property, file_, line_, failure_message);
- }
- const char* file_;
- int line_;
-
-
- Clause last_clause_;
- };
- template <typename F>
- class OnCallSpec : public UntypedOnCallSpecBase {
- public:
- typedef typename Function<F>::ArgumentTuple ArgumentTuple;
- typedef typename Function<F>::ArgumentMatcherTuple ArgumentMatcherTuple;
-
-
- OnCallSpec(const char* a_file, int a_line,
- const ArgumentMatcherTuple& matchers)
- : UntypedOnCallSpecBase(a_file, a_line),
- matchers_(matchers),
-
-
-
- extra_matcher_(A<const ArgumentTuple&>()) {}
-
- OnCallSpec& With(const Matcher<const ArgumentTuple&>& m) {
-
- ExpectSpecProperty(last_clause_ < kWith,
- ".With() cannot appear "
- "more than once in an ON_CALL().");
- last_clause_ = kWith;
- extra_matcher_ = m;
- return *this;
- }
-
- OnCallSpec& WillByDefault(const Action<F>& action) {
- ExpectSpecProperty(last_clause_ < kWillByDefault,
- ".WillByDefault() must appear "
- "exactly once in an ON_CALL().");
- last_clause_ = kWillByDefault;
- ExpectSpecProperty(!action.IsDoDefault(),
- "DoDefault() cannot be used in ON_CALL().");
- action_ = action;
- return *this;
- }
-
- bool Matches(const ArgumentTuple& args) const {
- return TupleMatches(matchers_, args) && extra_matcher_.Matches(args);
- }
-
- const Action<F>& GetAction() const {
- AssertSpecProperty(last_clause_ == kWillByDefault,
- ".WillByDefault() must appear exactly "
- "once in an ON_CALL().");
- return action_;
- }
- private:
-
-
-
-
-
-
-
-
-
-
-
-
-
- ArgumentMatcherTuple matchers_;
- Matcher<const ArgumentTuple&> extra_matcher_;
- Action<F> action_;
- };
- enum CallReaction {
- kAllow,
- kWarn,
- kFail,
- };
- }
- class GTEST_API_ Mock {
- public:
-
-
-
- static void AllowLeak(const void* mock_obj)
- GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
-
-
-
- static bool VerifyAndClearExpectations(void* mock_obj)
- GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
-
-
-
- static bool VerifyAndClear(void* mock_obj)
- GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
-
- static bool IsNaggy(void* mock_obj)
- GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
-
- static bool IsNice(void* mock_obj)
- GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
-
- static bool IsStrict(void* mock_obj)
- GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
- private:
- friend class internal::UntypedFunctionMockerBase;
-
-
- template <typename F>
- friend class internal::FunctionMocker;
- template <typename MockClass>
- friend class internal::NiceMockImpl;
- template <typename MockClass>
- friend class internal::NaggyMockImpl;
- template <typename MockClass>
- friend class internal::StrictMockImpl;
-
-
- static void AllowUninterestingCalls(const void* mock_obj)
- GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
-
-
- static void WarnUninterestingCalls(const void* mock_obj)
- GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
-
-
- static void FailUninterestingCalls(const void* mock_obj)
- GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
-
-
- static void UnregisterCallReaction(const void* mock_obj)
- GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
-
-
- static internal::CallReaction GetReactionOnUninterestingCalls(
- const void* mock_obj)
- GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
-
-
-
- static bool VerifyAndClearExpectationsLocked(void* mock_obj)
- GTEST_EXCLUSIVE_LOCK_REQUIRED_(internal::g_gmock_mutex);
-
- static void ClearDefaultActionsLocked(void* mock_obj)
- GTEST_EXCLUSIVE_LOCK_REQUIRED_(internal::g_gmock_mutex);
-
- static void Register(
- const void* mock_obj,
- internal::UntypedFunctionMockerBase* mocker)
- GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
-
-
-
- static void RegisterUseByOnCallOrExpectCall(
- const void* mock_obj, const char* file, int line)
- GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
-
-
-
-
- static void UnregisterLocked(internal::UntypedFunctionMockerBase* mocker)
- GTEST_EXCLUSIVE_LOCK_REQUIRED_(internal::g_gmock_mutex);
- };
- class GTEST_API_ Expectation {
- public:
-
- Expectation();
- Expectation(Expectation&&) = default;
- Expectation(const Expectation&) = default;
- Expectation& operator=(Expectation&&) = default;
- Expectation& operator=(const Expectation&) = default;
- ~Expectation();
-
-
-
-
-
-
-
-
-
- Expectation(internal::ExpectationBase& exp);
-
-
-
-
- bool operator==(const Expectation& rhs) const {
- return expectation_base_ == rhs.expectation_base_;
- }
- bool operator!=(const Expectation& rhs) const { return !(*this == rhs); }
- private:
- friend class ExpectationSet;
- friend class Sequence;
- friend class ::testing::internal::ExpectationBase;
- friend class ::testing::internal::UntypedFunctionMockerBase;
- template <typename F>
- friend class ::testing::internal::FunctionMocker;
- template <typename F>
- friend class ::testing::internal::TypedExpectation;
-
- class Less {
- public:
- bool operator()(const Expectation& lhs, const Expectation& rhs) const {
- return lhs.expectation_base_.get() < rhs.expectation_base_.get();
- }
- };
- typedef ::std::set<Expectation, Less> Set;
- Expectation(
- const std::shared_ptr<internal::ExpectationBase>& expectation_base);
-
- const std::shared_ptr<internal::ExpectationBase>& expectation_base() const {
- return expectation_base_;
- }
-
- std::shared_ptr<internal::ExpectationBase> expectation_base_;
- };
- class ExpectationSet {
- public:
-
- typedef Expectation::Set::const_iterator const_iterator;
-
- typedef Expectation::Set::value_type value_type;
-
- ExpectationSet() {}
-
-
-
- ExpectationSet(internal::ExpectationBase& exp) {
- *this += Expectation(exp);
- }
-
-
-
- ExpectationSet(const Expectation& e) {
- *this += e;
- }
-
-
-
-
- bool operator==(const ExpectationSet& rhs) const {
- return expectations_ == rhs.expectations_;
- }
- bool operator!=(const ExpectationSet& rhs) const { return !(*this == rhs); }
-
-
- ExpectationSet& operator+=(const Expectation& e) {
- expectations_.insert(e);
- return *this;
- }
- int size() const { return static_cast<int>(expectations_.size()); }
- const_iterator begin() const { return expectations_.begin(); }
- const_iterator end() const { return expectations_.end(); }
- private:
- Expectation::Set expectations_;
- };
- class GTEST_API_ Sequence {
- public:
-
- Sequence() : last_expectation_(new Expectation) {}
-
-
- void AddExpectation(const Expectation& expectation) const;
- private:
-
- std::shared_ptr<Expectation> last_expectation_;
- };
- class GTEST_API_ InSequence {
- public:
- InSequence();
- ~InSequence();
- private:
- bool sequence_created_;
- GTEST_DISALLOW_COPY_AND_ASSIGN_(InSequence);
- } GTEST_ATTRIBUTE_UNUSED_;
- namespace internal {
- GTEST_API_ extern ThreadLocal<Sequence*> g_gmock_implicit_sequence;
- class GTEST_API_ ExpectationBase {
- public:
-
- ExpectationBase(const char* file, int line, const std::string& source_text);
- virtual ~ExpectationBase();
-
- const char* file() const { return file_; }
- int line() const { return line_; }
- const char* source_text() const { return source_text_.c_str(); }
-
- const Cardinality& cardinality() const { return cardinality_; }
-
- void DescribeLocationTo(::std::ostream* os) const {
- *os << FormatFileLocation(file(), line()) << " ";
- }
-
-
- void DescribeCallCountTo(::std::ostream* os) const
- GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex);
-
-
- virtual void MaybeDescribeExtraMatcherTo(::std::ostream* os) = 0;
- protected:
- friend class ::testing::Expectation;
- friend class UntypedFunctionMockerBase;
- enum Clause {
-
- kNone,
- kWith,
- kTimes,
- kInSequence,
- kAfter,
- kWillOnce,
- kWillRepeatedly,
- kRetiresOnSaturation
- };
- typedef std::vector<const void*> UntypedActions;
-
-
- virtual Expectation GetHandle() = 0;
-
- void AssertSpecProperty(bool property,
- const std::string& failure_message) const {
- Assert(property, file_, line_, failure_message);
- }
-
- void ExpectSpecProperty(bool property,
- const std::string& failure_message) const {
- Expect(property, file_, line_, failure_message);
- }
-
-
- void SpecifyCardinality(const Cardinality& cardinality);
-
-
- bool cardinality_specified() const { return cardinality_specified_; }
-
- void set_cardinality(const Cardinality& a_cardinality) {
- cardinality_ = a_cardinality;
- }
-
-
-
-
- void RetireAllPreRequisites()
- GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex);
-
- bool is_retired() const
- GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
- g_gmock_mutex.AssertHeld();
- return retired_;
- }
-
- void Retire()
- GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
- g_gmock_mutex.AssertHeld();
- retired_ = true;
- }
-
- bool IsSatisfied() const
- GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
- g_gmock_mutex.AssertHeld();
- return cardinality().IsSatisfiedByCallCount(call_count_);
- }
-
- bool IsSaturated() const
- GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
- g_gmock_mutex.AssertHeld();
- return cardinality().IsSaturatedByCallCount(call_count_);
- }
-
- bool IsOverSaturated() const
- GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
- g_gmock_mutex.AssertHeld();
- return cardinality().IsOverSaturatedByCallCount(call_count_);
- }
-
-
- bool AllPrerequisitesAreSatisfied() const
- GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex);
-
- void FindUnsatisfiedPrerequisites(ExpectationSet* result) const
- GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex);
-
- int call_count() const
- GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
- g_gmock_mutex.AssertHeld();
- return call_count_;
- }
-
- void IncrementCallCount()
- GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
- g_gmock_mutex.AssertHeld();
- call_count_++;
- }
-
-
-
-
- void CheckActionCountIfNotDone() const
- GTEST_LOCK_EXCLUDED_(mutex_);
- friend class ::testing::Sequence;
- friend class ::testing::internal::ExpectationTester;
- template <typename Function>
- friend class TypedExpectation;
-
- void UntypedTimes(const Cardinality& a_cardinality);
-
-
- const char* file_;
- int line_;
- const std::string source_text_;
-
- bool cardinality_specified_;
- Cardinality cardinality_;
-
-
-
-
-
-
- ExpectationSet immediate_prerequisites_;
-
-
- int call_count_;
- bool retired_;
- UntypedActions untyped_actions_;
- bool extra_matcher_specified_;
- bool repeated_action_specified_;
- bool retires_on_saturation_;
- Clause last_clause_;
- mutable bool action_count_checked_;
- mutable Mutex mutex_;
- };
- template <typename F>
- class TypedExpectation : public ExpectationBase {
- public:
- typedef typename Function<F>::ArgumentTuple ArgumentTuple;
- typedef typename Function<F>::ArgumentMatcherTuple ArgumentMatcherTuple;
- typedef typename Function<F>::Result Result;
- TypedExpectation(FunctionMocker<F>* owner, const char* a_file, int a_line,
- const std::string& a_source_text,
- const ArgumentMatcherTuple& m)
- : ExpectationBase(a_file, a_line, a_source_text),
- owner_(owner),
- matchers_(m),
-
-
-
- extra_matcher_(A<const ArgumentTuple&>()),
- repeated_action_(DoDefault()) {}
- ~TypedExpectation() override {
-
-
- CheckActionCountIfNotDone();
- for (UntypedActions::const_iterator it = untyped_actions_.begin();
- it != untyped_actions_.end(); ++it) {
- delete static_cast<const Action<F>*>(*it);
- }
- }
-
- TypedExpectation& With(const Matcher<const ArgumentTuple&>& m) {
- if (last_clause_ == kWith) {
- ExpectSpecProperty(false,
- ".With() cannot appear "
- "more than once in an EXPECT_CALL().");
- } else {
- ExpectSpecProperty(last_clause_ < kWith,
- ".With() must be the first "
- "clause in an EXPECT_CALL().");
- }
- last_clause_ = kWith;
- extra_matcher_ = m;
- extra_matcher_specified_ = true;
- return *this;
- }
-
- TypedExpectation& Times(const Cardinality& a_cardinality) {
- ExpectationBase::UntypedTimes(a_cardinality);
- return *this;
- }
-
- TypedExpectation& Times(int n) {
- return Times(Exactly(n));
- }
-
- TypedExpectation& InSequence(const Sequence& s) {
- ExpectSpecProperty(last_clause_ <= kInSequence,
- ".InSequence() cannot appear after .After(),"
- " .WillOnce(), .WillRepeatedly(), or "
- ".RetiresOnSaturation().");
- last_clause_ = kInSequence;
- s.AddExpectation(GetHandle());
- return *this;
- }
- TypedExpectation& InSequence(const Sequence& s1, const Sequence& s2) {
- return InSequence(s1).InSequence(s2);
- }
- TypedExpectation& InSequence(const Sequence& s1, const Sequence& s2,
- const Sequence& s3) {
- return InSequence(s1, s2).InSequence(s3);
- }
- TypedExpectation& InSequence(const Sequence& s1, const Sequence& s2,
- const Sequence& s3, const Sequence& s4) {
- return InSequence(s1, s2, s3).InSequence(s4);
- }
- TypedExpectation& InSequence(const Sequence& s1, const Sequence& s2,
- const Sequence& s3, const Sequence& s4,
- const Sequence& s5) {
- return InSequence(s1, s2, s3, s4).InSequence(s5);
- }
-
- TypedExpectation& After(const ExpectationSet& s) {
- ExpectSpecProperty(last_clause_ <= kAfter,
- ".After() cannot appear after .WillOnce(),"
- " .WillRepeatedly(), or "
- ".RetiresOnSaturation().");
- last_clause_ = kAfter;
- for (ExpectationSet::const_iterator it = s.begin(); it != s.end(); ++it) {
- immediate_prerequisites_ += *it;
- }
- return *this;
- }
- TypedExpectation& After(const ExpectationSet& s1, const ExpectationSet& s2) {
- return After(s1).After(s2);
- }
- TypedExpectation& After(const ExpectationSet& s1, const ExpectationSet& s2,
- const ExpectationSet& s3) {
- return After(s1, s2).After(s3);
- }
- TypedExpectation& After(const ExpectationSet& s1, const ExpectationSet& s2,
- const ExpectationSet& s3, const ExpectationSet& s4) {
- return After(s1, s2, s3).After(s4);
- }
- TypedExpectation& After(const ExpectationSet& s1, const ExpectationSet& s2,
- const ExpectationSet& s3, const ExpectationSet& s4,
- const ExpectationSet& s5) {
- return After(s1, s2, s3, s4).After(s5);
- }
-
- TypedExpectation& WillOnce(const Action<F>& action) {
- ExpectSpecProperty(last_clause_ <= kWillOnce,
- ".WillOnce() cannot appear after "
- ".WillRepeatedly() or .RetiresOnSaturation().");
- last_clause_ = kWillOnce;
- untyped_actions_.push_back(new Action<F>(action));
- if (!cardinality_specified()) {
- set_cardinality(Exactly(static_cast<int>(untyped_actions_.size())));
- }
- return *this;
- }
-
- TypedExpectation& WillRepeatedly(const Action<F>& action) {
- if (last_clause_ == kWillRepeatedly) {
- ExpectSpecProperty(false,
- ".WillRepeatedly() cannot appear "
- "more than once in an EXPECT_CALL().");
- } else {
- ExpectSpecProperty(last_clause_ < kWillRepeatedly,
- ".WillRepeatedly() cannot appear "
- "after .RetiresOnSaturation().");
- }
- last_clause_ = kWillRepeatedly;
- repeated_action_specified_ = true;
- repeated_action_ = action;
- if (!cardinality_specified()) {
- set_cardinality(AtLeast(static_cast<int>(untyped_actions_.size())));
- }
-
-
- CheckActionCountIfNotDone();
- return *this;
- }
-
- TypedExpectation& RetiresOnSaturation() {
- ExpectSpecProperty(last_clause_ < kRetiresOnSaturation,
- ".RetiresOnSaturation() cannot appear "
- "more than once.");
- last_clause_ = kRetiresOnSaturation;
- retires_on_saturation_ = true;
-
-
- CheckActionCountIfNotDone();
- return *this;
- }
-
-
- const ArgumentMatcherTuple& matchers() const {
- return matchers_;
- }
-
- const Matcher<const ArgumentTuple&>& extra_matcher() const {
- return extra_matcher_;
- }
-
- const Action<F>& repeated_action() const { return repeated_action_; }
-
-
- void MaybeDescribeExtraMatcherTo(::std::ostream* os) override {
- if (extra_matcher_specified_) {
- *os << " Expected args: ";
- extra_matcher_.DescribeTo(os);
- *os << "\n";
- }
- }
- private:
- template <typename Function>
- friend class FunctionMocker;
-
-
- Expectation GetHandle() override { return owner_->GetHandleOf(this); }
-
-
-
-
- bool Matches(const ArgumentTuple& args) const
- GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
- g_gmock_mutex.AssertHeld();
- return TupleMatches(matchers_, args) && extra_matcher_.Matches(args);
- }
-
-
- bool ShouldHandleArguments(const ArgumentTuple& args) const
- GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
- g_gmock_mutex.AssertHeld();
-
-
-
-
- CheckActionCountIfNotDone();
- return !is_retired() && AllPrerequisitesAreSatisfied() && Matches(args);
- }
-
-
- void ExplainMatchResultTo(
- const ArgumentTuple& args,
- ::std::ostream* os) const
- GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
- g_gmock_mutex.AssertHeld();
- if (is_retired()) {
- *os << " Expected: the expectation is active\n"
- << " Actual: it is retired\n";
- } else if (!Matches(args)) {
- if (!TupleMatches(matchers_, args)) {
- ExplainMatchFailureTupleTo(matchers_, args, os);
- }
- StringMatchResultListener listener;
- if (!extra_matcher_.MatchAndExplain(args, &listener)) {
- *os << " Expected args: ";
- extra_matcher_.DescribeTo(os);
- *os << "\n Actual: don't match";
- internal::PrintIfNotEmpty(listener.str(), os);
- *os << "\n";
- }
- } else if (!AllPrerequisitesAreSatisfied()) {
- *os << " Expected: all pre-requisites are satisfied\n"
- << " Actual: the following immediate pre-requisites "
- << "are not satisfied:\n";
- ExpectationSet unsatisfied_prereqs;
- FindUnsatisfiedPrerequisites(&unsatisfied_prereqs);
- int i = 0;
- for (ExpectationSet::const_iterator it = unsatisfied_prereqs.begin();
- it != unsatisfied_prereqs.end(); ++it) {
- it->expectation_base()->DescribeLocationTo(os);
- *os << "pre-requisite #" << i++ << "\n";
- }
- *os << " (end of pre-requisites)\n";
- } else {
-
-
-
-
- *os << "The call matches the expectation.\n";
- }
- }
-
- const Action<F>& GetCurrentAction(const FunctionMocker<F>* mocker,
- const ArgumentTuple& args) const
- GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
- g_gmock_mutex.AssertHeld();
- const int count = call_count();
- Assert(count >= 1, __FILE__, __LINE__,
- "call_count() is <= 0 when GetCurrentAction() is "
- "called - this should never happen.");
- const int action_count = static_cast<int>(untyped_actions_.size());
- if (action_count > 0 && !repeated_action_specified_ &&
- count > action_count) {
-
-
- ::std::stringstream ss;
- DescribeLocationTo(&ss);
- ss << "Actions ran out in " << source_text() << "...\n"
- << "Called " << count << " times, but only "
- << action_count << " WillOnce()"
- << (action_count == 1 ? " is" : "s are") << " specified - ";
- mocker->DescribeDefaultActionTo(args, &ss);
- Log(kWarning, ss.str(), 1);
- }
- return count <= action_count
- ? *static_cast<const Action<F>*>(
- untyped_actions_[static_cast<size_t>(count - 1)])
- : repeated_action();
- }
-
-
-
-
-
-
-
- const Action<F>* GetActionForArguments(const FunctionMocker<F>* mocker,
- const ArgumentTuple& args,
- ::std::ostream* what,
- ::std::ostream* why)
- GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
- g_gmock_mutex.AssertHeld();
- if (IsSaturated()) {
-
- IncrementCallCount();
- *what << "Mock function called more times than expected - ";
- mocker->DescribeDefaultActionTo(args, what);
- DescribeCallCountTo(why);
- return nullptr;
- }
- IncrementCallCount();
- RetireAllPreRequisites();
- if (retires_on_saturation_ && IsSaturated()) {
- Retire();
- }
-
- *what << "Mock function call matches " << source_text() <<"...\n";
- return &(GetCurrentAction(mocker, args));
- }
-
-
- FunctionMocker<F>* const owner_;
- ArgumentMatcherTuple matchers_;
- Matcher<const ArgumentTuple&> extra_matcher_;
- Action<F> repeated_action_;
- GTEST_DISALLOW_COPY_AND_ASSIGN_(TypedExpectation);
- };
- GTEST_API_ void LogWithLocation(testing::internal::LogSeverity severity,
- const char* file, int line,
- const std::string& message);
- template <typename F>
- class MockSpec {
- public:
- typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
- typedef typename internal::Function<F>::ArgumentMatcherTuple
- ArgumentMatcherTuple;
-
-
- MockSpec(internal::FunctionMocker<F>* function_mocker,
- const ArgumentMatcherTuple& matchers)
- : function_mocker_(function_mocker), matchers_(matchers) {}
-
-
- internal::OnCallSpec<F>& InternalDefaultActionSetAt(
- const char* file, int line, const char* obj, const char* call) {
- LogWithLocation(internal::kInfo, file, line,
- std::string("ON_CALL(") + obj + ", " + call + ") invoked");
- return function_mocker_->AddNewOnCallSpec(file, line, matchers_);
- }
-
-
- internal::TypedExpectation<F>& InternalExpectedAt(
- const char* file, int line, const char* obj, const char* call) {
- const std::string source_text(std::string("EXPECT_CALL(") + obj + ", " +
- call + ")");
- LogWithLocation(internal::kInfo, file, line, source_text + " invoked");
- return function_mocker_->AddNewExpectation(
- file, line, source_text, matchers_);
- }
-
-
-
- MockSpec<F>& operator()(const internal::WithoutMatchers&, void* const) {
- return *this;
- }
- private:
- template <typename Function>
- friend class internal::FunctionMocker;
-
- internal::FunctionMocker<F>* const function_mocker_;
-
- ArgumentMatcherTuple matchers_;
- };
- template <typename T>
- class ReferenceOrValueWrapper {
- public:
-
- explicit ReferenceOrValueWrapper(T value)
- : value_(std::move(value)) {
- }
-
-
-
- T Unwrap() { return std::move(value_); }
-
-
-
-
- const T& Peek() const {
- return value_;
- }
- private:
- T value_;
- };
- template <typename T>
- class ReferenceOrValueWrapper<T&> {
- public:
-
-
- typedef T& reference;
- explicit ReferenceOrValueWrapper(reference ref)
- : value_ptr_(&ref) {}
- T& Unwrap() { return *value_ptr_; }
- const T& Peek() const { return *value_ptr_; }
- private:
- T* value_ptr_;
- };
- class UntypedActionResultHolderBase {
- public:
- virtual ~UntypedActionResultHolderBase() {}
-
- virtual void PrintAsActionResult(::std::ostream* os) const = 0;
- };
- template <typename T>
- class ActionResultHolder : public UntypedActionResultHolderBase {
- public:
-
- T Unwrap() {
- return result_.Unwrap();
- }
-
- void PrintAsActionResult(::std::ostream* os) const override {
- *os << "\n Returns: ";
-
- UniversalPrinter<T>::Print(result_.Peek(), os);
- }
-
-
- template <typename F>
- static ActionResultHolder* PerformDefaultAction(
- const FunctionMocker<F>* func_mocker,
- typename Function<F>::ArgumentTuple&& args,
- const std::string& call_description) {
- return new ActionResultHolder(Wrapper(func_mocker->PerformDefaultAction(
- std::move(args), call_description)));
- }
-
-
- template <typename F>
- static ActionResultHolder* PerformAction(
- const Action<F>& action, typename Function<F>::ArgumentTuple&& args) {
- return new ActionResultHolder(
- Wrapper(action.Perform(std::move(args))));
- }
- private:
- typedef ReferenceOrValueWrapper<T> Wrapper;
- explicit ActionResultHolder(Wrapper result)
- : result_(std::move(result)) {
- }
- Wrapper result_;
- GTEST_DISALLOW_COPY_AND_ASSIGN_(ActionResultHolder);
- };
- template <>
- class ActionResultHolder<void> : public UntypedActionResultHolderBase {
- public:
- void Unwrap() { }
- void PrintAsActionResult(::std::ostream* ) const override {}
-
-
- template <typename F>
- static ActionResultHolder* PerformDefaultAction(
- const FunctionMocker<F>* func_mocker,
- typename Function<F>::ArgumentTuple&& args,
- const std::string& call_description) {
- func_mocker->PerformDefaultAction(std::move(args), call_description);
- return new ActionResultHolder;
- }
-
-
- template <typename F>
- static ActionResultHolder* PerformAction(
- const Action<F>& action, typename Function<F>::ArgumentTuple&& args) {
- action.Perform(std::move(args));
- return new ActionResultHolder;
- }
- private:
- ActionResultHolder() {}
- GTEST_DISALLOW_COPY_AND_ASSIGN_(ActionResultHolder);
- };
- template <typename F>
- class FunctionMocker;
- template <typename R, typename... Args>
- class FunctionMocker<R(Args...)> final : public UntypedFunctionMockerBase {
- using F = R(Args...);
- public:
- using Result = R;
- using ArgumentTuple = std::tuple<Args...>;
- using ArgumentMatcherTuple = std::tuple<Matcher<Args>...>;
- FunctionMocker() {}
-
-
-
-
-
-
-
-
-
-
-
-
- FunctionMocker(const FunctionMocker&) = delete;
- FunctionMocker& operator=(const FunctionMocker&) = delete;
-
-
-
- ~FunctionMocker() override GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {
- MutexLock l(&g_gmock_mutex);
- VerifyAndClearExpectationsLocked();
- Mock::UnregisterLocked(this);
- ClearDefaultActionsLocked();
- }
-
-
-
- const OnCallSpec<F>* FindOnCallSpec(
- const ArgumentTuple& args) const {
- for (UntypedOnCallSpecs::const_reverse_iterator it
- = untyped_on_call_specs_.rbegin();
- it != untyped_on_call_specs_.rend(); ++it) {
- const OnCallSpec<F>* spec = static_cast<const OnCallSpec<F>*>(*it);
- if (spec->Matches(args))
- return spec;
- }
- return nullptr;
- }
-
-
-
-
-
-
-
- Result PerformDefaultAction(ArgumentTuple&& args,
- const std::string& call_description) const {
- const OnCallSpec<F>* const spec =
- this->FindOnCallSpec(args);
- if (spec != nullptr) {
- return spec->GetAction().Perform(std::move(args));
- }
- const std::string message =
- call_description +
- "\n The mock function has no default action "
- "set, and its return type has no default value set.";
- #if GTEST_HAS_EXCEPTIONS
- if (!DefaultValue<Result>::Exists()) {
- throw std::runtime_error(message);
- }
- #else
- Assert(DefaultValue<Result>::Exists(), "", -1, message);
- #endif
- return DefaultValue<Result>::Get();
- }
-
-
-
-
-
- UntypedActionResultHolderBase* UntypedPerformDefaultAction(
- void* untyped_args,
- const std::string& call_description) const override {
- ArgumentTuple* args = static_cast<ArgumentTuple*>(untyped_args);
- return ResultHolder::PerformDefaultAction(this, std::move(*args),
- call_description);
- }
-
-
-
-
- UntypedActionResultHolderBase* UntypedPerformAction(
- const void* untyped_action, void* untyped_args) const override {
-
-
- const Action<F> action = *static_cast<const Action<F>*>(untyped_action);
- ArgumentTuple* args = static_cast<ArgumentTuple*>(untyped_args);
- return ResultHolder::PerformAction(action, std::move(*args));
- }
-
-
- void ClearDefaultActionsLocked() override
- GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
- g_gmock_mutex.AssertHeld();
-
-
-
-
-
-
-
- UntypedOnCallSpecs specs_to_delete;
- untyped_on_call_specs_.swap(specs_to_delete);
- g_gmock_mutex.Unlock();
- for (UntypedOnCallSpecs::const_iterator it =
- specs_to_delete.begin();
- it != specs_to_delete.end(); ++it) {
- delete static_cast<const OnCallSpec<F>*>(*it);
- }
-
-
- g_gmock_mutex.Lock();
- }
-
-
-
- Result Invoke(Args... args) GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {
- ArgumentTuple tuple(std::forward<Args>(args)...);
- std::unique_ptr<ResultHolder> holder(DownCast_<ResultHolder*>(
- this->UntypedInvokeWith(static_cast<void*>(&tuple))));
- return holder->Unwrap();
- }
- MockSpec<F> With(Matcher<Args>... m) {
- return MockSpec<F>(this, ::std::make_tuple(std::move(m)...));
- }
- protected:
- template <typename Function>
- friend class MockSpec;
- typedef ActionResultHolder<Result> ResultHolder;
-
- OnCallSpec<F>& AddNewOnCallSpec(
- const char* file, int line,
- const ArgumentMatcherTuple& m)
- GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {
- Mock::RegisterUseByOnCallOrExpectCall(MockObject(), file, line);
- OnCallSpec<F>* const on_call_spec = new OnCallSpec<F>(file, line, m);
- untyped_on_call_specs_.push_back(on_call_spec);
- return *on_call_spec;
- }
-
- TypedExpectation<F>& AddNewExpectation(const char* file, int line,
- const std::string& source_text,
- const ArgumentMatcherTuple& m)
- GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {
- Mock::RegisterUseByOnCallOrExpectCall(MockObject(), file, line);
- TypedExpectation<F>* const expectation =
- new TypedExpectation<F>(this, file, line, source_text, m);
- const std::shared_ptr<ExpectationBase> untyped_expectation(expectation);
-
-
- untyped_expectations_.push_back(untyped_expectation);
-
- Sequence* const implicit_sequence = g_gmock_implicit_sequence.get();
- if (implicit_sequence != nullptr) {
- implicit_sequence->AddExpectation(Expectation(untyped_expectation));
- }
- return *expectation;
- }
- private:
- template <typename Func> friend class TypedExpectation;
-
-
-
-
- void DescribeDefaultActionTo(const ArgumentTuple& args,
- ::std::ostream* os) const {
- const OnCallSpec<F>* const spec = FindOnCallSpec(args);
- if (spec == nullptr) {
- *os << (std::is_void<Result>::value ? "returning directly.\n"
- : "returning default value.\n");
- } else {
- *os << "taking default action specified at:\n"
- << FormatFileLocation(spec->file(), spec->line()) << "\n";
- }
- }
-
-
-
- void UntypedDescribeUninterestingCall(const void* untyped_args,
- ::std::ostream* os) const override
- GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {
- const ArgumentTuple& args =
- *static_cast<const ArgumentTuple*>(untyped_args);
- *os << "Uninteresting mock function call - ";
- DescribeDefaultActionTo(args, os);
- *os << " Function call: " << Name();
- UniversalPrint(args, os);
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- const ExpectationBase* UntypedFindMatchingExpectation(
- const void* untyped_args, const void** untyped_action, bool* is_excessive,
- ::std::ostream* what, ::std::ostream* why) override
- GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {
- const ArgumentTuple& args =
- *static_cast<const ArgumentTuple*>(untyped_args);
- MutexLock l(&g_gmock_mutex);
- TypedExpectation<F>* exp = this->FindMatchingExpectationLocked(args);
- if (exp == nullptr) {
- this->FormatUnexpectedCallMessageLocked(args, what, why);
- return nullptr;
- }
-
-
-
- *is_excessive = exp->IsSaturated();
- const Action<F>* action = exp->GetActionForArguments(this, args, what, why);
- if (action != nullptr && action->IsDoDefault())
- action = nullptr;
- *untyped_action = action;
- return exp;
- }
-
- void UntypedPrintArgs(const void* untyped_args,
- ::std::ostream* os) const override {
- const ArgumentTuple& args =
- *static_cast<const ArgumentTuple*>(untyped_args);
- UniversalPrint(args, os);
- }
-
-
- TypedExpectation<F>* FindMatchingExpectationLocked(
- const ArgumentTuple& args) const
- GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
- g_gmock_mutex.AssertHeld();
-
-
- for (typename UntypedExpectations::const_reverse_iterator it =
- untyped_expectations_.rbegin();
- it != untyped_expectations_.rend(); ++it) {
- TypedExpectation<F>* const exp =
- static_cast<TypedExpectation<F>*>(it->get());
- if (exp->ShouldHandleArguments(args)) {
- return exp;
- }
- }
- return nullptr;
- }
-
- void FormatUnexpectedCallMessageLocked(
- const ArgumentTuple& args,
- ::std::ostream* os,
- ::std::ostream* why) const
- GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
- g_gmock_mutex.AssertHeld();
- *os << "\nUnexpected mock function call - ";
- DescribeDefaultActionTo(args, os);
- PrintTriedExpectationsLocked(args, why);
- }
-
-
- void PrintTriedExpectationsLocked(
- const ArgumentTuple& args,
- ::std::ostream* why) const
- GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
- g_gmock_mutex.AssertHeld();
- const size_t count = untyped_expectations_.size();
- *why << "Google Mock tried the following " << count << " "
- << (count == 1 ? "expectation, but it didn't match" :
- "expectations, but none matched")
- << ":\n";
- for (size_t i = 0; i < count; i++) {
- TypedExpectation<F>* const expectation =
- static_cast<TypedExpectation<F>*>(untyped_expectations_[i].get());
- *why << "\n";
- expectation->DescribeLocationTo(why);
- if (count > 1) {
- *why << "tried expectation #" << i << ": ";
- }
- *why << expectation->source_text() << "...\n";
- expectation->ExplainMatchResultTo(args, why);
- expectation->DescribeCallCountTo(why);
- }
- }
- };
- void ReportUninterestingCall(CallReaction reaction, const std::string& msg);
- }
- namespace internal {
- template <typename F>
- class MockFunction;
- template <typename R, typename... Args>
- class MockFunction<R(Args...)> {
- public:
- MockFunction(const MockFunction&) = delete;
- MockFunction& operator=(const MockFunction&) = delete;
- std::function<R(Args...)> AsStdFunction() {
- return [this](Args... args) -> R {
- return this->Call(std::forward<Args>(args)...);
- };
- }
-
- R Call(Args... args) {
- mock_.SetOwnerAndName(this, "Call");
- return mock_.Invoke(std::forward<Args>(args)...);
- }
- MockSpec<R(Args...)> gmock_Call(Matcher<Args>... m) {
- mock_.RegisterOwner(this);
- return mock_.With(std::move(m)...);
- }
- MockSpec<R(Args...)> gmock_Call(const WithoutMatchers&, R (*)(Args...)) {
- return this->gmock_Call(::testing::A<Args>()...);
- }
- protected:
- MockFunction() = default;
- ~MockFunction() = default;
- private:
- FunctionMocker<R(Args...)> mock_;
- };
- template <typename F, typename = void>
- struct SignatureOf;
- template <typename R, typename... Args>
- struct SignatureOf<R(Args...)> {
- using type = R(Args...);
- };
- template <template <typename> class C, typename F>
- struct SignatureOf<C<F>,
- typename std::enable_if<std::is_function<F>::value>::type>
- : SignatureOf<F> {};
- template <typename F>
- using SignatureOfT = typename SignatureOf<F>::type;
- }
- template <typename F>
- class MockFunction : public internal::MockFunction<internal::SignatureOfT<F>> {
- using Base = internal::MockFunction<internal::SignatureOfT<F>>;
- public:
- using Base::Base;
- };
- using internal::MockSpec;
- template <typename T>
- inline const T& Const(const T& x) { return x; }
- inline Expectation::Expectation(internal::ExpectationBase& exp)
- : expectation_base_(exp.GetHandle().expectation_base()) {}
- }
- GTEST_DISABLE_MSC_WARNINGS_POP_()
- #define GMOCK_ON_CALL_IMPL_(mock_expr, Setter, call) \
- ((mock_expr).gmock_##call)(::testing::internal::GetWithoutMatchers(), \
- nullptr) \
- .Setter(__FILE__, __LINE__, #mock_expr, #call)
- #define ON_CALL(obj, call) \
- GMOCK_ON_CALL_IMPL_(obj, InternalDefaultActionSetAt, call)
- #define EXPECT_CALL(obj, call) \
- GMOCK_ON_CALL_IMPL_(obj, InternalExpectedAt, call)
- #endif
|