Commit c7a03daa authored by Shaindel Schwartz's avatar Shaindel Schwartz
Browse files

Merge pull request #2387 from kuzkry:iff

PiperOrigin-RevId: 268693457
parents ac24edd6 7bd4a7f3
......@@ -742,12 +742,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);
```
......
......@@ -1270,8 +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.
For example:
`Pointee(m)` matches a pointer if and only if `m` matches the value the pointer
points to. For example:
```cpp
using ::testing::Ge;
......@@ -3573,7 +3573,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;
......@@ -3727,10 +3727,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.
......
......@@ -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;
}
......@@ -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
......@@ -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
......@@ -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
......@@ -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_;
};
......
......@@ -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.
......@@ -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) &&
......
......@@ -358,8 +358,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) {
......@@ -417,8 +417,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.
......@@ -2530,7 +2530,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;
......@@ -2612,8 +2613,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()) {
......@@ -3148,8 +3149,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
......@@ -3213,8 +3214,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) {
......@@ -3705,7 +3706,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(
......@@ -3732,7 +3733,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> >
......@@ -3787,11 +3788,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
......@@ -4341,7 +4341,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);
......@@ -4547,8 +4547,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(\
......
......@@ -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);
}
......@@ -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);
......@@ -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_;
}
......@@ -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_;
}
......@@ -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.
......@@ -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();
......@@ -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);
......@@ -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
......@@ -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.
......@@ -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();
......
......@@ -157,11 +157,11 @@ GMOCK_DECLARE_KIND_(long double, kFloatingPoint);
static_cast< ::testing::internal::TypeKind>( \
::testing::internal::KindOf<type>::value)
// Evaluates to true if integer type T is signed.
// Evaluates to true if and only if integer type T is signed.
#define GMOCK_IS_SIGNED_(T) (static_cast<T>(-1) < 0)
// LosslessArithmeticConvertibleImpl<kFromKind, From, kToKind, To>::value
// is true if arithmetic type From can be losslessly converted to
// is true if and only if arithmetic type From can be losslessly converted to
// arithmetic type To.
//
// It's the user's responsibility to ensure that both From and To are
......@@ -192,8 +192,8 @@ template <typename From>
struct LosslessArithmeticConvertibleImpl<kInteger, From, kBool, bool>
: public std::false_type {};
// Converting an integer to another non-bool integer is lossless if
// the target type's range encloses the source type's range.
// Converting an integer to another non-bool integer is lossless
// if and only if the target type's range encloses the source type's range.
template <typename From, typename To>
struct LosslessArithmeticConvertibleImpl<kInteger, From, kInteger, To>
: public bool_constant<
......@@ -224,14 +224,14 @@ struct LosslessArithmeticConvertibleImpl<kFloatingPoint, From, kInteger, To>
: public std::false_type {};
// Converting a floating-point to another floating-point is lossless
// if the target type is at least as big as the source type.
// if and only if the target type is at least as big as the source type.
template <typename From, typename To>
struct LosslessArithmeticConvertibleImpl<
kFloatingPoint, From, kFloatingPoint, To>
: public bool_constant<sizeof(From) <= sizeof(To)> {}; // NOLINT
// LosslessArithmeticConvertible<From, To>::value is true if arithmetic
// type From can be losslessly converted to arithmetic type To.
// LosslessArithmeticConvertible<From, To>::value is true if and only if
// arithmetic type From can be losslessly converted to arithmetic type To.
//
// It's the user's responsibility to ensure that both From and To are
// raw (i.e. has no CV modifier, is not a pointer, and is not a
......@@ -305,11 +305,11 @@ const char kWarningVerbosity[] = "warning";
// No logs are printed.
const char kErrorVerbosity[] = "error";
// Returns true if a log with the given severity is visible according
// to the --gmock_verbose flag.
// Returns true if and only if a log with the given severity is visible
// according to the --gmock_verbose flag.
GTEST_API_ bool LogIsVisible(LogSeverity severity);
// Prints the given message to stdout if 'severity' >= the level
// Prints the given message to stdout if and only if 'severity' >= the level
// specified by the --gmock_verbose flag. If stack_frames_to_skip >=
// 0, also prints the stack trace excluding the top
// stack_frames_to_skip frames. In opt mode, any positive
......
......@@ -123,8 +123,8 @@ GTEST_API_ FailureReporterInterface* GetFailureReporter() {
// Protects global resources (stdout in particular) used by Log().
static GTEST_DEFINE_STATIC_MUTEX_(g_log_mutex);
// Returns true if a log with the given severity is visible according
// to the --gmock_verbose flag.
// Returns true if and only if a log with the given severity is visible
// according to the --gmock_verbose flag.
GTEST_API_ bool LogIsVisible(LogSeverity severity) {
if (GMOCK_FLAG(verbose) == kInfoVerbosity) {
// Always show the log if --gmock_verbose=info.
......@@ -139,7 +139,7 @@ GTEST_API_ bool LogIsVisible(LogSeverity severity) {
}
}
// Prints the given message to stdout if 'severity' >= the level
// Prints the given message to stdout if and only if 'severity' >= the level
// specified by the --gmock_verbose flag. If stack_frames_to_skip >=
// 0, also prints the stack trace excluding the top
// stack_frames_to_skip frames. In opt mode, any positive
......
......@@ -126,8 +126,8 @@ void ExpectationBase::RetireAllPreRequisites()
}
}
// Returns true if all pre-requisites of this expectation have been
// satisfied.
// Returns true if and only if all pre-requisites of this expectation
// have been satisfied.
bool ExpectationBase::AllPrerequisitesAreSatisfied() const
GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
g_gmock_mutex.AssertHeld();
......@@ -384,7 +384,7 @@ UntypedActionResultHolderBase* UntypedFunctionMockerBase::UntypedInvokeWith(
const CallReaction reaction =
Mock::GetReactionOnUninterestingCalls(MockObject());
// True if we need to print this call's arguments and return
// True if and only if we need to print this call's arguments and return
// value. This definition must be kept in sync with
// the behavior of ReportUninterestingCall().
const bool need_to_report_uninteresting_call =
......@@ -435,7 +435,8 @@ UntypedActionResultHolderBase* UntypedFunctionMockerBase::UntypedInvokeWith(
&ss, &why);
const bool found = untyped_expectation != nullptr;
// True if we need to print the call's arguments and return value.
// True if and only if we need to print the call's arguments
// and return value.
// This definition must be kept in sync with the uses of Expect()
// and Log() in this function.
const bool need_to_report_call =
......@@ -574,7 +575,7 @@ struct MockObjectState {
int first_used_line;
::std::string first_used_test_suite;
::std::string first_used_test;
bool leakable; // true if it's OK to leak the object.
bool leakable; // true if and only if it's OK to leak the object.
FunctionMockers function_mockers; // All registered methods of the object.
};
......@@ -718,7 +719,7 @@ bool Mock::VerifyAndClearExpectations(void* mock_obj)
}
// 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.
bool Mock::VerifyAndClear(void* mock_obj)
GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) {
......
......@@ -34,8 +34,8 @@
namespace testing {
GMOCK_DEFINE_bool_(catch_leaked_mocks, true,
"true if Google Mock should report leaked mock objects "
"as failures.");
"true if and only if Google Mock should report leaked "
"mock objects as failures.");
GMOCK_DEFINE_string_(verbose, internal::kWarningVerbosity,
"Controls how verbose Google Mock's output is."
......
......@@ -395,12 +395,14 @@ TEST(ExactlyTest, HasCorrectBounds) {
class EvenCardinality : public CardinalityInterface {
public:
// 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 override {
return (call_count % 2 == 0);
}
// 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 override {
return false;
}
......
......@@ -956,10 +956,9 @@ TEST(TypedEqTest, CanDescribeSelf) {
// Tests that TypedEq<T>(v) has type Matcher<T>.
// Type<T>::IsTypeOf(v) compiles if the type of value v is T, where T
// is a "bare" type (i.e. not in the form of const U or U&). If v's
// type is not T, the compiler will generate a message about
// "undefined reference".
// Type<T>::IsTypeOf(v) compiles if and only if the type of value v is T, where
// T is a "bare" type (i.e. not in the form of const U or U&). If v's type is
// not T, the compiler will generate a message about "undefined reference".
template <typename T>
struct Type {
static bool IsTypeOf(const T& /* v */) { return true; }
......@@ -2640,8 +2639,8 @@ class IsGreaterThan {
// For testing Truly().
const int foo = 0;
// This predicate returns true if the argument references foo and has
// a zero value.
// This predicate returns true if and only if the argument references foo and
// has a zero value.
bool ReferencesFooAndIsZero(const int& n) {
return (&n == &foo) && (n == 0);
}
......@@ -3594,7 +3593,7 @@ class Uncopyable {
GTEST_DISALLOW_COPY_AND_ASSIGN_(Uncopyable);
};
// Returns true if x.value() is positive.
// Returns true if and only if x.value() is positive.
bool ValueIsPositive(const Uncopyable& x) { return x.value() > 0; }
MATCHER_P(UncopyableIs, inner_matcher, "") {
......
......@@ -1952,12 +1952,14 @@ TEST(DeletingMockEarlyTest, Failure2) {
class EvenNumberCardinality : public CardinalityInterface {
public:
// 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 override {
return call_count % 2 == 0;
}
// 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 override {
return false;
}
......
......@@ -276,20 +276,20 @@ class GTEST_API_ KilledBySignal {
// This macro is used for implementing macros such as
// EXPECT_DEATH_IF_SUPPORTED and ASSERT_DEATH_IF_SUPPORTED on systems where
// death tests are not supported. Those macros must compile on such systems
// if EXPECT_DEATH and ASSERT_DEATH compile with the same parameters on
// systems that support death tests. This allows one to write such a macro
// on a system that does not support death tests and be sure that it will
// compile on a death-test supporting system. It is exposed publicly so that
// systems that have death-tests with stricter requirements than
// GTEST_HAS_DEATH_TEST can write their own equivalent of
// EXPECT_DEATH_IF_SUPPORTED and ASSERT_DEATH_IF_SUPPORTED.
// if and only if EXPECT_DEATH and ASSERT_DEATH compile with the same parameters
// on systems that support death tests. This allows one to write such a macro on
// a system that does not support death tests and be sure that it will compile
// on a death-test supporting system. It is exposed publicly so that systems
// that have death-tests with stricter requirements than GTEST_HAS_DEATH_TEST
// can write their own equivalent of EXPECT_DEATH_IF_SUPPORTED and
// ASSERT_DEATH_IF_SUPPORTED.
//
// Parameters:
// statement - A statement that a macro such as EXPECT_DEATH would test
// for program termination. This macro has to make sure this
// statement is compiled but not executed, to ensure that
// EXPECT_DEATH_IF_SUPPORTED compiles with a certain
// parameter if EXPECT_DEATH compiles with it.
// parameter if and only if EXPECT_DEATH compiles with it.
// regex - A regex that a macro such as EXPECT_DEATH would use to test
// the output of statement. This parameter has to be
// compiled but not evaluated by this macro, to ensure that
......
......@@ -96,8 +96,8 @@ class MatchResultListener {
// Returns the underlying ostream.
::std::ostream* stream() { return stream_; }
// Returns true if the listener is interested in an explanation of
// the match result. A matcher's MatchAndExplain() method can use
// Returns true if and only if the listener is interested in an explanation
// of the match result. A matcher's MatchAndExplain() method can use
// this information to avoid generating the explanation when no one
// intends to hear it.
bool IsInterested() const { return stream_ != nullptr; }
......@@ -141,8 +141,8 @@ class MatcherDescriberInterface {
template <typename T>
class MatcherInterface : public MatcherDescriberInterface {
public:
// Returns true if the matcher matches x; also explains the match
// result to 'listener' if necessary (see the next paragraph), in
// Returns true if and only if the matcher matches x; also explains the
// match result to 'listener' if necessary (see the next paragraph), in
// the form of a non-restrictive relative clause ("which ...",
// "whose ...", etc) that describes x. For example, the
// MatchAndExplain() method of the Pointee(...) matcher should
......@@ -258,13 +258,13 @@ class StreamMatchResultListener : public MatchResultListener {
template <typename T>
class MatcherBase {
public:
// Returns true if the matcher matches x; also explains the match
// result to 'listener'.
// Returns true if and only if the matcher matches x; also explains the
// match result to 'listener'.
bool MatchAndExplain(const T& x, MatchResultListener* listener) const {
return impl_->MatchAndExplain(x, listener);
}
// Returns true if this matcher matches x.
// Returns true if and only if this matcher matches x.
bool Matches(const T& x) const {
DummyMatchResultListener dummy;
return MatchAndExplain(x, &dummy);
......
......@@ -87,19 +87,19 @@ class GTEST_API_ TestPartResult {
// Gets the message associated with the test part.
const char* message() const { return message_.c_str(); }
// Returns true if the test part was skipped.
// Returns true if and only if the test part was skipped.
bool skipped() const { return type_ == kSkip; }
// Returns true if the test part passed.
// Returns true if and only if the test part passed.
bool passed() const { return type_ == kSuccess; }
// Returns true if the test part non-fatally failed.
// Returns true if and only if the test part non-fatally failed.
bool nonfatally_failed() const { return type_ == kNonFatalFailure; }
// Returns true if the test part fatally failed.
// Returns true if and only if the test part fatally failed.
bool fatally_failed() const { return type_ == kFatalFailure; }
// Returns true if the test part failed.
// Returns true if and only if the test part failed.
bool failed() const { return fatally_failed() || nonfatally_failed(); }
private:
......
......@@ -308,7 +308,7 @@ class GTEST_API_ AssertionResult {
return *this;
}
// Returns true if the assertion succeeded.
// Returns true if and only if the assertion succeeded.
operator bool() const { return success_; } // NOLINT
// Returns the assertion's negation. Used with EXPECT/ASSERT_FALSE.
......@@ -432,16 +432,16 @@ class GTEST_API_ Test {
static void SetUpTestCase() {}
#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
// Returns true if the current test has a fatal failure.
// Returns true if and only if the current test has a fatal failure.
static bool HasFatalFailure();
// Returns true if the current test has a non-fatal failure.
// Returns true if and only if the current test has a non-fatal failure.
static bool HasNonfatalFailure();
// Returns true if the current test was skipped.
// Returns true if and only if the current test was skipped.
static bool IsSkipped();
// Returns true if the current test has a (either fatal or
// Returns true if and only if the current test has a (either fatal or
// non-fatal) failure.
static bool HasFailure() { return HasFatalFailure() || HasNonfatalFailure(); }
......@@ -472,8 +472,8 @@ class GTEST_API_ Test {
virtual void TearDown();
private:
// Returns true if the current test has the same fixture class as
// the first test in the current test suite.
// Returns true if and only if the current test has the same fixture class
// as the first test in the current test suite.
static bool HasSameFixtureClass();
// Runs the test after the test fixture has been set up.
......@@ -574,19 +574,19 @@ class GTEST_API_ TestResult {
// Returns the number of the test properties.
int test_property_count() const;
// Returns true if the test passed (i.e. no test part failed).
// Returns true if and only if the test passed (i.e. no test part failed).
bool Passed() const { return !Skipped() && !Failed(); }
// Returns true if the test was skipped.
// Returns true if and only if the test was skipped.
bool Skipped() const;
// Returns true if the test failed.
// Returns true if and only if the test failed.
bool Failed() const;
// Returns true if the test fatally failed.
// Returns true if and only if the test fatally failed.
bool HasFatalFailure() const;
// Returns true if the test has a non-fatal failure.
// Returns true if and only if the test has a non-fatal failure.
bool HasNonfatalFailure() const;
// Returns the elapsed time, in milliseconds.
......@@ -750,7 +750,7 @@ class GTEST_API_ TestInfo {
// contains the character 'A' or starts with "Foo.".
bool should_run() const { return should_run_; }
// Returns true if this test will appear in the XML report.
// Returns true if and only if this test will appear in the XML report.
bool is_reportable() const {
// The XML report includes tests matching the filter, excluding those
// run in other shards.
......@@ -808,12 +808,12 @@ class GTEST_API_ TestInfo {
// value-parameterized test.
const std::unique_ptr<const ::std::string> value_param_;
internal::CodeLocation location_;
const internal::TypeId fixture_class_id_; // ID of the test fixture class
bool should_run_; // True if this test should run
bool is_disabled_; // True if this test is disabled
bool matches_filter_; // True if this test matches the
// user-specified filter.
bool is_in_another_shard_; // Will be run in another shard.
const internal::TypeId fixture_class_id_; // ID of the test fixture class
bool should_run_; // True if and only if this test should run
bool is_disabled_; // True if and only if this test is disabled
bool matches_filter_; // True if this test matches the
// user-specified filter.
bool is_in_another_shard_; // Will be run in another shard.
internal::TestFactoryBase* const factory_; // The factory that creates
// the test object
......@@ -885,10 +885,10 @@ class GTEST_API_ TestSuite {
// Gets the number of all tests in this test suite.
int total_test_count() const;
// Returns true if the test suite passed.
// Returns true if and only if the test suite passed.
bool Passed() const { return !Failed(); }
// Returns true if the test suite failed.
// Returns true if and only if the test suite failed.
bool Failed() const { return failed_test_count() > 0; }
// Returns the elapsed time, in milliseconds.
......@@ -956,33 +956,33 @@ class GTEST_API_ TestSuite {
}
}
// Returns true if test passed.
// Returns true if and only if test passed.
static bool TestPassed(const TestInfo* test_info) {
return test_info->should_run() && test_info->result()->Passed();
}
// Returns true if test skipped.
// Returns true if and only if test skipped.
static bool TestSkipped(const TestInfo* test_info) {
return test_info->should_run() && test_info->result()->Skipped();
}
// Returns true if test failed.
// Returns true if and only if test failed.
static bool TestFailed(const TestInfo* test_info) {
return test_info->should_run() && test_info->result()->Failed();
}
// Returns true if the test is disabled and will be reported in the XML
// report.
// Returns true if and only if the test is disabled and will be reported in
// the XML report.
static bool TestReportableDisabled(const TestInfo* test_info) {
return test_info->is_reportable() && test_info->is_disabled_;
}
// Returns true if test is disabled.
// Returns true if and only if test is disabled.
static bool TestDisabled(const TestInfo* test_info) {
return test_info->is_disabled_;
}
// Returns true if this test will appear in the XML report.
// Returns true if and only if this test will appear in the XML report.
static bool TestReportable(const TestInfo* test_info) {
return test_info->is_reportable();
}
......@@ -1014,7 +1014,7 @@ class GTEST_API_ TestSuite {
internal::SetUpTestSuiteFunc set_up_tc_;
// Pointer to the function that tears down the test suite.
internal::TearDownTestSuiteFunc tear_down_tc_;
// True if any test in this test suite should run.
// True if and only if any test in this test suite should run.
bool should_run_;
// The start time, in milliseconds since UNIX Epoch.
TimeInMillis start_timestamp_;
......@@ -1349,11 +1349,12 @@ class GTEST_API_ UnitTest {
// Gets the elapsed time, in milliseconds.
TimeInMillis elapsed_time() const;
// Returns true if the unit test passed (i.e. all test suites passed).
// Returns true if and only if the unit test passed (i.e. all test suites
// passed).
bool Passed() const;
// Returns true if the unit test failed (i.e. some test suite failed
// or something outside of all tests failed).
// Returns true if and only if the unit test failed (i.e. some test suite
// failed or something outside of all tests failed).
bool Failed() const;
// Gets the i-th test suite among all the test suites. i can range from 0 to
......@@ -2265,10 +2266,9 @@ class GTEST_API_ ScopedTrace {
::testing::ScopedTrace GTEST_CONCAT_TOKEN_(gtest_trace_, __LINE__)(\
__FILE__, __LINE__, (message))
// Compile-time assertion for type equality.
// StaticAssertTypeEq<type1, type2>() compiles if type1 and type2 are
// the same type. The value it returns is not interesting.
// StaticAssertTypeEq<type1, type2>() compiles if and only if type1 and type2
// are the same type. The value it returns is not interesting.
//
// Instead of making StaticAssertTypeEq a class template, we make it a
// function template that invokes a helper class template. This
......
......@@ -110,7 +110,7 @@ class GTEST_API_ FilePath {
const FilePath& base_name,
const char* extension);
// Returns true if the path is "".
// Returns true if and only if the path is "".
bool IsEmpty() const { return pathname_.empty(); }
// If input name has a trailing separator character, removes it and returns
......
......@@ -189,7 +189,7 @@ GTEST_API_ std::string DiffStrings(const std::string& left,
// expected_value: "5"
// actual_value: "6"
//
// The ignoring_case parameter is true if the assertion is a
// The ignoring_case parameter is true if and only if the assertion is a
// *_STRCASEEQ*. When it's true, the string " (ignoring case)" will
// be inserted into the message.
GTEST_API_ AssertionResult EqFailure(const char* expected_expression,
......@@ -318,15 +318,15 @@ class FloatingPoint {
// Returns the sign bit of this number.
Bits sign_bit() const { return kSignBitMask & u_.bits_; }
// Returns true if this is NAN (not a number).
// Returns true if and only if this is NAN (not a number).
bool is_nan() const {
// It's a NAN if the exponent bits are all ones and the fraction
// bits are not entirely zeros.
return (exponent_bits() == kExponentBitMask) && (fraction_bits() != 0);
}
// Returns true if this number is at most kMaxUlps ULP's away from
// rhs. In particular, this function:
// Returns true if and only if this number is at most kMaxUlps ULP's away
// from rhs. In particular, this function:
//
// - returns false if either number is (or both are) NAN.
// - treats really large numbers as almost equal to infinity.
......@@ -852,7 +852,7 @@ class GTEST_API_ Random {
typename std::remove_const<typename std::remove_reference<T>::type>::type
// IsAProtocolMessage<T>::value is a compile-time bool constant that's
// true if T is type proto2::Message or a subclass of it.
// true if and only if T is type proto2::Message or a subclass of it.
template <typename T>
struct IsAProtocolMessage
: public bool_constant<
......
......@@ -357,7 +357,8 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
# include <android/api-level.h> // NOLINT
#endif
// Defines this to true if Google Test can use POSIX regular expressions.
// Defines this to true if and only if Google Test can use POSIX regular
// expressions.
#ifndef GTEST_HAS_POSIX_RE
# if GTEST_OS_LINUX_ANDROID
// On Android, <regex.h> is only available starting with Gingerbread.
......@@ -398,7 +399,7 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
// The user didn't tell us whether exceptions are enabled, so we need
// to figure it out.
# if defined(_MSC_VER) && defined(_CPPUNWIND)
// MSVC defines _CPPUNWIND to 1 if exceptions are enabled.
// MSVC defines _CPPUNWIND to 1 if and only if exceptions are enabled.
# define GTEST_HAS_EXCEPTIONS 1
# elif defined(__BORLANDC__)
// C++Builder's implementation of the STL uses the _HAS_EXCEPTIONS
......@@ -409,16 +410,17 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
# endif // _HAS_EXCEPTIONS
# define GTEST_HAS_EXCEPTIONS _HAS_EXCEPTIONS
# elif defined(__clang__)
// clang defines __EXCEPTIONS if exceptions are enabled before clang 220714,
// but if cleanups are enabled after that. In Obj-C++ files, there can be
// cleanups for ObjC exceptions which also need cleanups, even if C++ exceptions
// are disabled. clang has __has_feature(cxx_exceptions) which checks for C++
// exceptions starting at clang r206352, but which checked for cleanups prior to
// that. To reliably check for C++ exception availability with clang, check for
// clang defines __EXCEPTIONS if and only if exceptions are enabled before clang
// 220714, but if and only if cleanups are enabled after that. In Obj-C++ files,
// there can be cleanups for ObjC exceptions which also need cleanups, even if
// C++ exceptions are disabled. clang has __has_feature(cxx_exceptions) which
// checks for C++ exceptions starting at clang r206352, but which checked for
// cleanups prior to that. To reliably check for C++ exception availability with
// clang, check for
// __EXCEPTIONS && __has_feature(cxx_exceptions).
# define GTEST_HAS_EXCEPTIONS (__EXCEPTIONS && __has_feature(cxx_exceptions))
# elif defined(__GNUC__) && __EXCEPTIONS
// gcc defines __EXCEPTIONS to 1 if exceptions are enabled.
// gcc defines __EXCEPTIONS to 1 if and only if exceptions are enabled.
# define GTEST_HAS_EXCEPTIONS 1
# elif defined(__SUNPRO_CC)
// Sun Pro CC supports exceptions. However, there is no compile-time way of
......@@ -426,7 +428,7 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
// they are enabled unless the user tells us otherwise.
# define GTEST_HAS_EXCEPTIONS 1
# elif defined(__IBMCPP__) && __EXCEPTIONS
// xlC defines __EXCEPTIONS to 1 if exceptions are enabled.
// xlC defines __EXCEPTIONS to 1 if and only if exceptions are enabled.
# define GTEST_HAS_EXCEPTIONS 1
# elif defined(__HP_aCC)
// Exception handling is in effect by default in HP aCC compiler. It has to
......@@ -467,13 +469,14 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
# ifdef _MSC_VER
# ifdef _CPPRTTI // MSVC defines this macro if RTTI is enabled.
#ifdef _CPPRTTI // MSVC defines this macro if and only if RTTI is enabled.
# define GTEST_HAS_RTTI 1
# else
# define GTEST_HAS_RTTI 0
# endif
// Starting with version 4.3.2, gcc defines __GXX_RTTI if RTTI is enabled.
// Starting with version 4.3.2, gcc defines __GXX_RTTI if and only if RTTI is
// enabled.
# elif defined(__GNUC__)
# ifdef __GXX_RTTI
......@@ -894,9 +897,9 @@ class GTEST_API_ RE {
// Returns the string representation of the regex.
const char* pattern() const { return pattern_; }
// FullMatch(str, re) returns true if regular expression re matches
// the entire str.
// PartialMatch(str, re) returns true if regular expression re
// FullMatch(str, re) returns true if and only if regular expression re
// matches the entire str.
// PartialMatch(str, re) returns true if and only if regular expression re
// matches a substring of str (including str itself).
static bool FullMatch(const ::std::string& str, const RE& re) {
return FullMatch(str.c_str(), re);
......@@ -1238,7 +1241,8 @@ class GTEST_API_ AutoHandle {
void Reset(Handle handle);
private:
// Returns true if the handle is a valid handle object that can be closed.
// Returns true if and only if the handle is a valid handle object that can be
// closed.
bool IsCloseable() const;
Handle handle_;
......@@ -1340,7 +1344,8 @@ class ThreadWithParam : public ThreadWithParamBase {
// When non-NULL, used to block execution until the controller thread
// notifies.
Notification* const thread_can_start_;
bool finished_; // true if we know that the thread function has finished.
bool finished_; // true if and only if we know that the thread function has
// finished.
pthread_t thread_; // The native thread object.
GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadWithParam);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment