51 {
52
53
54
55
56
57
58
59
60
61
62
63
64class CardinalityInterface {
65 public:
66 virtual ~CardinalityInterface() {}
67
68
69
70 virtual int ConservativeLowerBound() const { return 0; }
71 virtual int ConservativeUpperBound() const { return INT_MAX; }
72
73
74
75 virtual bool IsSatisfiedByCallCount(int call_count) const = 0;
76
77
78
79 virtual bool IsSaturatedByCallCount(int call_count) const = 0;
80
81
82 virtual void DescribeTo(::std::ostream* os) const = 0;
83};
84
85
86
87
88
90 public:
91
92
93 Cardinality() {}
94
95
96 explicit Cardinality(const CardinalityInterface* impl) : impl_(impl) {}
97
98
99
100 int ConservativeLowerBound() const { return impl_->ConservativeLowerBound(); }
101 int ConservativeUpperBound() const { return impl_->ConservativeUpperBound(); }
102
103
104
105 bool IsSatisfiedByCallCount(int call_count) const {
106 return impl_->IsSatisfiedByCallCount(call_count);
107 }
108
109
110
111 bool IsSaturatedByCallCount(int call_count) const {
112 return impl_->IsSaturatedByCallCount(call_count);
113 }
114
115
116
117 bool IsOverSaturatedByCallCount(int call_count) const {
118 return impl_->IsSaturatedByCallCount(call_count) &&
119 !impl_->IsSatisfiedByCallCount(call_count);
120 }
121
122
123 void DescribeTo(::std::ostream* os) const { impl_->DescribeTo(os); }
124
125
126 static void DescribeActualCallCountTo(int actual_call_count,
127 ::std::ostream* os);
128
129 private:
130 std::shared_ptr<const CardinalityInterface> impl_;
131};
132
133
135
136
138
139
141
142
144
145
147
148
149inline Cardinality MakeCardinality(const CardinalityInterface* c) {
150 return Cardinality(c);
151}
152
153}
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)