gmock-cardinalities_test.cc (googletest-release-1.11.0) | : | gmock-cardinalities_test.cc (googletest-release-1.12.0) | ||
---|---|---|---|---|
skipping to change at line 35 | skipping to change at line 35 | |||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
// Google Mock - a framework for writing C++ mock classes. | // Google Mock - a framework for writing C++ mock classes. | |||
// | // | |||
// This file tests the built-in cardinalities. | // This file tests the built-in cardinalities. | |||
#include "gmock/gmock.h" | #include "gmock/gmock.h" | |||
#include "gtest/gtest.h" | ||||
#include "gtest/gtest-spi.h" | #include "gtest/gtest-spi.h" | |||
#include "gtest/gtest.h" | ||||
namespace { | namespace { | |||
using std::stringstream; | using std::stringstream; | |||
using testing::AnyNumber; | using testing::AnyNumber; | |||
using testing::AtLeast; | using testing::AtLeast; | |||
using testing::AtMost; | using testing::AtMost; | |||
using testing::Between; | using testing::Between; | |||
using testing::Cardinality; | using testing::Cardinality; | |||
using testing::CardinalityInterface; | using testing::CardinalityInterface; | |||
using testing::Exactly; | using testing::Exactly; | |||
using testing::IsSubstring; | using testing::IsSubstring; | |||
using testing::MakeCardinality; | using testing::MakeCardinality; | |||
class MockFoo { | class MockFoo { | |||
public: | public: | |||
MockFoo() {} | MockFoo() {} | |||
MOCK_METHOD0(Bar, int()); // NOLINT | MOCK_METHOD0(Bar, int()); // NOLINT | |||
private: | private: | |||
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFoo); | MockFoo(const MockFoo&) = delete; | |||
MockFoo& operator=(const MockFoo&) = delete; | ||||
}; | }; | |||
// Tests that Cardinality objects can be default constructed. | // Tests that Cardinality objects can be default constructed. | |||
TEST(CardinalityTest, IsDefaultConstructable) { | TEST(CardinalityTest, IsDefaultConstructable) { Cardinality c; } | |||
Cardinality c; | ||||
} | ||||
// Tests that Cardinality objects are copyable. | // Tests that Cardinality objects are copyable. | |||
TEST(CardinalityTest, IsCopyable) { | TEST(CardinalityTest, IsCopyable) { | |||
// Tests the copy constructor. | // Tests the copy constructor. | |||
Cardinality c = Exactly(1); | Cardinality c = Exactly(1); | |||
EXPECT_FALSE(c.IsSatisfiedByCallCount(0)); | EXPECT_FALSE(c.IsSatisfiedByCallCount(0)); | |||
EXPECT_TRUE(c.IsSatisfiedByCallCount(1)); | EXPECT_TRUE(c.IsSatisfiedByCallCount(1)); | |||
EXPECT_TRUE(c.IsSaturatedByCallCount(1)); | EXPECT_TRUE(c.IsSaturatedByCallCount(1)); | |||
// Tests the assignment operator. | // Tests the assignment operator. | |||
skipping to change at line 121 | skipping to change at line 120 | |||
EXPECT_FALSE(c.IsSaturatedByCallCount(0)); | EXPECT_FALSE(c.IsSaturatedByCallCount(0)); | |||
EXPECT_TRUE(c.IsSatisfiedByCallCount(1)); | EXPECT_TRUE(c.IsSatisfiedByCallCount(1)); | |||
EXPECT_FALSE(c.IsSaturatedByCallCount(1)); | EXPECT_FALSE(c.IsSaturatedByCallCount(1)); | |||
EXPECT_TRUE(c.IsSatisfiedByCallCount(9)); | EXPECT_TRUE(c.IsSatisfiedByCallCount(9)); | |||
EXPECT_FALSE(c.IsSaturatedByCallCount(9)); | EXPECT_FALSE(c.IsSaturatedByCallCount(9)); | |||
stringstream ss; | stringstream ss; | |||
c.DescribeTo(&ss); | c.DescribeTo(&ss); | |||
EXPECT_PRED_FORMAT2(IsSubstring, "called any number of times", | EXPECT_PRED_FORMAT2(IsSubstring, "called any number of times", ss.str()); | |||
ss.str()); | ||||
} | } | |||
TEST(AnyNumberTest, HasCorrectBounds) { | TEST(AnyNumberTest, HasCorrectBounds) { | |||
const Cardinality c = AnyNumber(); | const Cardinality c = AnyNumber(); | |||
EXPECT_EQ(0, c.ConservativeLowerBound()); | EXPECT_EQ(0, c.ConservativeLowerBound()); | |||
EXPECT_EQ(INT_MAX, c.ConservativeUpperBound()); | EXPECT_EQ(INT_MAX, c.ConservativeUpperBound()); | |||
} | } | |||
// Tests AtLeast(n). | // Tests AtLeast(n). | |||
TEST(AtLeastTest, OnNegativeNumber) { | TEST(AtLeastTest, OnNegativeNumber) { | |||
EXPECT_NONFATAL_FAILURE({ // NOLINT | EXPECT_NONFATAL_FAILURE( | |||
AtLeast(-1); | { // NOLINT | |||
}, "The invocation lower bound must be >= 0"); | AtLeast(-1); | |||
}, | ||||
"The invocation lower bound must be >= 0"); | ||||
} | } | |||
TEST(AtLeastTest, OnZero) { | TEST(AtLeastTest, OnZero) { | |||
const Cardinality c = AtLeast(0); | const Cardinality c = AtLeast(0); | |||
EXPECT_TRUE(c.IsSatisfiedByCallCount(0)); | EXPECT_TRUE(c.IsSatisfiedByCallCount(0)); | |||
EXPECT_FALSE(c.IsSaturatedByCallCount(0)); | EXPECT_FALSE(c.IsSaturatedByCallCount(0)); | |||
EXPECT_TRUE(c.IsSatisfiedByCallCount(1)); | EXPECT_TRUE(c.IsSatisfiedByCallCount(1)); | |||
EXPECT_FALSE(c.IsSaturatedByCallCount(1)); | EXPECT_FALSE(c.IsSaturatedByCallCount(1)); | |||
stringstream ss; | stringstream ss; | |||
c.DescribeTo(&ss); | c.DescribeTo(&ss); | |||
EXPECT_PRED_FORMAT2(IsSubstring, "any number of times", | EXPECT_PRED_FORMAT2(IsSubstring, "any number of times", ss.str()); | |||
ss.str()); | ||||
} | } | |||
TEST(AtLeastTest, OnPositiveNumber) { | TEST(AtLeastTest, OnPositiveNumber) { | |||
const Cardinality c = AtLeast(2); | const Cardinality c = AtLeast(2); | |||
EXPECT_FALSE(c.IsSatisfiedByCallCount(0)); | EXPECT_FALSE(c.IsSatisfiedByCallCount(0)); | |||
EXPECT_FALSE(c.IsSaturatedByCallCount(0)); | EXPECT_FALSE(c.IsSaturatedByCallCount(0)); | |||
EXPECT_FALSE(c.IsSatisfiedByCallCount(1)); | EXPECT_FALSE(c.IsSatisfiedByCallCount(1)); | |||
EXPECT_FALSE(c.IsSaturatedByCallCount(1)); | EXPECT_FALSE(c.IsSaturatedByCallCount(1)); | |||
EXPECT_TRUE(c.IsSatisfiedByCallCount(2)); | EXPECT_TRUE(c.IsSatisfiedByCallCount(2)); | |||
EXPECT_FALSE(c.IsSaturatedByCallCount(2)); | EXPECT_FALSE(c.IsSaturatedByCallCount(2)); | |||
stringstream ss1; | stringstream ss1; | |||
AtLeast(1).DescribeTo(&ss1); | AtLeast(1).DescribeTo(&ss1); | |||
EXPECT_PRED_FORMAT2(IsSubstring, "at least once", | EXPECT_PRED_FORMAT2(IsSubstring, "at least once", ss1.str()); | |||
ss1.str()); | ||||
stringstream ss2; | stringstream ss2; | |||
c.DescribeTo(&ss2); | c.DescribeTo(&ss2); | |||
EXPECT_PRED_FORMAT2(IsSubstring, "at least twice", | EXPECT_PRED_FORMAT2(IsSubstring, "at least twice", ss2.str()); | |||
ss2.str()); | ||||
stringstream ss3; | stringstream ss3; | |||
AtLeast(3).DescribeTo(&ss3); | AtLeast(3).DescribeTo(&ss3); | |||
EXPECT_PRED_FORMAT2(IsSubstring, "at least 3 times", | EXPECT_PRED_FORMAT2(IsSubstring, "at least 3 times", ss3.str()); | |||
ss3.str()); | ||||
} | } | |||
TEST(AtLeastTest, HasCorrectBounds) { | TEST(AtLeastTest, HasCorrectBounds) { | |||
const Cardinality c = AtLeast(2); | const Cardinality c = AtLeast(2); | |||
EXPECT_EQ(2, c.ConservativeLowerBound()); | EXPECT_EQ(2, c.ConservativeLowerBound()); | |||
EXPECT_EQ(INT_MAX, c.ConservativeUpperBound()); | EXPECT_EQ(INT_MAX, c.ConservativeUpperBound()); | |||
} | } | |||
// Tests AtMost(n). | // Tests AtMost(n). | |||
TEST(AtMostTest, OnNegativeNumber) { | TEST(AtMostTest, OnNegativeNumber) { | |||
EXPECT_NONFATAL_FAILURE({ // NOLINT | EXPECT_NONFATAL_FAILURE( | |||
AtMost(-1); | { // NOLINT | |||
}, "The invocation upper bound must be >= 0"); | AtMost(-1); | |||
}, | ||||
"The invocation upper bound must be >= 0"); | ||||
} | } | |||
TEST(AtMostTest, OnZero) { | TEST(AtMostTest, OnZero) { | |||
const Cardinality c = AtMost(0); | const Cardinality c = AtMost(0); | |||
EXPECT_TRUE(c.IsSatisfiedByCallCount(0)); | EXPECT_TRUE(c.IsSatisfiedByCallCount(0)); | |||
EXPECT_TRUE(c.IsSaturatedByCallCount(0)); | EXPECT_TRUE(c.IsSaturatedByCallCount(0)); | |||
EXPECT_FALSE(c.IsSatisfiedByCallCount(1)); | EXPECT_FALSE(c.IsSatisfiedByCallCount(1)); | |||
EXPECT_TRUE(c.IsSaturatedByCallCount(1)); | EXPECT_TRUE(c.IsSaturatedByCallCount(1)); | |||
stringstream ss; | stringstream ss; | |||
c.DescribeTo(&ss); | c.DescribeTo(&ss); | |||
EXPECT_PRED_FORMAT2(IsSubstring, "never called", | EXPECT_PRED_FORMAT2(IsSubstring, "never called", ss.str()); | |||
ss.str()); | ||||
} | } | |||
TEST(AtMostTest, OnPositiveNumber) { | TEST(AtMostTest, OnPositiveNumber) { | |||
const Cardinality c = AtMost(2); | const Cardinality c = AtMost(2); | |||
EXPECT_TRUE(c.IsSatisfiedByCallCount(0)); | EXPECT_TRUE(c.IsSatisfiedByCallCount(0)); | |||
EXPECT_FALSE(c.IsSaturatedByCallCount(0)); | EXPECT_FALSE(c.IsSaturatedByCallCount(0)); | |||
EXPECT_TRUE(c.IsSatisfiedByCallCount(1)); | EXPECT_TRUE(c.IsSatisfiedByCallCount(1)); | |||
EXPECT_FALSE(c.IsSaturatedByCallCount(1)); | EXPECT_FALSE(c.IsSaturatedByCallCount(1)); | |||
EXPECT_TRUE(c.IsSatisfiedByCallCount(2)); | EXPECT_TRUE(c.IsSatisfiedByCallCount(2)); | |||
EXPECT_TRUE(c.IsSaturatedByCallCount(2)); | EXPECT_TRUE(c.IsSaturatedByCallCount(2)); | |||
stringstream ss1; | stringstream ss1; | |||
AtMost(1).DescribeTo(&ss1); | AtMost(1).DescribeTo(&ss1); | |||
EXPECT_PRED_FORMAT2(IsSubstring, "called at most once", | EXPECT_PRED_FORMAT2(IsSubstring, "called at most once", ss1.str()); | |||
ss1.str()); | ||||
stringstream ss2; | stringstream ss2; | |||
c.DescribeTo(&ss2); | c.DescribeTo(&ss2); | |||
EXPECT_PRED_FORMAT2(IsSubstring, "called at most twice", | EXPECT_PRED_FORMAT2(IsSubstring, "called at most twice", ss2.str()); | |||
ss2.str()); | ||||
stringstream ss3; | stringstream ss3; | |||
AtMost(3).DescribeTo(&ss3); | AtMost(3).DescribeTo(&ss3); | |||
EXPECT_PRED_FORMAT2(IsSubstring, "called at most 3 times", | EXPECT_PRED_FORMAT2(IsSubstring, "called at most 3 times", ss3.str()); | |||
ss3.str()); | ||||
} | } | |||
TEST(AtMostTest, HasCorrectBounds) { | TEST(AtMostTest, HasCorrectBounds) { | |||
const Cardinality c = AtMost(2); | const Cardinality c = AtMost(2); | |||
EXPECT_EQ(0, c.ConservativeLowerBound()); | EXPECT_EQ(0, c.ConservativeLowerBound()); | |||
EXPECT_EQ(2, c.ConservativeUpperBound()); | EXPECT_EQ(2, c.ConservativeUpperBound()); | |||
} | } | |||
// Tests Between(m, n). | // Tests Between(m, n). | |||
TEST(BetweenTest, OnNegativeStart) { | TEST(BetweenTest, OnNegativeStart) { | |||
EXPECT_NONFATAL_FAILURE({ // NOLINT | EXPECT_NONFATAL_FAILURE( | |||
Between(-1, 2); | { // NOLINT | |||
}, "The invocation lower bound must be >= 0, but is actually -1"); | Between(-1, 2); | |||
}, | ||||
"The invocation lower bound must be >= 0, but is actually -1"); | ||||
} | } | |||
TEST(BetweenTest, OnNegativeEnd) { | TEST(BetweenTest, OnNegativeEnd) { | |||
EXPECT_NONFATAL_FAILURE({ // NOLINT | EXPECT_NONFATAL_FAILURE( | |||
Between(1, -2); | { // NOLINT | |||
}, "The invocation upper bound must be >= 0, but is actually -2"); | Between(1, -2); | |||
}, | ||||
"The invocation upper bound must be >= 0, but is actually -2"); | ||||
} | } | |||
TEST(BetweenTest, OnStartBiggerThanEnd) { | TEST(BetweenTest, OnStartBiggerThanEnd) { | |||
EXPECT_NONFATAL_FAILURE({ // NOLINT | EXPECT_NONFATAL_FAILURE( | |||
Between(2, 1); | { // NOLINT | |||
}, "The invocation upper bound (1) must be >= " | Between(2, 1); | |||
"the invocation lower bound (2)"); | }, | |||
"The invocation upper bound (1) must be >= " | ||||
"the invocation lower bound (2)"); | ||||
} | } | |||
TEST(BetweenTest, OnZeroStartAndZeroEnd) { | TEST(BetweenTest, OnZeroStartAndZeroEnd) { | |||
const Cardinality c = Between(0, 0); | const Cardinality c = Between(0, 0); | |||
EXPECT_TRUE(c.IsSatisfiedByCallCount(0)); | EXPECT_TRUE(c.IsSatisfiedByCallCount(0)); | |||
EXPECT_TRUE(c.IsSaturatedByCallCount(0)); | EXPECT_TRUE(c.IsSaturatedByCallCount(0)); | |||
EXPECT_FALSE(c.IsSatisfiedByCallCount(1)); | EXPECT_FALSE(c.IsSatisfiedByCallCount(1)); | |||
EXPECT_TRUE(c.IsSaturatedByCallCount(1)); | EXPECT_TRUE(c.IsSaturatedByCallCount(1)); | |||
stringstream ss; | stringstream ss; | |||
c.DescribeTo(&ss); | c.DescribeTo(&ss); | |||
EXPECT_PRED_FORMAT2(IsSubstring, "never called", | EXPECT_PRED_FORMAT2(IsSubstring, "never called", ss.str()); | |||
ss.str()); | ||||
} | } | |||
TEST(BetweenTest, OnZeroStartAndNonZeroEnd) { | TEST(BetweenTest, OnZeroStartAndNonZeroEnd) { | |||
const Cardinality c = Between(0, 2); | const Cardinality c = Between(0, 2); | |||
EXPECT_TRUE(c.IsSatisfiedByCallCount(0)); | EXPECT_TRUE(c.IsSatisfiedByCallCount(0)); | |||
EXPECT_FALSE(c.IsSaturatedByCallCount(0)); | EXPECT_FALSE(c.IsSaturatedByCallCount(0)); | |||
EXPECT_TRUE(c.IsSatisfiedByCallCount(2)); | EXPECT_TRUE(c.IsSatisfiedByCallCount(2)); | |||
EXPECT_TRUE(c.IsSaturatedByCallCount(2)); | EXPECT_TRUE(c.IsSaturatedByCallCount(2)); | |||
EXPECT_FALSE(c.IsSatisfiedByCallCount(4)); | EXPECT_FALSE(c.IsSatisfiedByCallCount(4)); | |||
EXPECT_TRUE(c.IsSaturatedByCallCount(4)); | EXPECT_TRUE(c.IsSaturatedByCallCount(4)); | |||
stringstream ss; | stringstream ss; | |||
c.DescribeTo(&ss); | c.DescribeTo(&ss); | |||
EXPECT_PRED_FORMAT2(IsSubstring, "called at most twice", | EXPECT_PRED_FORMAT2(IsSubstring, "called at most twice", ss.str()); | |||
ss.str()); | ||||
} | } | |||
TEST(BetweenTest, OnSameStartAndEnd) { | TEST(BetweenTest, OnSameStartAndEnd) { | |||
const Cardinality c = Between(3, 3); | const Cardinality c = Between(3, 3); | |||
EXPECT_FALSE(c.IsSatisfiedByCallCount(2)); | EXPECT_FALSE(c.IsSatisfiedByCallCount(2)); | |||
EXPECT_FALSE(c.IsSaturatedByCallCount(2)); | EXPECT_FALSE(c.IsSaturatedByCallCount(2)); | |||
EXPECT_TRUE(c.IsSatisfiedByCallCount(3)); | EXPECT_TRUE(c.IsSatisfiedByCallCount(3)); | |||
EXPECT_TRUE(c.IsSaturatedByCallCount(3)); | EXPECT_TRUE(c.IsSaturatedByCallCount(3)); | |||
EXPECT_FALSE(c.IsSatisfiedByCallCount(4)); | EXPECT_FALSE(c.IsSatisfiedByCallCount(4)); | |||
EXPECT_TRUE(c.IsSaturatedByCallCount(4)); | EXPECT_TRUE(c.IsSaturatedByCallCount(4)); | |||
stringstream ss; | stringstream ss; | |||
c.DescribeTo(&ss); | c.DescribeTo(&ss); | |||
EXPECT_PRED_FORMAT2(IsSubstring, "called 3 times", | EXPECT_PRED_FORMAT2(IsSubstring, "called 3 times", ss.str()); | |||
ss.str()); | ||||
} | } | |||
TEST(BetweenTest, OnDifferentStartAndEnd) { | TEST(BetweenTest, OnDifferentStartAndEnd) { | |||
const Cardinality c = Between(3, 5); | const Cardinality c = Between(3, 5); | |||
EXPECT_FALSE(c.IsSatisfiedByCallCount(2)); | EXPECT_FALSE(c.IsSatisfiedByCallCount(2)); | |||
EXPECT_FALSE(c.IsSaturatedByCallCount(2)); | EXPECT_FALSE(c.IsSaturatedByCallCount(2)); | |||
EXPECT_TRUE(c.IsSatisfiedByCallCount(3)); | EXPECT_TRUE(c.IsSatisfiedByCallCount(3)); | |||
EXPECT_FALSE(c.IsSaturatedByCallCount(3)); | EXPECT_FALSE(c.IsSaturatedByCallCount(3)); | |||
EXPECT_TRUE(c.IsSatisfiedByCallCount(5)); | EXPECT_TRUE(c.IsSatisfiedByCallCount(5)); | |||
EXPECT_TRUE(c.IsSaturatedByCallCount(5)); | EXPECT_TRUE(c.IsSaturatedByCallCount(5)); | |||
EXPECT_FALSE(c.IsSatisfiedByCallCount(6)); | EXPECT_FALSE(c.IsSatisfiedByCallCount(6)); | |||
EXPECT_TRUE(c.IsSaturatedByCallCount(6)); | EXPECT_TRUE(c.IsSaturatedByCallCount(6)); | |||
stringstream ss; | stringstream ss; | |||
c.DescribeTo(&ss); | c.DescribeTo(&ss); | |||
EXPECT_PRED_FORMAT2(IsSubstring, "called between 3 and 5 times", | EXPECT_PRED_FORMAT2(IsSubstring, "called between 3 and 5 times", ss.str()); | |||
ss.str()); | ||||
} | } | |||
TEST(BetweenTest, HasCorrectBounds) { | TEST(BetweenTest, HasCorrectBounds) { | |||
const Cardinality c = Between(3, 5); | const Cardinality c = Between(3, 5); | |||
EXPECT_EQ(3, c.ConservativeLowerBound()); | EXPECT_EQ(3, c.ConservativeLowerBound()); | |||
EXPECT_EQ(5, c.ConservativeUpperBound()); | EXPECT_EQ(5, c.ConservativeUpperBound()); | |||
} | } | |||
// Tests Exactly(n). | // Tests Exactly(n). | |||
TEST(ExactlyTest, OnNegativeNumber) { | TEST(ExactlyTest, OnNegativeNumber) { | |||
EXPECT_NONFATAL_FAILURE({ // NOLINT | EXPECT_NONFATAL_FAILURE( | |||
Exactly(-1); | { // NOLINT | |||
}, "The invocation lower bound must be >= 0"); | Exactly(-1); | |||
}, | ||||
"The invocation lower bound must be >= 0"); | ||||
} | } | |||
TEST(ExactlyTest, OnZero) { | TEST(ExactlyTest, OnZero) { | |||
const Cardinality c = Exactly(0); | const Cardinality c = Exactly(0); | |||
EXPECT_TRUE(c.IsSatisfiedByCallCount(0)); | EXPECT_TRUE(c.IsSatisfiedByCallCount(0)); | |||
EXPECT_TRUE(c.IsSaturatedByCallCount(0)); | EXPECT_TRUE(c.IsSaturatedByCallCount(0)); | |||
EXPECT_FALSE(c.IsSatisfiedByCallCount(1)); | EXPECT_FALSE(c.IsSatisfiedByCallCount(1)); | |||
EXPECT_TRUE(c.IsSaturatedByCallCount(1)); | EXPECT_TRUE(c.IsSaturatedByCallCount(1)); | |||
stringstream ss; | stringstream ss; | |||
c.DescribeTo(&ss); | c.DescribeTo(&ss); | |||
EXPECT_PRED_FORMAT2(IsSubstring, "never called", | EXPECT_PRED_FORMAT2(IsSubstring, "never called", ss.str()); | |||
ss.str()); | ||||
} | } | |||
TEST(ExactlyTest, OnPositiveNumber) { | TEST(ExactlyTest, OnPositiveNumber) { | |||
const Cardinality c = Exactly(2); | const Cardinality c = Exactly(2); | |||
EXPECT_FALSE(c.IsSatisfiedByCallCount(0)); | EXPECT_FALSE(c.IsSatisfiedByCallCount(0)); | |||
EXPECT_FALSE(c.IsSaturatedByCallCount(0)); | EXPECT_FALSE(c.IsSaturatedByCallCount(0)); | |||
EXPECT_TRUE(c.IsSatisfiedByCallCount(2)); | EXPECT_TRUE(c.IsSatisfiedByCallCount(2)); | |||
EXPECT_TRUE(c.IsSaturatedByCallCount(2)); | EXPECT_TRUE(c.IsSaturatedByCallCount(2)); | |||
stringstream ss1; | stringstream ss1; | |||
Exactly(1).DescribeTo(&ss1); | Exactly(1).DescribeTo(&ss1); | |||
EXPECT_PRED_FORMAT2(IsSubstring, "called once", | EXPECT_PRED_FORMAT2(IsSubstring, "called once", ss1.str()); | |||
ss1.str()); | ||||
stringstream ss2; | stringstream ss2; | |||
c.DescribeTo(&ss2); | c.DescribeTo(&ss2); | |||
EXPECT_PRED_FORMAT2(IsSubstring, "called twice", | EXPECT_PRED_FORMAT2(IsSubstring, "called twice", ss2.str()); | |||
ss2.str()); | ||||
stringstream ss3; | stringstream ss3; | |||
Exactly(3).DescribeTo(&ss3); | Exactly(3).DescribeTo(&ss3); | |||
EXPECT_PRED_FORMAT2(IsSubstring, "called 3 times", | EXPECT_PRED_FORMAT2(IsSubstring, "called 3 times", ss3.str()); | |||
ss3.str()); | ||||
} | } | |||
TEST(ExactlyTest, HasCorrectBounds) { | TEST(ExactlyTest, HasCorrectBounds) { | |||
const Cardinality c = Exactly(3); | const Cardinality c = Exactly(3); | |||
EXPECT_EQ(3, c.ConservativeLowerBound()); | EXPECT_EQ(3, c.ConservativeLowerBound()); | |||
EXPECT_EQ(3, c.ConservativeUpperBound()); | EXPECT_EQ(3, c.ConservativeUpperBound()); | |||
} | } | |||
// Tests that a user can make their own cardinality by implementing | // Tests that a user can make their own cardinality by implementing | |||
// CardinalityInterface and calling MakeCardinality(). | // CardinalityInterface and calling MakeCardinality(). | |||
End of changes. 27 change blocks. | ||||
58 lines changed or deleted | 52 lines changed or added |