50 class BetweenCardinalityImpl :
public CardinalityInterface {
52 BetweenCardinalityImpl(
int min,
int max)
53 :
min_(min >= 0 ? min : 0),
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;
101 std::stringstream ss;
108 void 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_);
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));