Add the last expectation's retirement in Sequence

This commit is contained in:
Hyuk Myeong 2020-03-12 00:24:23 +09:00
parent e588eb1ff9
commit 94374d3df4
2 changed files with 42 additions and 1 deletions

View File

@ -127,6 +127,7 @@ void ExpectationBase::RetireAllPreRequisites()
expectations.push_back(next);
}
}
retires_on_saturation_ = true;
}
}

View File

@ -1284,7 +1284,7 @@ TEST(InSequenceTest, NestedInSequence) {
a.DoA(3);
}
TEST(InSequenceTest, ExpectationsOutOfScopeAreNotAffected) {
TEST(InSequenceTest, ExpectationsOutOfScopeAreNotAffected1) {
MockA a;
{
InSequence dummy;
@ -1294,6 +1294,24 @@ TEST(InSequenceTest, ExpectationsOutOfScopeAreNotAffected) {
}
EXPECT_CALL(a, DoA(3));
EXPECT_NONFATAL_FAILURE({ // NOLINT
a.DoA(2);
}, "Unexpected mock function call");
a.DoA(3);
a.DoA(1);
a.DoA(2);
}
TEST(InSequenceTest, ExpectationsOutOfScopeAreNotAffected2) {
MockA a;
EXPECT_CALL(a, DoA(3));
{
InSequence dummy;
EXPECT_CALL(a, DoA(1));
EXPECT_CALL(a, DoA(2));
}
EXPECT_NONFATAL_FAILURE({ // NOLINT
a.DoA(2);
}, "Unexpected mock function call");
@ -1461,6 +1479,28 @@ TEST(SequenceTest, Retirement) {
a.DoA(1);
}
TEST(SequenceTest, RetirementLastExpectationInSequence) {
MockA a;
Sequence s;
EXPECT_CALL(a, DoA(_))
.Times(AnyNumber());
EXPECT_CALL(a, DoA(1))
.InSequence(s);
EXPECT_CALL(a, DoA(_))
.InSequence(s)
.RetiresOnSaturation();
EXPECT_CALL(a, DoA(1))
.InSequence(s);
a.DoA(1);
a.DoA(2);
a.DoA(1);
a.DoA(1);
a.DoA(2);
}
// Tests Expectation.
TEST(ExpectationTest, ConstrutorsWork) {