File indexing completed on 2025-08-06 08:19:54
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037 #include "gmock/gmock-spec-builders.h"
0038
0039 #include <stdlib.h>
0040 #include <iostream> // NOLINT
0041 #include <map>
0042 #include <set>
0043 #include <string>
0044 #include "gmock/gmock.h"
0045 #include "gtest/gtest.h"
0046
0047 #if GTEST_OS_CYGWIN || GTEST_OS_LINUX || GTEST_OS_MAC
0048 # include <unistd.h> // NOLINT
0049 #endif
0050
0051 namespace testing {
0052 namespace internal {
0053
0054
0055
0056 GTEST_API_ GTEST_DEFINE_STATIC_MUTEX_(g_gmock_mutex);
0057
0058
0059 GTEST_API_ void LogWithLocation(testing::internal::LogSeverity severity,
0060 const char* file, int line,
0061 const string& message) {
0062 ::std::ostringstream s;
0063 s << file << ":" << line << ": " << message << ::std::endl;
0064 Log(severity, s.str(), 0);
0065 }
0066
0067
0068 ExpectationBase::ExpectationBase(const char* a_file,
0069 int a_line,
0070 const string& a_source_text)
0071 : file_(a_file),
0072 line_(a_line),
0073 source_text_(a_source_text),
0074 cardinality_specified_(false),
0075 cardinality_(Exactly(1)),
0076 call_count_(0),
0077 retired_(false),
0078 extra_matcher_specified_(false),
0079 repeated_action_specified_(false),
0080 retires_on_saturation_(false),
0081 last_clause_(kNone),
0082 action_count_checked_(false) {}
0083
0084
0085 ExpectationBase::~ExpectationBase() {}
0086
0087
0088
0089 void ExpectationBase::SpecifyCardinality(const Cardinality& a_cardinality) {
0090 cardinality_specified_ = true;
0091 cardinality_ = a_cardinality;
0092 }
0093
0094
0095 void ExpectationBase::RetireAllPreRequisites()
0096 GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
0097 if (is_retired()) {
0098
0099
0100 return;
0101 }
0102
0103 for (ExpectationSet::const_iterator it = immediate_prerequisites_.begin();
0104 it != immediate_prerequisites_.end(); ++it) {
0105 ExpectationBase* const prerequisite = it->expectation_base().get();
0106 if (!prerequisite->is_retired()) {
0107 prerequisite->RetireAllPreRequisites();
0108 prerequisite->Retire();
0109 }
0110 }
0111 }
0112
0113
0114
0115 bool ExpectationBase::AllPrerequisitesAreSatisfied() const
0116 GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
0117 g_gmock_mutex.AssertHeld();
0118 for (ExpectationSet::const_iterator it = immediate_prerequisites_.begin();
0119 it != immediate_prerequisites_.end(); ++it) {
0120 if (!(it->expectation_base()->IsSatisfied()) ||
0121 !(it->expectation_base()->AllPrerequisitesAreSatisfied()))
0122 return false;
0123 }
0124 return true;
0125 }
0126
0127
0128 void ExpectationBase::FindUnsatisfiedPrerequisites(ExpectationSet* result) const
0129 GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
0130 g_gmock_mutex.AssertHeld();
0131 for (ExpectationSet::const_iterator it = immediate_prerequisites_.begin();
0132 it != immediate_prerequisites_.end(); ++it) {
0133 if (it->expectation_base()->IsSatisfied()) {
0134
0135
0136 if (it->expectation_base()->call_count_ == 0) {
0137 it->expectation_base()->FindUnsatisfiedPrerequisites(result);
0138 }
0139 } else {
0140
0141
0142
0143 *result += *it;
0144 }
0145 }
0146 }
0147
0148
0149
0150 void ExpectationBase::DescribeCallCountTo(::std::ostream* os) const
0151 GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
0152 g_gmock_mutex.AssertHeld();
0153
0154
0155 *os << " Expected: to be ";
0156 cardinality().DescribeTo(os);
0157 *os << "\n Actual: ";
0158 Cardinality::DescribeActualCallCountTo(call_count(), os);
0159
0160
0161
0162 *os << " - " << (IsOverSaturated() ? "over-saturated" :
0163 IsSaturated() ? "saturated" :
0164 IsSatisfied() ? "satisfied" : "unsatisfied")
0165 << " and "
0166 << (is_retired() ? "retired" : "active");
0167 }
0168
0169
0170
0171
0172
0173 void ExpectationBase::CheckActionCountIfNotDone() const
0174 GTEST_LOCK_EXCLUDED_(mutex_) {
0175 bool should_check = false;
0176 {
0177 MutexLock l(&mutex_);
0178 if (!action_count_checked_) {
0179 action_count_checked_ = true;
0180 should_check = true;
0181 }
0182 }
0183
0184 if (should_check) {
0185 if (!cardinality_specified_) {
0186
0187
0188 return;
0189 }
0190
0191
0192 const int action_count = static_cast<int>(untyped_actions_.size());
0193 const int upper_bound = cardinality().ConservativeUpperBound();
0194 const int lower_bound = cardinality().ConservativeLowerBound();
0195 bool too_many;
0196
0197 if (action_count > upper_bound ||
0198 (action_count == upper_bound && repeated_action_specified_)) {
0199 too_many = true;
0200 } else if (0 < action_count && action_count < lower_bound &&
0201 !repeated_action_specified_) {
0202 too_many = false;
0203 } else {
0204 return;
0205 }
0206
0207 ::std::stringstream ss;
0208 DescribeLocationTo(&ss);
0209 ss << "Too " << (too_many ? "many" : "few")
0210 << " actions specified in " << source_text() << "...\n"
0211 << "Expected to be ";
0212 cardinality().DescribeTo(&ss);
0213 ss << ", but has " << (too_many ? "" : "only ")
0214 << action_count << " WillOnce()"
0215 << (action_count == 1 ? "" : "s");
0216 if (repeated_action_specified_) {
0217 ss << " and a WillRepeatedly()";
0218 }
0219 ss << ".";
0220 Log(kWarning, ss.str(), -1);
0221 }
0222 }
0223
0224
0225 void ExpectationBase::UntypedTimes(const Cardinality& a_cardinality) {
0226 if (last_clause_ == kTimes) {
0227 ExpectSpecProperty(false,
0228 ".Times() cannot appear "
0229 "more than once in an EXPECT_CALL().");
0230 } else {
0231 ExpectSpecProperty(last_clause_ < kTimes,
0232 ".Times() cannot appear after "
0233 ".InSequence(), .WillOnce(), .WillRepeatedly(), "
0234 "or .RetiresOnSaturation().");
0235 }
0236 last_clause_ = kTimes;
0237
0238 SpecifyCardinality(a_cardinality);
0239 }
0240
0241
0242
0243 GTEST_API_ ThreadLocal<Sequence*> g_gmock_implicit_sequence;
0244
0245
0246
0247 void ReportUninterestingCall(CallReaction reaction, const string& msg) {
0248
0249 const int stack_frames_to_skip =
0250 GMOCK_FLAG(verbose) == kInfoVerbosity ? 3 : -1;
0251 switch (reaction) {
0252 case kAllow:
0253 Log(kInfo, msg, stack_frames_to_skip);
0254 break;
0255 case kWarn:
0256 Log(kWarning,
0257 msg +
0258 "\nNOTE: You can safely ignore the above warning unless this "
0259 "call should not happen. Do not suppress it by blindly adding "
0260 "an EXPECT_CALL() if you don't mean to enforce the call. "
0261 "See https://github.com/google/googletest/blob/master/googlemock/docs/CookBook.md#"
0262 "knowing-when-to-expect for details.\n",
0263 stack_frames_to_skip);
0264 break;
0265 default:
0266 Expect(false, NULL, -1, msg);
0267 }
0268 }
0269
0270 UntypedFunctionMockerBase::UntypedFunctionMockerBase()
0271 : mock_obj_(NULL), name_("") {}
0272
0273 UntypedFunctionMockerBase::~UntypedFunctionMockerBase() {}
0274
0275
0276
0277
0278
0279 void UntypedFunctionMockerBase::RegisterOwner(const void* mock_obj)
0280 GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {
0281 {
0282 MutexLock l(&g_gmock_mutex);
0283 mock_obj_ = mock_obj;
0284 }
0285 Mock::Register(mock_obj, this);
0286 }
0287
0288
0289
0290
0291 void UntypedFunctionMockerBase::SetOwnerAndName(const void* mock_obj,
0292 const char* name)
0293 GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {
0294
0295
0296 MutexLock l(&g_gmock_mutex);
0297 mock_obj_ = mock_obj;
0298 name_ = name;
0299 }
0300
0301
0302
0303 const void* UntypedFunctionMockerBase::MockObject() const
0304 GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {
0305 const void* mock_obj;
0306 {
0307
0308
0309 MutexLock l(&g_gmock_mutex);
0310 Assert(mock_obj_ != NULL, __FILE__, __LINE__,
0311 "MockObject() must not be called before RegisterOwner() or "
0312 "SetOwnerAndName() has been called.");
0313 mock_obj = mock_obj_;
0314 }
0315 return mock_obj;
0316 }
0317
0318
0319
0320 const char* UntypedFunctionMockerBase::Name() const
0321 GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {
0322 const char* name;
0323 {
0324
0325
0326 MutexLock l(&g_gmock_mutex);
0327 Assert(name_ != NULL, __FILE__, __LINE__,
0328 "Name() must not be called before SetOwnerAndName() has "
0329 "been called.");
0330 name = name_;
0331 }
0332 return name;
0333 }
0334
0335
0336
0337
0338 UntypedActionResultHolderBase*
0339 UntypedFunctionMockerBase::UntypedInvokeWith(const void* const untyped_args)
0340 GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {
0341 if (untyped_expectations_.size() == 0) {
0342
0343
0344
0345
0346
0347
0348
0349 const CallReaction reaction =
0350 Mock::GetReactionOnUninterestingCalls(MockObject());
0351
0352
0353
0354
0355 const bool need_to_report_uninteresting_call =
0356
0357
0358 reaction == kAllow ? LogIsVisible(kInfo) :
0359
0360
0361 reaction == kWarn ? LogIsVisible(kWarning) :
0362
0363
0364 true;
0365
0366 if (!need_to_report_uninteresting_call) {
0367
0368 return this->UntypedPerformDefaultAction(untyped_args, "");
0369 }
0370
0371
0372 ::std::stringstream ss;
0373 this->UntypedDescribeUninterestingCall(untyped_args, &ss);
0374
0375
0376 UntypedActionResultHolderBase* const result =
0377 this->UntypedPerformDefaultAction(untyped_args, ss.str());
0378
0379
0380 if (result != NULL)
0381 result->PrintAsActionResult(&ss);
0382
0383 ReportUninterestingCall(reaction, ss.str());
0384 return result;
0385 }
0386
0387 bool is_excessive = false;
0388 ::std::stringstream ss;
0389 ::std::stringstream why;
0390 ::std::stringstream loc;
0391 const void* untyped_action = NULL;
0392
0393
0394
0395 const ExpectationBase* const untyped_expectation =
0396 this->UntypedFindMatchingExpectation(
0397 untyped_args, &untyped_action, &is_excessive,
0398 &ss, &why);
0399 const bool found = untyped_expectation != NULL;
0400
0401
0402
0403
0404 const bool need_to_report_call =
0405 !found || is_excessive || LogIsVisible(kInfo);
0406 if (!need_to_report_call) {
0407
0408 return
0409 untyped_action == NULL ?
0410 this->UntypedPerformDefaultAction(untyped_args, "") :
0411 this->UntypedPerformAction(untyped_action, untyped_args);
0412 }
0413
0414 ss << " Function call: " << Name();
0415 this->UntypedPrintArgs(untyped_args, &ss);
0416
0417
0418
0419 if (found && !is_excessive) {
0420 untyped_expectation->DescribeLocationTo(&loc);
0421 }
0422
0423 UntypedActionResultHolderBase* const result =
0424 untyped_action == NULL ?
0425 this->UntypedPerformDefaultAction(untyped_args, ss.str()) :
0426 this->UntypedPerformAction(untyped_action, untyped_args);
0427 if (result != NULL)
0428 result->PrintAsActionResult(&ss);
0429 ss << "\n" << why.str();
0430
0431 if (!found) {
0432
0433 Expect(false, NULL, -1, ss.str());
0434 } else if (is_excessive) {
0435
0436 Expect(false, untyped_expectation->file(),
0437 untyped_expectation->line(), ss.str());
0438 } else {
0439
0440
0441 Log(kInfo, loc.str() + ss.str(), 2);
0442 }
0443
0444 return result;
0445 }
0446
0447
0448
0449 Expectation UntypedFunctionMockerBase::GetHandleOf(ExpectationBase* exp) {
0450 for (UntypedExpectations::const_iterator it =
0451 untyped_expectations_.begin();
0452 it != untyped_expectations_.end(); ++it) {
0453 if (it->get() == exp) {
0454 return Expectation(*it);
0455 }
0456 }
0457
0458 Assert(false, __FILE__, __LINE__, "Cannot find expectation.");
0459 return Expectation();
0460
0461
0462 }
0463
0464
0465
0466
0467 bool UntypedFunctionMockerBase::VerifyAndClearExpectationsLocked()
0468 GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
0469 g_gmock_mutex.AssertHeld();
0470 bool expectations_met = true;
0471 for (UntypedExpectations::const_iterator it =
0472 untyped_expectations_.begin();
0473 it != untyped_expectations_.end(); ++it) {
0474 ExpectationBase* const untyped_expectation = it->get();
0475 if (untyped_expectation->IsOverSaturated()) {
0476
0477
0478
0479 expectations_met = false;
0480 } else if (!untyped_expectation->IsSatisfied()) {
0481 expectations_met = false;
0482 ::std::stringstream ss;
0483 ss << "Actual function call count doesn't match "
0484 << untyped_expectation->source_text() << "...\n";
0485
0486
0487
0488 untyped_expectation->MaybeDescribeExtraMatcherTo(&ss);
0489 untyped_expectation->DescribeCallCountTo(&ss);
0490 Expect(false, untyped_expectation->file(),
0491 untyped_expectation->line(), ss.str());
0492 }
0493 }
0494
0495
0496
0497
0498
0499
0500
0501
0502 UntypedExpectations expectations_to_delete;
0503 untyped_expectations_.swap(expectations_to_delete);
0504
0505 g_gmock_mutex.Unlock();
0506 expectations_to_delete.clear();
0507 g_gmock_mutex.Lock();
0508
0509 return expectations_met;
0510 }
0511
0512 }
0513
0514
0515
0516 namespace {
0517
0518 typedef std::set<internal::UntypedFunctionMockerBase*> FunctionMockers;
0519
0520
0521
0522
0523 struct MockObjectState {
0524 MockObjectState()
0525 : first_used_file(NULL), first_used_line(-1), leakable(false) {}
0526
0527
0528
0529 const char* first_used_file;
0530 int first_used_line;
0531 ::std::string first_used_test_case;
0532 ::std::string first_used_test;
0533 bool leakable;
0534 FunctionMockers function_mockers;
0535 };
0536
0537
0538
0539
0540
0541 class MockObjectRegistry {
0542 public:
0543
0544 typedef std::map<const void*, MockObjectState> StateMap;
0545
0546
0547
0548
0549
0550 ~MockObjectRegistry() {
0551
0552
0553
0554 if (!GMOCK_FLAG(catch_leaked_mocks))
0555 return;
0556
0557 int leaked_count = 0;
0558 for (StateMap::const_iterator it = states_.begin(); it != states_.end();
0559 ++it) {
0560 if (it->second.leakable)
0561 continue;
0562
0563
0564
0565 std::cout << "\n";
0566 const MockObjectState& state = it->second;
0567 std::cout << internal::FormatFileLocation(state.first_used_file,
0568 state.first_used_line);
0569 std::cout << " ERROR: this mock object";
0570 if (state.first_used_test != "") {
0571 std::cout << " (used in test " << state.first_used_test_case << "."
0572 << state.first_used_test << ")";
0573 }
0574 std::cout << " should be deleted but never is. Its address is @"
0575 << it->first << ".";
0576 leaked_count++;
0577 }
0578 if (leaked_count > 0) {
0579 std::cout << "\nERROR: " << leaked_count
0580 << " leaked mock " << (leaked_count == 1 ? "object" : "objects")
0581 << " found at program exit.\n";
0582 std::cout.flush();
0583 ::std::cerr.flush();
0584
0585
0586
0587 _exit(1);
0588
0589 }
0590 }
0591
0592 StateMap& states() { return states_; }
0593
0594 private:
0595 StateMap states_;
0596 };
0597
0598
0599 MockObjectRegistry g_mock_object_registry;
0600
0601
0602
0603 std::map<const void*, internal::CallReaction> g_uninteresting_call_reaction;
0604
0605
0606
0607 void SetReactionOnUninterestingCalls(const void* mock_obj,
0608 internal::CallReaction reaction)
0609 GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) {
0610 internal::MutexLock l(&internal::g_gmock_mutex);
0611 g_uninteresting_call_reaction[mock_obj] = reaction;
0612 }
0613
0614 }
0615
0616
0617
0618 void Mock::AllowUninterestingCalls(const void* mock_obj)
0619 GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) {
0620 SetReactionOnUninterestingCalls(mock_obj, internal::kAllow);
0621 }
0622
0623
0624
0625 void Mock::WarnUninterestingCalls(const void* mock_obj)
0626 GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) {
0627 SetReactionOnUninterestingCalls(mock_obj, internal::kWarn);
0628 }
0629
0630
0631
0632 void Mock::FailUninterestingCalls(const void* mock_obj)
0633 GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) {
0634 SetReactionOnUninterestingCalls(mock_obj, internal::kFail);
0635 }
0636
0637
0638
0639 void Mock::UnregisterCallReaction(const void* mock_obj)
0640 GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) {
0641 internal::MutexLock l(&internal::g_gmock_mutex);
0642 g_uninteresting_call_reaction.erase(mock_obj);
0643 }
0644
0645
0646
0647 internal::CallReaction Mock::GetReactionOnUninterestingCalls(
0648 const void* mock_obj)
0649 GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) {
0650 internal::MutexLock l(&internal::g_gmock_mutex);
0651 return (g_uninteresting_call_reaction.count(mock_obj) == 0) ?
0652 internal::kDefault : g_uninteresting_call_reaction[mock_obj];
0653 }
0654
0655
0656
0657 void Mock::AllowLeak(const void* mock_obj)
0658 GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) {
0659 internal::MutexLock l(&internal::g_gmock_mutex);
0660 g_mock_object_registry.states()[mock_obj].leakable = true;
0661 }
0662
0663
0664
0665
0666 bool Mock::VerifyAndClearExpectations(void* mock_obj)
0667 GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) {
0668 internal::MutexLock l(&internal::g_gmock_mutex);
0669 return VerifyAndClearExpectationsLocked(mock_obj);
0670 }
0671
0672
0673
0674
0675 bool Mock::VerifyAndClear(void* mock_obj)
0676 GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) {
0677 internal::MutexLock l(&internal::g_gmock_mutex);
0678 ClearDefaultActionsLocked(mock_obj);
0679 return VerifyAndClearExpectationsLocked(mock_obj);
0680 }
0681
0682
0683
0684
0685 bool Mock::VerifyAndClearExpectationsLocked(void* mock_obj)
0686 GTEST_EXCLUSIVE_LOCK_REQUIRED_(internal::g_gmock_mutex) {
0687 internal::g_gmock_mutex.AssertHeld();
0688 if (g_mock_object_registry.states().count(mock_obj) == 0) {
0689
0690 return true;
0691 }
0692
0693
0694
0695 bool expectations_met = true;
0696 FunctionMockers& mockers =
0697 g_mock_object_registry.states()[mock_obj].function_mockers;
0698 for (FunctionMockers::const_iterator it = mockers.begin();
0699 it != mockers.end(); ++it) {
0700 if (!(*it)->VerifyAndClearExpectationsLocked()) {
0701 expectations_met = false;
0702 }
0703 }
0704
0705
0706
0707 return expectations_met;
0708 }
0709
0710
0711 void Mock::Register(const void* mock_obj,
0712 internal::UntypedFunctionMockerBase* mocker)
0713 GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) {
0714 internal::MutexLock l(&internal::g_gmock_mutex);
0715 g_mock_object_registry.states()[mock_obj].function_mockers.insert(mocker);
0716 }
0717
0718
0719
0720
0721 void Mock::RegisterUseByOnCallOrExpectCall(const void* mock_obj,
0722 const char* file, int line)
0723 GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) {
0724 internal::MutexLock l(&internal::g_gmock_mutex);
0725 MockObjectState& state = g_mock_object_registry.states()[mock_obj];
0726 if (state.first_used_file == NULL) {
0727 state.first_used_file = file;
0728 state.first_used_line = line;
0729 const TestInfo* const test_info =
0730 UnitTest::GetInstance()->current_test_info();
0731 if (test_info != NULL) {
0732
0733
0734
0735 state.first_used_test_case = test_info->test_case_name();
0736 state.first_used_test = test_info->name();
0737 }
0738 }
0739 }
0740
0741
0742
0743
0744
0745 void Mock::UnregisterLocked(internal::UntypedFunctionMockerBase* mocker)
0746 GTEST_EXCLUSIVE_LOCK_REQUIRED_(internal::g_gmock_mutex) {
0747 internal::g_gmock_mutex.AssertHeld();
0748 for (MockObjectRegistry::StateMap::iterator it =
0749 g_mock_object_registry.states().begin();
0750 it != g_mock_object_registry.states().end(); ++it) {
0751 FunctionMockers& mockers = it->second.function_mockers;
0752 if (mockers.erase(mocker) > 0) {
0753
0754 if (mockers.empty()) {
0755 g_mock_object_registry.states().erase(it);
0756 }
0757 return;
0758 }
0759 }
0760 }
0761
0762
0763 void Mock::ClearDefaultActionsLocked(void* mock_obj)
0764 GTEST_EXCLUSIVE_LOCK_REQUIRED_(internal::g_gmock_mutex) {
0765 internal::g_gmock_mutex.AssertHeld();
0766
0767 if (g_mock_object_registry.states().count(mock_obj) == 0) {
0768
0769 return;
0770 }
0771
0772
0773
0774 FunctionMockers& mockers =
0775 g_mock_object_registry.states()[mock_obj].function_mockers;
0776 for (FunctionMockers::const_iterator it = mockers.begin();
0777 it != mockers.end(); ++it) {
0778 (*it)->ClearDefaultActionsLocked();
0779 }
0780
0781
0782
0783 }
0784
0785 Expectation::Expectation() {}
0786
0787 Expectation::Expectation(
0788 const internal::linked_ptr<internal::ExpectationBase>& an_expectation_base)
0789 : expectation_base_(an_expectation_base) {}
0790
0791 Expectation::~Expectation() {}
0792
0793
0794 void Sequence::AddExpectation(const Expectation& expectation) const {
0795 if (*last_expectation_ != expectation) {
0796 if (last_expectation_->expectation_base() != NULL) {
0797 expectation.expectation_base()->immediate_prerequisites_
0798 += *last_expectation_;
0799 }
0800 *last_expectation_ = expectation;
0801 }
0802 }
0803
0804
0805 InSequence::InSequence() {
0806 if (internal::g_gmock_implicit_sequence.get() == NULL) {
0807 internal::g_gmock_implicit_sequence.set(new Sequence);
0808 sequence_created_ = true;
0809 } else {
0810 sequence_created_ = false;
0811 }
0812 }
0813
0814
0815
0816 InSequence::~InSequence() {
0817 if (sequence_created_) {
0818 delete internal::g_gmock_implicit_sequence.get();
0819 internal::g_gmock_implicit_sequence.set(NULL);
0820 }
0821 }
0822
0823 }