Skip to content

Commit

Permalink
restore mistakenly removed iffs in their explicit form
Browse files Browse the repository at this point in the history
Due to confusion arisen from "iff" standing for "if and only if",
this commit uses the latter.
  • Loading branch information
kuzkry committed Aug 20, 2019
1 parent c9ccac7 commit 7bd4a7f
Show file tree
Hide file tree
Showing 35 changed files with 321 additions and 295 deletions.
4 changes: 2 additions & 2 deletions googlemock/docs/cheat_sheet.md
Original file line number Diff line number Diff line change
Expand Up @@ -731,12 +731,12 @@ you can do it earlier:
using ::testing::Mock;
...
// Verifies and removes the expectations on mock_obj;
// returns true if successful.
// returns true if and only if successful.
Mock::VerifyAndClearExpectations(&mock_obj);
...
// Verifies and removes the expectations on mock_obj;
// also removes the default actions set by ON_CALL();
// returns true if successful.
// returns true if and only if successful.
Mock::VerifyAndClear(&mock_obj);
```
Expand Down
10 changes: 6 additions & 4 deletions googlemock/docs/cook_book.md
Original file line number Diff line number Diff line change
Expand Up @@ -1270,7 +1270,8 @@ what if you want to make sure the value *pointed to* by the pointer, instead of
the pointer itself, has a certain property? Well, you can use the `Pointee(m)`
matcher.

`Pointee(m)` matches a pointer if `m` matches the value the pointer points to.
`Pointee(m)` matches a pointer if and only if `m` matches the value the pointer
points to.
For example:

```cpp
Expand Down Expand Up @@ -3573,7 +3574,7 @@ class MatcherInterface {
public:
virtual ~MatcherInterface();

// Returns true if the matcher matches x; also explains the match
// Returns true if and only if the matcher matches x; also explains the match
// result to 'listener'.
virtual bool MatchAndExplain(T x, MatchResultListener* listener) const = 0;

Expand Down Expand Up @@ -3727,10 +3728,11 @@ class CardinalityInterface {
public:
virtual ~CardinalityInterface();

// Returns true if call_count calls will satisfy this cardinality.
// Returns true if and only if call_count calls will satisfy this cardinality.
virtual bool IsSatisfiedByCallCount(int call_count) const = 0;

// Returns true if call_count calls will saturate this cardinality.
// Returns true if and only if call_count calls will saturate this
// cardinality.
virtual bool IsSaturatedByCallCount(int call_count) const = 0;

// Describes self to an ostream.
Expand Down
11 changes: 6 additions & 5 deletions googlemock/include/gmock/gmock-actions.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ struct BuiltInDefaultValueGetter<T, false> {
template <typename T>
class BuiltInDefaultValue {
public:
// This function returns true if type T has a built-in default value.
// This function returns true if and only if type T has a built-in default
// value.
static bool Exists() {
return ::std::is_default_constructible<T>::value;
}
Expand Down Expand Up @@ -208,7 +209,7 @@ class DefaultValue {
producer_ = nullptr;
}

// Returns true if the user has set the default value for type T.
// Returns true if and only if the user has set the default value for type T.
static bool IsSet() { return producer_ != nullptr; }

// Returns true if T has a default return value set by the user or there
Expand Down Expand Up @@ -269,7 +270,7 @@ class DefaultValue<T&> {
// Unsets the default value for type T&.
static void Clear() { address_ = nullptr; }

// Returns true if the user has set the default value for type T&.
// Returns true if and only if the user has set the default value for type T&.
static bool IsSet() { return address_ != nullptr; }

// Returns true if T has a default return value set by the user or there
Expand Down Expand Up @@ -375,7 +376,7 @@ class Action {
template <typename Func>
explicit Action(const Action<Func>& action) : fun_(action.fun_) {}

// Returns true if this is the DoDefault() action.
// Returns true if and only if this is the DoDefault() action.
bool IsDoDefault() const { return fun_ == nullptr; }

// Performs the action. Note that this method is const even though
Expand All @@ -395,7 +396,7 @@ class Action {
template <typename G>
friend class Action;

// fun_ is an empty function if this is the DoDefault() action.
// fun_ is an empty function if and only if this is the DoDefault() action.
::std::function<F> fun_;
};

Expand Down
14 changes: 9 additions & 5 deletions googlemock/include/gmock/gmock-cardinalities.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,12 @@ class CardinalityInterface {
virtual int ConservativeLowerBound() const { return 0; }
virtual int ConservativeUpperBound() const { return INT_MAX; }

// Returns true if call_count calls will satisfy this cardinality.
// Returns true if and only if call_count calls will satisfy this
// cardinality.
virtual bool IsSatisfiedByCallCount(int call_count) const = 0;

// Returns true if call_count calls will saturate this cardinality.
// Returns true if and only if call_count calls will saturate this
// cardinality.
virtual bool IsSaturatedByCallCount(int call_count) const = 0;

// Describes self to an ostream.
Expand All @@ -98,17 +100,19 @@ class GTEST_API_ Cardinality {
int ConservativeLowerBound() const { return impl_->ConservativeLowerBound(); }
int ConservativeUpperBound() const { return impl_->ConservativeUpperBound(); }

// Returns true if call_count calls will satisfy this cardinality.
// Returns true if and only if call_count calls will satisfy this
// cardinality.
bool IsSatisfiedByCallCount(int call_count) const {
return impl_->IsSatisfiedByCallCount(call_count);
}

// Returns true if call_count calls will saturate this cardinality.
// Returns true if and only if call_count calls will saturate this
// cardinality.
bool IsSaturatedByCallCount(int call_count) const {
return impl_->IsSaturatedByCallCount(call_count);
}

// Returns true if call_count calls will over-saturate this
// Returns true if and only if call_count calls will over-saturate this
// cardinality, i.e. exceed the maximum number of allowed calls.
bool IsOverSaturatedByCallCount(int call_count) const {
return impl_->IsSaturatedByCallCount(call_count) &&
Expand Down
40 changes: 20 additions & 20 deletions googlemock/include/gmock/gmock-matchers.h
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,8 @@ template <size_t N>
class TuplePrefix {
public:
// TuplePrefix<N>::Matches(matcher_tuple, value_tuple) returns true
// if the first N fields of matcher_tuple matches the first N
// fields of value_tuple, respectively.
// if and only if the first N fields of matcher_tuple matches
// the first N fields of value_tuple, respectively.
template <typename MatcherTuple, typename ValueTuple>
static bool Matches(const MatcherTuple& matcher_tuple,
const ValueTuple& value_tuple) {
Expand Down Expand Up @@ -420,8 +420,8 @@ class TuplePrefix<0> {
::std::ostream* /* os */) {}
};

// TupleMatches(matcher_tuple, value_tuple) returns true if all
// matchers in matcher_tuple match the corresponding fields in
// TupleMatches(matcher_tuple, value_tuple) returns true if and only if
// all matchers in matcher_tuple match the corresponding fields in
// value_tuple. It is a compiler error if matcher_tuple and
// value_tuple have different number of fields or incompatible field
// types.
Expand Down Expand Up @@ -2534,7 +2534,8 @@ class KeyMatcherImpl : public MatcherInterface<PairType> {
testing::SafeMatcherCast<const KeyType&>(inner_matcher)) {
}

// Returns true if 'key_value.first' (the key) matches the inner matcher.
// Returns true if and only if 'key_value.first' (the key) matches the inner
// matcher.
bool MatchAndExplain(PairType key_value,
MatchResultListener* listener) const override {
StringMatchResultListener inner_listener;
Expand Down Expand Up @@ -2616,8 +2617,8 @@ class PairMatcherImpl : public MatcherInterface<PairType> {
second_matcher_.DescribeNegationTo(os);
}

// Returns true if 'a_pair.first' matches first_matcher and 'a_pair.second'
// matches second_matcher.
// Returns true if and only if 'a_pair.first' matches first_matcher and
// 'a_pair.second' matches second_matcher.
bool MatchAndExplain(PairType a_pair,
MatchResultListener* listener) const override {
if (!listener->IsInterested()) {
Expand Down Expand Up @@ -3152,8 +3153,8 @@ class ElementsAreArrayMatcher {

// Given a 2-tuple matcher tm of type Tuple2Matcher and a value second
// of type Second, BoundSecondMatcher<Tuple2Matcher, Second>(tm,
// second) is a polymorphic matcher that matches a value x if tm
// matches tuple (x, second). Useful for implementing
// second) is a polymorphic matcher that matches a value x if and only if
// tm matches tuple (x, second). Useful for implementing
// UnorderedPointwise() in terms of UnorderedElementsAreArray().
//
// BoundSecondMatcher is copyable and assignable, as we need to put
Expand Down Expand Up @@ -3217,8 +3218,8 @@ class BoundSecondMatcher {

// Given a 2-tuple matcher tm and a value second,
// MatcherBindSecond(tm, second) returns a matcher that matches a
// value x if tm matches tuple (x, second). Useful for implementing
// UnorderedPointwise() in terms of UnorderedElementsAreArray().
// value x if and only if tm matches tuple (x, second). Useful for
// implementing UnorderedPointwise() in terms of UnorderedElementsAreArray().
template <typename Tuple2Matcher, typename Second>
BoundSecondMatcher<Tuple2Matcher, Second> MatcherBindSecond(
const Tuple2Matcher& tm, const Second& second) {
Expand Down Expand Up @@ -3710,7 +3711,7 @@ WhenDynamicCastTo(const Matcher<To>& inner_matcher) {
// Creates a matcher that matches an object whose given field matches
// 'matcher'. For example,
// Field(&Foo::number, Ge(5))
// matches a Foo object x if x.number >= 5.
// matches a Foo object x if and only if x.number >= 5.
template <typename Class, typename FieldType, typename FieldMatcher>
inline PolymorphicMatcher<
internal::FieldMatcher<Class, FieldType> > Field(
Expand All @@ -3737,7 +3738,7 @@ inline PolymorphicMatcher<internal::FieldMatcher<Class, FieldType> > Field(
// Creates a matcher that matches an object whose given property
// matches 'matcher'. For example,
// Property(&Foo::str, StartsWith("hi"))
// matches a Foo object x if x.str() starts with "hi".
// matches a Foo object x if and only if x.str() starts with "hi".
template <typename Class, typename PropertyType, typename PropertyMatcher>
inline PolymorphicMatcher<internal::PropertyMatcher<
Class, PropertyType, PropertyType (Class::*)() const> >
Expand Down Expand Up @@ -3792,11 +3793,10 @@ Property(const std::string& property_name,
property_name, property, MatcherCast<const PropertyType&>(matcher)));
}

// Creates a matcher that matches an object if the result of applying
// a callable to x matches 'matcher'.
// For example,
// Creates a matcher that matches an object if and only if the result of
// applying a callable to x matches 'matcher'. For example,
// ResultOf(f, StartsWith("hi"))
// matches a Foo object x if f(x) starts with "hi".
// matches a Foo object x if and only if f(x) starts with "hi".
// `callable` parameter can be a function, function pointer, or a functor. It is
// required to keep no state affecting the results of the calls on it and make
// no assumptions about how many calls will be made. Any state it keeps must be
Expand Down Expand Up @@ -4345,7 +4345,7 @@ inline internal::MatcherAsPredicate<M> Matches(M matcher) {
return internal::MatcherAsPredicate<M>(matcher);
}

// Returns true if the value matches the matcher.
// Returns true if and only if the value matches the matcher.
template <typename T, typename M>
inline bool Value(const T& value, M matcher) {
return testing::Matches(matcher)(value);
Expand Down Expand Up @@ -4551,8 +4551,8 @@ PolymorphicMatcher<internal::variant_matcher::VariantMatcher<T> > VariantWith(

// These macros allow using matchers to check values in Google Test
// tests. ASSERT_THAT(value, matcher) and EXPECT_THAT(value, matcher)
// succeed if the value matches the matcher. If the assertion fails,
// the value and the description of the matcher will be printed.
// succeed if and only if the value matches the matcher. If the assertion
// fails, the value and the description of the matcher will be printed.
#define ASSERT_THAT(value, matcher) ASSERT_PRED_FORMAT1(\
::testing::internal::MakePredicateFormatterFromMatcher(matcher), value)
#define EXPECT_THAT(value, matcher) EXPECT_PRED_FORMAT1(\
Expand Down
35 changes: 19 additions & 16 deletions googlemock/include/gmock/gmock-spec-builders.h
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ class OnCallSpec : public UntypedOnCallSpecBase {
return *this;
}

// Returns true if the given arguments match the matchers.
// Returns true if and only if the given arguments match the matchers.
bool Matches(const ArgumentTuple& args) const {
return TupleMatches(matchers_, args) && extra_matcher_.Matches(args);
}
Expand Down Expand Up @@ -390,7 +390,7 @@ class GTEST_API_ Mock {
GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);

// Verifies all expectations on the given mock object and clears its
// default actions and expectations. Returns true if the
// default actions and expectations. Returns true if and only if the
// verification was successful.
static bool VerifyAndClear(void* mock_obj)
GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
Expand Down Expand Up @@ -516,7 +516,8 @@ class GTEST_API_ Expectation {
// The compiler-generated copy ctor and operator= work exactly as
// intended, so we don't need to define our own.

// Returns true if rhs references the same expectation as this object does.
// Returns true if and only if rhs references the same expectation as this
// object does.
bool operator==(const Expectation& rhs) const {
return expectation_base_ == rhs.expectation_base_;
}
Expand Down Expand Up @@ -598,8 +599,8 @@ class ExpectationSet {
// The compiler-generator ctor and operator= works exactly as
// intended, so we don't need to define our own.

// Returns true if rhs contains the same set of Expectation objects
// as this does.
// Returns true if and only if rhs contains the same set of Expectation
// objects as this does.
bool operator==(const ExpectationSet& rhs) const {
return expectations_ == rhs.expectations_;
}
Expand Down Expand Up @@ -760,8 +761,8 @@ class GTEST_API_ ExpectationBase {
// by the subclasses to implement the .Times() clause.
void SpecifyCardinality(const Cardinality& cardinality);

// Returns true if the user specified the cardinality explicitly
// using a .Times().
// Returns true if and only if the user specified the cardinality
// explicitly using a .Times().
bool cardinality_specified() const { return cardinality_specified_; }

// Sets the cardinality of this expectation spec.
Expand All @@ -777,7 +778,7 @@ class GTEST_API_ ExpectationBase {
void RetireAllPreRequisites()
GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex);

// Returns true if this expectation is retired.
// Returns true if and only if this expectation is retired.
bool is_retired() const
GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
g_gmock_mutex.AssertHeld();
Expand All @@ -791,28 +792,29 @@ class GTEST_API_ ExpectationBase {
retired_ = true;
}

// Returns true if this expectation is satisfied.
// Returns true if and only if this expectation is satisfied.
bool IsSatisfied() const
GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
g_gmock_mutex.AssertHeld();
return cardinality().IsSatisfiedByCallCount(call_count_);
}

// Returns true if this expectation is saturated.
// Returns true if and only if this expectation is saturated.
bool IsSaturated() const
GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
g_gmock_mutex.AssertHeld();
return cardinality().IsSaturatedByCallCount(call_count_);
}

// Returns true if this expectation is over-saturated.
// Returns true if and only if this expectation is over-saturated.
bool IsOverSaturated() const
GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
g_gmock_mutex.AssertHeld();
return cardinality().IsOverSaturatedByCallCount(call_count_);
}

// Returns true if all pre-requisites of this expectation are satisfied.
// Returns true if and only if all pre-requisites of this expectation are
// satisfied.
bool AllPrerequisitesAreSatisfied() const
GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex);

Expand Down Expand Up @@ -855,7 +857,7 @@ class GTEST_API_ ExpectationBase {
const char* file_; // The file that contains the expectation.
int line_; // The line number of the expectation.
const std::string source_text_; // The EXPECT_CALL(...) source text.
// True if the cardinality is specified explicitly.
// True if and only if the cardinality is specified explicitly.
bool cardinality_specified_;
Cardinality cardinality_; // The cardinality of the expectation.
// The immediate pre-requisites (i.e. expectations that must be
Expand All @@ -869,7 +871,7 @@ class GTEST_API_ ExpectationBase {
// This group of fields are the current state of the expectation,
// and can change as the mock function is called.
int call_count_; // How many times this expectation has been invoked.
bool retired_; // True if this expectation has retired.
bool retired_; // True if and only if this expectation has retired.
UntypedActions untyped_actions_;
bool extra_matcher_specified_;
bool repeated_action_specified_; // True if a WillRepeatedly() was specified.
Expand Down Expand Up @@ -1087,14 +1089,15 @@ class TypedExpectation : public ExpectationBase {
// statement finishes and when the current thread holds
// g_gmock_mutex.

// Returns true if this expectation matches the given arguments.
// Returns true if and only if this expectation matches the given arguments.
bool Matches(const ArgumentTuple& args) const
GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
g_gmock_mutex.AssertHeld();
return TupleMatches(matchers_, args) && extra_matcher_.Matches(args);
}

// Returns true if this expectation should handle the given arguments.
// Returns true if and only if this expectation should handle the given
// arguments.
bool ShouldHandleArguments(const ArgumentTuple& args) const
GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
g_gmock_mutex.AssertHeld();
Expand Down
Loading

0 comments on commit 7bd4a7f

Please sign in to comment.