"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "googlemock/src/gmock-cardinalities.cc" between
googletest-release-1.11.0.tar.gz and googletest-release-1.12.0.tar.gz

About: GoogleTest is Google's (unit) testing and mocking framework for C++ tests.

gmock-cardinalities.cc  (googletest-release-1.11.0):gmock-cardinalities.cc  (googletest-release-1.12.0)
skipping to change at line 37 skipping to change at line 37
// (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 implements cardinalities. // This file implements cardinalities.
#include "gmock/gmock-cardinalities.h" #include "gmock/gmock-cardinalities.h"
#include <limits.h> #include <limits.h>
#include <ostream> // NOLINT #include <ostream> // NOLINT
#include <sstream> #include <sstream>
#include <string> #include <string>
#include "gmock/internal/gmock-internal-utils.h" #include "gmock/internal/gmock-internal-utils.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
namespace testing { namespace testing {
namespace { namespace {
// Implements the Between(m, n) cardinality. // Implements the Between(m, n) cardinality.
class BetweenCardinalityImpl : public CardinalityInterface { class BetweenCardinalityImpl : public CardinalityInterface {
public: public:
BetweenCardinalityImpl(int min, int max) BetweenCardinalityImpl(int min, int max)
: min_(min >= 0 ? min : 0), : min_(min >= 0 ? min : 0), max_(max >= min_ ? max : min_) {
max_(max >= min_ ? max : min_) {
std::stringstream ss; std::stringstream ss;
if (min < 0) { if (min < 0) {
ss << "The invocation lower bound must be >= 0, " ss << "The invocation lower bound must be >= 0, "
<< "but is actually " << min << "."; << "but is actually " << min << ".";
internal::Expect(false, __FILE__, __LINE__, ss.str()); internal::Expect(false, __FILE__, __LINE__, ss.str());
} else if (max < 0) { } else if (max < 0) {
ss << "The invocation upper bound must be >= 0, " ss << "The invocation upper bound must be >= 0, "
<< "but is actually " << max << "."; << "but is actually " << max << ".";
internal::Expect(false, __FILE__, __LINE__, ss.str()); internal::Expect(false, __FILE__, __LINE__, ss.str());
} else if (min > max) { } else if (min > max) {
ss << "The invocation upper bound (" << max ss << "The invocation upper bound (" << max
<< ") must be >= the invocation lower bound (" << min << ") must be >= the invocation lower bound (" << min << ").";
<< ").";
internal::Expect(false, __FILE__, __LINE__, ss.str()); internal::Expect(false, __FILE__, __LINE__, ss.str());
} }
} }
// Conservative estimate on the lower/upper bound of the number of // Conservative estimate on the lower/upper bound of the number of
// calls allowed. // calls allowed.
int ConservativeLowerBound() const override { return min_; } int ConservativeLowerBound() const override { return min_; }
int ConservativeUpperBound() const override { return max_; } int ConservativeUpperBound() const override { return max_; }
bool IsSatisfiedByCallCount(int call_count) const override { bool IsSatisfiedByCallCount(int call_count) const override {
skipping to change at line 89 skipping to change at line 89
bool IsSaturatedByCallCount(int call_count) const override { bool IsSaturatedByCallCount(int call_count) const override {
return call_count >= max_; return call_count >= max_;
} }
void DescribeTo(::std::ostream* os) const override; void DescribeTo(::std::ostream* os) const override;
private: private:
const int min_; const int min_;
const int max_; const int max_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(BetweenCardinalityImpl); BetweenCardinalityImpl(const BetweenCardinalityImpl&) = delete;
BetweenCardinalityImpl& operator=(const BetweenCardinalityImpl&) = delete;
}; };
// Formats "n times" in a human-friendly way. // Formats "n times" in a human-friendly way.
inline std::string FormatTimes(int n) { inline std::string FormatTimes(int n) {
if (n == 1) { if (n == 1) {
return "once"; return "once";
} else if (n == 2) { } else if (n == 2) {
return "twice"; return "twice";
} else { } else {
std::stringstream ss; std::stringstream ss;
 End of changes. 5 change blocks. 
5 lines changed or deleted 6 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)