50class BetweenCardinalityImpl :
public CardinalityInterface {
52 BetweenCardinalityImpl(
int min,
int max)
53 : min_(
min >= 0 ?
min : 0),
54 max_(max >= min_ ? max : min_) {
57 ss <<
"The invocation lower bound must be >= 0, "
58 <<
"but is actually " <<
min <<
".";
61 ss <<
"The invocation upper bound must be >= 0, "
62 <<
"but is actually " << max <<
".";
64 }
else if (min > max) {
65 ss <<
"The invocation upper bound (" << max
66 <<
") must be >= the invocation lower bound (" <<
min
74 virtual int ConservativeLowerBound()
const {
return min_; }
75 virtual int ConservativeUpperBound()
const {
return max_; }
77 virtual bool IsSatisfiedByCallCount(
int call_count)
const {
78 return min_ <= call_count && call_count <= max_;
81 virtual bool IsSaturatedByCallCount(
int call_count)
const {
82 return call_count >= max_;
85 virtual void DescribeTo(::std::ostream*
os)
const;
95inline std::string FormatTimes(
int n) {
101 std::stringstream
ss;
108void BetweenCardinalityImpl::DescribeTo(::std::ostream*
os)
const {
111 *
os <<
"never called";
112 }
else if (max_ == INT_MAX) {
113 *
os <<
"called any number of times";
115 *
os <<
"called at most " << FormatTimes(max_);
117 }
else if (min_ == max_) {
118 *
os <<
"called " << FormatTimes(min_);
119 }
else if (max_ == INT_MAX) {
120 *
os <<
"called at least " << FormatTimes(min_);
123 *
os <<
"called between " << min_ <<
" and " << max_ <<
" times";
131 ::std::ostream*
os) {
132 if (actual_call_count > 0) {
133 *
os <<
"called " << FormatTimes(actual_call_count);
135 *
os <<
"never called";
150 return Cardinality(
new BetweenCardinalityImpl(min, max));
static void DescribeActualCallCountTo(int actual_call_count, ::std::ostream *os)
#define GTEST_DISALLOW_COPY_AND_ASSIGN_(type)
static const Segment ss(Segment::ss)
const T & min(const T &a, const T &b)
void Expect(bool condition, const char *file, int line, const std::string &msg)
GTEST_API_ Cardinality AtLeast(int n)
GTEST_API_ Cardinality Between(int min, int max)
GTEST_API_ Cardinality AtMost(int n)
GTEST_API_ Cardinality AnyNumber()
GTEST_API_ Cardinality Exactly(int n)