35 #include "gmock/gmock.h"
36 #include "gtest/gtest.h"
37 #include "gtest/gtest-spi.h"
41 using std::stringstream;
62 TEST(CardinalityTest, IsDefaultConstructable) {
67 TEST(CardinalityTest, IsCopyable) {
81 TEST(CardinalityTest, IsOverSaturatedByCallCountWorks) {
90 TEST(CardinalityTest, CanDescribeActualCallCount) {
92 Cardinality::DescribeActualCallCountTo(0, &ss0);
96 Cardinality::DescribeActualCallCountTo(1, &ss1);
100 Cardinality::DescribeActualCallCountTo(2, &ss2);
104 Cardinality::DescribeActualCallCountTo(3, &ss3);
126 TEST(AnyNumberTest, HasCorrectBounds) {
129 EXPECT_EQ(INT_MAX,
c.ConservativeUpperBound());
134 TEST(AtLeastTest, OnNegativeNumber) {
137 },
"The invocation lower bound must be >= 0");
140 TEST(AtLeastTest, OnZero) {
154 TEST(AtLeastTest, OnPositiveNumber) {
181 TEST(AtLeastTest, HasCorrectBounds) {
184 EXPECT_EQ(INT_MAX,
c.ConservativeUpperBound());
189 TEST(AtMostTest, OnNegativeNumber) {
192 },
"The invocation upper bound must be >= 0");
195 TEST(AtMostTest, OnZero) {
209 TEST(AtMostTest, OnPositiveNumber) {
236 TEST(AtMostTest, HasCorrectBounds) {
244 TEST(BetweenTest, OnNegativeStart) {
247 },
"The invocation lower bound must be >= 0, but is actually -1");
250 TEST(BetweenTest, OnNegativeEnd) {
253 },
"The invocation upper bound must be >= 0, but is actually -2");
256 TEST(BetweenTest, OnStartBiggerThanEnd) {
259 },
"The invocation upper bound (1) must be >= "
260 "the invocation lower bound (2)");
263 TEST(BetweenTest, OnZeroStartAndZeroEnd) {
278 TEST(BetweenTest, OnZeroStartAndNonZeroEnd) {
296 TEST(BetweenTest, OnSameStartAndEnd) {
314 TEST(BetweenTest, OnDifferentStartAndEnd) {
335 TEST(BetweenTest, HasCorrectBounds) {
343 TEST(ExactlyTest, OnNegativeNumber) {
346 },
"The invocation lower bound must be >= 0");
349 TEST(ExactlyTest, OnZero) {
363 TEST(ExactlyTest, OnPositiveNumber) {
387 TEST(ExactlyTest, HasCorrectBounds) {
396 class EvenCardinality :
public CardinalityInterface {
399 bool IsSatisfiedByCallCount(
int call_count)
const override {
400 return (call_count % 2 == 0);
404 bool IsSaturatedByCallCount(
int )
const override {
409 void DescribeTo(::std::ostream* ss)
const override {
410 *ss <<
"called even number of times";
414 TEST(MakeCardinalityTest, ConstructsCardinalityFromInterface) {
424 EXPECT_EQ(
"called even number of times", ss.str());