restore mistakenly removed iffs in their explicit form

Due to confusion arisen from "iff" standing for "if and only if",
this commit uses the latter.
This commit is contained in:
Krystian Kuzniarek 2019-08-12 07:09:50 +02:00
parent c9ccac7cb7
commit 7bd4a7f3e9
35 changed files with 321 additions and 295 deletions

View File

@ -731,12 +731,12 @@ you can do it earlier:
using ::testing::Mock; using ::testing::Mock;
... ...
// Verifies and removes the expectations on mock_obj; // Verifies and removes the expectations on mock_obj;
// returns true if successful. // returns true if and only if successful.
Mock::VerifyAndClearExpectations(&mock_obj); Mock::VerifyAndClearExpectations(&mock_obj);
... ...
// Verifies and removes the expectations on mock_obj; // Verifies and removes the expectations on mock_obj;
// also removes the default actions set by ON_CALL(); // also removes the default actions set by ON_CALL();
// returns true if successful. // returns true if and only if successful.
Mock::VerifyAndClear(&mock_obj); Mock::VerifyAndClear(&mock_obj);
``` ```

View File

@ -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)` the pointer itself, has a certain property? Well, you can use the `Pointee(m)`
matcher. 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: For example:
```cpp ```cpp
@ -3573,7 +3574,7 @@ class MatcherInterface {
public: public:
virtual ~MatcherInterface(); 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'. // result to 'listener'.
virtual bool MatchAndExplain(T x, MatchResultListener* listener) const = 0; virtual bool MatchAndExplain(T x, MatchResultListener* listener) const = 0;
@ -3727,10 +3728,11 @@ class CardinalityInterface {
public: public:
virtual ~CardinalityInterface(); 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; 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; virtual bool IsSaturatedByCallCount(int call_count) const = 0;
// Describes self to an ostream. // Describes self to an ostream.

View File

@ -99,7 +99,8 @@ struct BuiltInDefaultValueGetter<T, false> {
template <typename T> template <typename T>
class BuiltInDefaultValue { class BuiltInDefaultValue {
public: 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() { static bool Exists() {
return ::std::is_default_constructible<T>::value; return ::std::is_default_constructible<T>::value;
} }
@ -208,7 +209,7 @@ class DefaultValue {
producer_ = nullptr; 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; } static bool IsSet() { return producer_ != nullptr; }
// Returns true if T has a default return value set by the user or there // 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&. // Unsets the default value for type T&.
static void Clear() { address_ = nullptr; } 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; } static bool IsSet() { return address_ != nullptr; }
// Returns true if T has a default return value set by the user or there // Returns true if T has a default return value set by the user or there
@ -375,7 +376,7 @@ class Action {
template <typename Func> template <typename Func>
explicit Action(const Action<Func>& action) : fun_(action.fun_) {} 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; } bool IsDoDefault() const { return fun_ == nullptr; }
// Performs the action. Note that this method is const even though // Performs the action. Note that this method is const even though
@ -395,7 +396,7 @@ class Action {
template <typename G> template <typename G>
friend class Action; 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_; ::std::function<F> fun_;
}; };

View File

@ -70,10 +70,12 @@ class CardinalityInterface {
virtual int ConservativeLowerBound() const { return 0; } virtual int ConservativeLowerBound() const { return 0; }
virtual int ConservativeUpperBound() const { return INT_MAX; } 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; 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; virtual bool IsSaturatedByCallCount(int call_count) const = 0;
// Describes self to an ostream. // Describes self to an ostream.
@ -98,17 +100,19 @@ class GTEST_API_ Cardinality {
int ConservativeLowerBound() const { return impl_->ConservativeLowerBound(); } int ConservativeLowerBound() const { return impl_->ConservativeLowerBound(); }
int ConservativeUpperBound() const { return impl_->ConservativeUpperBound(); } 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 { bool IsSatisfiedByCallCount(int call_count) const {
return impl_->IsSatisfiedByCallCount(call_count); 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 { bool IsSaturatedByCallCount(int call_count) const {
return impl_->IsSaturatedByCallCount(call_count); 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. // cardinality, i.e. exceed the maximum number of allowed calls.
bool IsOverSaturatedByCallCount(int call_count) const { bool IsOverSaturatedByCallCount(int call_count) const {
return impl_->IsSaturatedByCallCount(call_count) && return impl_->IsSaturatedByCallCount(call_count) &&

View File

@ -361,8 +361,8 @@ template <size_t N>
class TuplePrefix { class TuplePrefix {
public: public:
// TuplePrefix<N>::Matches(matcher_tuple, value_tuple) returns true // TuplePrefix<N>::Matches(matcher_tuple, value_tuple) returns true
// if the first N fields of matcher_tuple matches the first N // if and only if the first N fields of matcher_tuple matches
// fields of value_tuple, respectively. // the first N fields of value_tuple, respectively.
template <typename MatcherTuple, typename ValueTuple> template <typename MatcherTuple, typename ValueTuple>
static bool Matches(const MatcherTuple& matcher_tuple, static bool Matches(const MatcherTuple& matcher_tuple,
const ValueTuple& value_tuple) { const ValueTuple& value_tuple) {
@ -420,8 +420,8 @@ class TuplePrefix<0> {
::std::ostream* /* os */) {} ::std::ostream* /* os */) {}
}; };
// TupleMatches(matcher_tuple, value_tuple) returns true if all // TupleMatches(matcher_tuple, value_tuple) returns true if and only if
// matchers in matcher_tuple match the corresponding fields in // all matchers in matcher_tuple match the corresponding fields in
// value_tuple. It is a compiler error if matcher_tuple and // value_tuple. It is a compiler error if matcher_tuple and
// value_tuple have different number of fields or incompatible field // value_tuple have different number of fields or incompatible field
// types. // types.
@ -2534,7 +2534,8 @@ class KeyMatcherImpl : public MatcherInterface<PairType> {
testing::SafeMatcherCast<const KeyType&>(inner_matcher)) { 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, bool MatchAndExplain(PairType key_value,
MatchResultListener* listener) const override { MatchResultListener* listener) const override {
StringMatchResultListener inner_listener; StringMatchResultListener inner_listener;
@ -2616,8 +2617,8 @@ class PairMatcherImpl : public MatcherInterface<PairType> {
second_matcher_.DescribeNegationTo(os); second_matcher_.DescribeNegationTo(os);
} }
// Returns true if 'a_pair.first' matches first_matcher and 'a_pair.second' // Returns true if and only if 'a_pair.first' matches first_matcher and
// matches second_matcher. // 'a_pair.second' matches second_matcher.
bool MatchAndExplain(PairType a_pair, bool MatchAndExplain(PairType a_pair,
MatchResultListener* listener) const override { MatchResultListener* listener) const override {
if (!listener->IsInterested()) { if (!listener->IsInterested()) {
@ -3152,8 +3153,8 @@ class ElementsAreArrayMatcher {
// Given a 2-tuple matcher tm of type Tuple2Matcher and a value second // Given a 2-tuple matcher tm of type Tuple2Matcher and a value second
// of type Second, BoundSecondMatcher<Tuple2Matcher, Second>(tm, // of type Second, BoundSecondMatcher<Tuple2Matcher, Second>(tm,
// second) is a polymorphic matcher that matches a value x if tm // second) is a polymorphic matcher that matches a value x if and only if
// matches tuple (x, second). Useful for implementing // tm matches tuple (x, second). Useful for implementing
// UnorderedPointwise() in terms of UnorderedElementsAreArray(). // UnorderedPointwise() in terms of UnorderedElementsAreArray().
// //
// BoundSecondMatcher is copyable and assignable, as we need to put // BoundSecondMatcher is copyable and assignable, as we need to put
@ -3217,8 +3218,8 @@ class BoundSecondMatcher {
// Given a 2-tuple matcher tm and a value second, // Given a 2-tuple matcher tm and a value second,
// MatcherBindSecond(tm, second) returns a matcher that matches a // MatcherBindSecond(tm, second) returns a matcher that matches a
// value x if tm matches tuple (x, second). Useful for implementing // value x if and only if tm matches tuple (x, second). Useful for
// UnorderedPointwise() in terms of UnorderedElementsAreArray(). // implementing UnorderedPointwise() in terms of UnorderedElementsAreArray().
template <typename Tuple2Matcher, typename Second> template <typename Tuple2Matcher, typename Second>
BoundSecondMatcher<Tuple2Matcher, Second> MatcherBindSecond( BoundSecondMatcher<Tuple2Matcher, Second> MatcherBindSecond(
const Tuple2Matcher& tm, const Second& second) { const Tuple2Matcher& tm, const Second& second) {
@ -3710,7 +3711,7 @@ WhenDynamicCastTo(const Matcher<To>& inner_matcher) {
// Creates a matcher that matches an object whose given field matches // Creates a matcher that matches an object whose given field matches
// 'matcher'. For example, // 'matcher'. For example,
// Field(&Foo::number, Ge(5)) // 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> template <typename Class, typename FieldType, typename FieldMatcher>
inline PolymorphicMatcher< inline PolymorphicMatcher<
internal::FieldMatcher<Class, FieldType> > Field( internal::FieldMatcher<Class, FieldType> > Field(
@ -3737,7 +3738,7 @@ inline PolymorphicMatcher<internal::FieldMatcher<Class, FieldType> > Field(
// Creates a matcher that matches an object whose given property // Creates a matcher that matches an object whose given property
// matches 'matcher'. For example, // matches 'matcher'. For example,
// Property(&Foo::str, StartsWith("hi")) // 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> template <typename Class, typename PropertyType, typename PropertyMatcher>
inline PolymorphicMatcher<internal::PropertyMatcher< inline PolymorphicMatcher<internal::PropertyMatcher<
Class, PropertyType, PropertyType (Class::*)() const> > Class, PropertyType, PropertyType (Class::*)() const> >
@ -3792,11 +3793,10 @@ Property(const std::string& property_name,
property_name, property, MatcherCast<const PropertyType&>(matcher))); property_name, property, MatcherCast<const PropertyType&>(matcher)));
} }
// Creates a matcher that matches an object if the result of applying // Creates a matcher that matches an object if and only if the result of
// a callable to x matches 'matcher'. // applying a callable to x matches 'matcher'. For example,
// For example,
// ResultOf(f, StartsWith("hi")) // 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 // `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 // 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 // no assumptions about how many calls will be made. Any state it keeps must be
@ -4345,7 +4345,7 @@ inline internal::MatcherAsPredicate<M> Matches(M matcher) {
return internal::MatcherAsPredicate<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> template <typename T, typename M>
inline bool Value(const T& value, M matcher) { inline bool Value(const T& value, M matcher) {
return testing::Matches(matcher)(value); return testing::Matches(matcher)(value);
@ -4551,8 +4551,8 @@ PolymorphicMatcher<internal::variant_matcher::VariantMatcher<T> > VariantWith(
// These macros allow using matchers to check values in Google Test // These macros allow using matchers to check values in Google Test
// tests. ASSERT_THAT(value, matcher) and EXPECT_THAT(value, matcher) // tests. ASSERT_THAT(value, matcher) and EXPECT_THAT(value, matcher)
// succeed if the value matches the matcher. If the assertion fails, // succeed if and only if the value matches the matcher. If the assertion
// the value and the description of the matcher will be printed. // fails, the value and the description of the matcher will be printed.
#define ASSERT_THAT(value, matcher) ASSERT_PRED_FORMAT1(\ #define ASSERT_THAT(value, matcher) ASSERT_PRED_FORMAT1(\
::testing::internal::MakePredicateFormatterFromMatcher(matcher), value) ::testing::internal::MakePredicateFormatterFromMatcher(matcher), value)
#define EXPECT_THAT(value, matcher) EXPECT_PRED_FORMAT1(\ #define EXPECT_THAT(value, matcher) EXPECT_PRED_FORMAT1(\

View File

@ -332,7 +332,7 @@ class OnCallSpec : public UntypedOnCallSpecBase {
return *this; 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 { bool Matches(const ArgumentTuple& args) const {
return TupleMatches(matchers_, args) && extra_matcher_.Matches(args); return TupleMatches(matchers_, args) && extra_matcher_.Matches(args);
} }
@ -390,7 +390,7 @@ class GTEST_API_ Mock {
GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex); GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
// Verifies all expectations on the given mock object and clears its // 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. // verification was successful.
static bool VerifyAndClear(void* mock_obj) static bool VerifyAndClear(void* mock_obj)
GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex); 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 // The compiler-generated copy ctor and operator= work exactly as
// intended, so we don't need to define our own. // 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 { bool operator==(const Expectation& rhs) const {
return expectation_base_ == rhs.expectation_base_; return expectation_base_ == rhs.expectation_base_;
} }
@ -598,8 +599,8 @@ class ExpectationSet {
// The compiler-generator ctor and operator= works exactly as // The compiler-generator ctor and operator= works exactly as
// intended, so we don't need to define our own. // intended, so we don't need to define our own.
// Returns true if rhs contains the same set of Expectation objects // Returns true if and only if rhs contains the same set of Expectation
// as this does. // objects as this does.
bool operator==(const ExpectationSet& rhs) const { bool operator==(const ExpectationSet& rhs) const {
return expectations_ == rhs.expectations_; return expectations_ == rhs.expectations_;
} }
@ -760,8 +761,8 @@ class GTEST_API_ ExpectationBase {
// by the subclasses to implement the .Times() clause. // by the subclasses to implement the .Times() clause.
void SpecifyCardinality(const Cardinality& cardinality); void SpecifyCardinality(const Cardinality& cardinality);
// Returns true if the user specified the cardinality explicitly // Returns true if and only if the user specified the cardinality
// using a .Times(). // explicitly using a .Times().
bool cardinality_specified() const { return cardinality_specified_; } bool cardinality_specified() const { return cardinality_specified_; }
// Sets the cardinality of this expectation spec. // Sets the cardinality of this expectation spec.
@ -777,7 +778,7 @@ class GTEST_API_ ExpectationBase {
void RetireAllPreRequisites() void RetireAllPreRequisites()
GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex); 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 bool is_retired() const
GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) { GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
g_gmock_mutex.AssertHeld(); g_gmock_mutex.AssertHeld();
@ -791,28 +792,29 @@ class GTEST_API_ ExpectationBase {
retired_ = true; retired_ = true;
} }
// Returns true if this expectation is satisfied. // Returns true if and only if this expectation is satisfied.
bool IsSatisfied() const bool IsSatisfied() const
GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) { GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
g_gmock_mutex.AssertHeld(); g_gmock_mutex.AssertHeld();
return cardinality().IsSatisfiedByCallCount(call_count_); 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 bool IsSaturated() const
GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) { GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
g_gmock_mutex.AssertHeld(); g_gmock_mutex.AssertHeld();
return cardinality().IsSaturatedByCallCount(call_count_); 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 bool IsOverSaturated() const
GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) { GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
g_gmock_mutex.AssertHeld(); g_gmock_mutex.AssertHeld();
return cardinality().IsOverSaturatedByCallCount(call_count_); 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 bool AllPrerequisitesAreSatisfied() const
GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex); GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex);
@ -855,7 +857,7 @@ class GTEST_API_ ExpectationBase {
const char* file_; // The file that contains the expectation. const char* file_; // The file that contains the expectation.
int line_; // The line number of the expectation. int line_; // The line number of the expectation.
const std::string source_text_; // The EXPECT_CALL(...) source text. 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_; bool cardinality_specified_;
Cardinality cardinality_; // The cardinality of the expectation. Cardinality cardinality_; // The cardinality of the expectation.
// The immediate pre-requisites (i.e. expectations that must be // 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, // This group of fields are the current state of the expectation,
// and can change as the mock function is called. // and can change as the mock function is called.
int call_count_; // How many times this expectation has been invoked. 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_; UntypedActions untyped_actions_;
bool extra_matcher_specified_; bool extra_matcher_specified_;
bool repeated_action_specified_; // True if a WillRepeatedly() was 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 // statement finishes and when the current thread holds
// g_gmock_mutex. // 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 bool Matches(const ArgumentTuple& args) const
GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) { GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
g_gmock_mutex.AssertHeld(); g_gmock_mutex.AssertHeld();
return TupleMatches(matchers_, args) && extra_matcher_.Matches(args); 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 bool ShouldHandleArguments(const ArgumentTuple& args) const
GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) { GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
g_gmock_mutex.AssertHeld(); g_gmock_mutex.AssertHeld();

View File

@ -157,11 +157,11 @@ GMOCK_DECLARE_KIND_(long double, kFloatingPoint);
static_cast< ::testing::internal::TypeKind>( \ static_cast< ::testing::internal::TypeKind>( \
::testing::internal::KindOf<type>::value) ::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) #define GMOCK_IS_SIGNED_(T) (static_cast<T>(-1) < 0)
// LosslessArithmeticConvertibleImpl<kFromKind, From, kToKind, To>::value // 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. // arithmetic type To.
// //
// It's the user's responsibility to ensure that both From and To are // 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> struct LosslessArithmeticConvertibleImpl<kInteger, From, kBool, bool>
: public false_type {}; // NOLINT : public false_type {}; // NOLINT
// Converting an integer to another non-bool integer is lossless if // Converting an integer to another non-bool integer is lossless
// the target type's range encloses the source type's range. // if and only if the target type's range encloses the source type's range.
template <typename From, typename To> template <typename From, typename To>
struct LosslessArithmeticConvertibleImpl<kInteger, From, kInteger, To> struct LosslessArithmeticConvertibleImpl<kInteger, From, kInteger, To>
: public bool_constant< : public bool_constant<
@ -224,14 +224,14 @@ struct LosslessArithmeticConvertibleImpl<kFloatingPoint, From, kInteger, To>
: public false_type {}; // NOLINT : public false_type {}; // NOLINT
// Converting a floating-point to another floating-point is lossless // 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> template <typename From, typename To>
struct LosslessArithmeticConvertibleImpl< struct LosslessArithmeticConvertibleImpl<
kFloatingPoint, From, kFloatingPoint, To> kFloatingPoint, From, kFloatingPoint, To>
: public bool_constant<sizeof(From) <= sizeof(To)> {}; // NOLINT : public bool_constant<sizeof(From) <= sizeof(To)> {}; // NOLINT
// LosslessArithmeticConvertible<From, To>::value is true if arithmetic // LosslessArithmeticConvertible<From, To>::value is true if and only if
// type From can be losslessly converted to arithmetic type To. // 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 // 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 // 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. // No logs are printed.
const char kErrorVerbosity[] = "error"; const char kErrorVerbosity[] = "error";
// Returns true if a log with the given severity is visible according // Returns true if and only if a log with the given severity is visible
// to the --gmock_verbose flag. // according to the --gmock_verbose flag.
GTEST_API_ bool LogIsVisible(LogSeverity severity); 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 >= // specified by the --gmock_verbose flag. If stack_frames_to_skip >=
// 0, also prints the stack trace excluding the top // 0, also prints the stack trace excluding the top
// stack_frames_to_skip frames. In opt mode, any positive // stack_frames_to_skip frames. In opt mode, any positive

View File

@ -123,8 +123,8 @@ GTEST_API_ FailureReporterInterface* GetFailureReporter() {
// Protects global resources (stdout in particular) used by Log(). // Protects global resources (stdout in particular) used by Log().
static GTEST_DEFINE_STATIC_MUTEX_(g_log_mutex); static GTEST_DEFINE_STATIC_MUTEX_(g_log_mutex);
// Returns true if a log with the given severity is visible according // Returns true if and only if a log with the given severity is visible
// to the --gmock_verbose flag. // according to the --gmock_verbose flag.
GTEST_API_ bool LogIsVisible(LogSeverity severity) { GTEST_API_ bool LogIsVisible(LogSeverity severity) {
if (GMOCK_FLAG(verbose) == kInfoVerbosity) { if (GMOCK_FLAG(verbose) == kInfoVerbosity) {
// Always show the log if --gmock_verbose=info. // 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 >= // specified by the --gmock_verbose flag. If stack_frames_to_skip >=
// 0, also prints the stack trace excluding the top // 0, also prints the stack trace excluding the top
// stack_frames_to_skip frames. In opt mode, any positive // stack_frames_to_skip frames. In opt mode, any positive

View File

@ -126,8 +126,8 @@ void ExpectationBase::RetireAllPreRequisites()
} }
} }
// Returns true if all pre-requisites of this expectation have been // Returns true if and only if all pre-requisites of this expectation
// satisfied. // have been satisfied.
bool ExpectationBase::AllPrerequisitesAreSatisfied() const bool ExpectationBase::AllPrerequisitesAreSatisfied() const
GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) { GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
g_gmock_mutex.AssertHeld(); g_gmock_mutex.AssertHeld();
@ -384,7 +384,7 @@ UntypedActionResultHolderBase* UntypedFunctionMockerBase::UntypedInvokeWith(
const CallReaction reaction = const CallReaction reaction =
Mock::GetReactionOnUninterestingCalls(MockObject()); 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 // value. This definition must be kept in sync with
// the behavior of ReportUninterestingCall(). // the behavior of ReportUninterestingCall().
const bool need_to_report_uninteresting_call = const bool need_to_report_uninteresting_call =
@ -435,7 +435,8 @@ UntypedActionResultHolderBase* UntypedFunctionMockerBase::UntypedInvokeWith(
&ss, &why); &ss, &why);
const bool found = untyped_expectation != nullptr; 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() // This definition must be kept in sync with the uses of Expect()
// and Log() in this function. // and Log() in this function.
const bool need_to_report_call = const bool need_to_report_call =
@ -574,7 +575,7 @@ struct MockObjectState {
int first_used_line; int first_used_line;
::std::string first_used_test_suite; ::std::string first_used_test_suite;
::std::string first_used_test; ::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. 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 // 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. // verification was successful.
bool Mock::VerifyAndClear(void* mock_obj) bool Mock::VerifyAndClear(void* mock_obj)
GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) { GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) {

View File

@ -34,8 +34,8 @@
namespace testing { namespace testing {
GMOCK_DEFINE_bool_(catch_leaked_mocks, true, GMOCK_DEFINE_bool_(catch_leaked_mocks, true,
"true if Google Mock should report leaked mock objects " "true if and only if Google Mock should report leaked "
"as failures."); "mock objects as failures.");
GMOCK_DEFINE_string_(verbose, internal::kWarningVerbosity, GMOCK_DEFINE_string_(verbose, internal::kWarningVerbosity,
"Controls how verbose Google Mock's output is." "Controls how verbose Google Mock's output is."

View File

@ -395,12 +395,14 @@ TEST(ExactlyTest, HasCorrectBounds) {
class EvenCardinality : public CardinalityInterface { class EvenCardinality : public CardinalityInterface {
public: 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 { bool IsSatisfiedByCallCount(int call_count) const override {
return (call_count % 2 == 0); 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 { bool IsSaturatedByCallCount(int /* call_count */) const override {
return false; return false;
} }

View File

@ -956,10 +956,9 @@ TEST(TypedEqTest, CanDescribeSelf) {
// Tests that TypedEq<T>(v) has type Matcher<T>. // Tests that TypedEq<T>(v) has type Matcher<T>.
// Type<T>::IsTypeOf(v) compiles if the type of value v is T, where T // Type<T>::IsTypeOf(v) compiles if and only if the type of value v is T, where
// is a "bare" type (i.e. not in the form of const U or U&). If v's // T is a "bare" type (i.e. not in the form of const U or U&). If v's type is
// type is not T, the compiler will generate a message about // not T, the compiler will generate a message about "undefined reference".
// "undefined reference".
template <typename T> template <typename T>
struct Type { struct Type {
static bool IsTypeOf(const T& /* v */) { return true; } static bool IsTypeOf(const T& /* v */) { return true; }
@ -2640,8 +2639,8 @@ class IsGreaterThan {
// For testing Truly(). // For testing Truly().
const int foo = 0; const int foo = 0;
// This predicate returns true if the argument references foo and has // This predicate returns true if and only if the argument references foo and
// a zero value. // has a zero value.
bool ReferencesFooAndIsZero(const int& n) { bool ReferencesFooAndIsZero(const int& n) {
return (&n == &foo) && (n == 0); return (&n == &foo) && (n == 0);
} }
@ -3594,7 +3593,7 @@ class Uncopyable {
GTEST_DISALLOW_COPY_AND_ASSIGN_(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; } bool ValueIsPositive(const Uncopyable& x) { return x.value() > 0; }
MATCHER_P(UncopyableIs, inner_matcher, "") { MATCHER_P(UncopyableIs, inner_matcher, "") {

View File

@ -1952,12 +1952,14 @@ TEST(DeletingMockEarlyTest, Failure2) {
class EvenNumberCardinality : public CardinalityInterface { class EvenNumberCardinality : public CardinalityInterface {
public: 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 { bool IsSatisfiedByCallCount(int call_count) const override {
return call_count % 2 == 0; 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 { bool IsSaturatedByCallCount(int /* call_count */) const override {
return false; return false;
} }

View File

@ -276,20 +276,20 @@ class GTEST_API_ KilledBySignal {
// This macro is used for implementing macros such as // This macro is used for implementing macros such as
// EXPECT_DEATH_IF_SUPPORTED and ASSERT_DEATH_IF_SUPPORTED on systems where // EXPECT_DEATH_IF_SUPPORTED and ASSERT_DEATH_IF_SUPPORTED on systems where
// death tests are not supported. Those macros must compile on such systems // death tests are not supported. Those macros must compile on such systems
// if EXPECT_DEATH and ASSERT_DEATH compile with the same parameters on // if and only if EXPECT_DEATH and ASSERT_DEATH compile with the same parameters
// systems that support death tests. This allows one to write such a macro // on systems that support death tests. This allows one to write such a macro on
// on a system that does not support death tests and be sure that it will // a system that does not support death tests and be sure that it will compile
// compile on a death-test supporting system. It is exposed publicly so that // on a death-test supporting system. It is exposed publicly so that systems
// systems that have death-tests with stricter requirements than // that have death-tests with stricter requirements than GTEST_HAS_DEATH_TEST
// GTEST_HAS_DEATH_TEST can write their own equivalent of // can write their own equivalent of EXPECT_DEATH_IF_SUPPORTED and
// EXPECT_DEATH_IF_SUPPORTED and ASSERT_DEATH_IF_SUPPORTED. // ASSERT_DEATH_IF_SUPPORTED.
// //
// Parameters: // Parameters:
// statement - A statement that a macro such as EXPECT_DEATH would test // statement - A statement that a macro such as EXPECT_DEATH would test
// for program termination. This macro has to make sure this // for program termination. This macro has to make sure this
// statement is compiled but not executed, to ensure that // statement is compiled but not executed, to ensure that
// EXPECT_DEATH_IF_SUPPORTED compiles with a certain // 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 // regex - A regex that a macro such as EXPECT_DEATH would use to test
// the output of statement. This parameter has to be // the output of statement. This parameter has to be
// compiled but not evaluated by this macro, to ensure that // compiled but not evaluated by this macro, to ensure that

View File

@ -96,8 +96,8 @@ class MatchResultListener {
// Returns the underlying ostream. // Returns the underlying ostream.
::std::ostream* stream() { return stream_; } ::std::ostream* stream() { return stream_; }
// Returns true if the listener is interested in an explanation of // Returns true if and only if the listener is interested in an explanation
// the match result. A matcher's MatchAndExplain() method can use // of the match result. A matcher's MatchAndExplain() method can use
// this information to avoid generating the explanation when no one // this information to avoid generating the explanation when no one
// intends to hear it. // intends to hear it.
bool IsInterested() const { return stream_ != nullptr; } bool IsInterested() const { return stream_ != nullptr; }
@ -141,8 +141,8 @@ class MatcherDescriberInterface {
template <typename T> template <typename T>
class MatcherInterface : public MatcherDescriberInterface { class MatcherInterface : public MatcherDescriberInterface {
public: public:
// Returns true if the matcher matches x; also explains the match // Returns true if and only if the matcher matches x; also explains the
// result to 'listener' if necessary (see the next paragraph), in // match result to 'listener' if necessary (see the next paragraph), in
// the form of a non-restrictive relative clause ("which ...", // the form of a non-restrictive relative clause ("which ...",
// "whose ...", etc) that describes x. For example, the // "whose ...", etc) that describes x. For example, the
// MatchAndExplain() method of the Pointee(...) matcher should // MatchAndExplain() method of the Pointee(...) matcher should
@ -258,13 +258,13 @@ class StreamMatchResultListener : public MatchResultListener {
template <typename T> template <typename T>
class MatcherBase { class MatcherBase {
public: public:
// Returns true if the matcher matches x; also explains the match // Returns true if and only if the matcher matches x; also explains the
// result to 'listener'. // match result to 'listener'.
bool MatchAndExplain(const T& x, MatchResultListener* listener) const { bool MatchAndExplain(const T& x, MatchResultListener* listener) const {
return impl_->MatchAndExplain(x, listener); 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 { bool Matches(const T& x) const {
DummyMatchResultListener dummy; DummyMatchResultListener dummy;
return MatchAndExplain(x, &dummy); return MatchAndExplain(x, &dummy);

View File

@ -87,19 +87,19 @@ class GTEST_API_ TestPartResult {
// Gets the message associated with the test part. // Gets the message associated with the test part.
const char* message() const { return message_.c_str(); } 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; } 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; } 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; } 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; } 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(); } bool failed() const { return fatally_failed() || nonfatally_failed(); }
private: private:

View File

@ -308,7 +308,7 @@ class GTEST_API_ AssertionResult {
return *this; return *this;
} }
// Returns true if the assertion succeeded. // Returns true if and only if the assertion succeeded.
operator bool() const { return success_; } // NOLINT operator bool() const { return success_; } // NOLINT
// Returns the assertion's negation. Used with EXPECT/ASSERT_FALSE. // Returns the assertion's negation. Used with EXPECT/ASSERT_FALSE.
@ -432,16 +432,16 @@ class GTEST_API_ Test {
static void SetUpTestCase() {} static void SetUpTestCase() {}
#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_ #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(); 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(); 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(); 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. // non-fatal) failure.
static bool HasFailure() { return HasFatalFailure() || HasNonfatalFailure(); } static bool HasFailure() { return HasFatalFailure() || HasNonfatalFailure(); }
@ -472,8 +472,8 @@ class GTEST_API_ Test {
virtual void TearDown(); virtual void TearDown();
private: private:
// Returns true if the current test has the same fixture class as // Returns true if and only if the current test has the same fixture class
// the first test in the current test suite. // as the first test in the current test suite.
static bool HasSameFixtureClass(); static bool HasSameFixtureClass();
// Runs the test after the test fixture has been set up. // 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. // Returns the number of the test properties.
int test_property_count() const; 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(); } 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; bool Skipped() const;
// Returns true if the test failed. // Returns true if and only if the test failed.
bool Failed() const; bool Failed() const;
// Returns true if the test fatally failed. // Returns true if and only if the test fatally failed.
bool HasFatalFailure() const; 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; bool HasNonfatalFailure() const;
// Returns the elapsed time, in milliseconds. // Returns the elapsed time, in milliseconds.
@ -750,7 +750,7 @@ class GTEST_API_ TestInfo {
// contains the character 'A' or starts with "Foo.". // contains the character 'A' or starts with "Foo.".
bool should_run() const { return should_run_; } 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 { bool is_reportable() const {
// The XML report includes tests matching the filter, excluding those // The XML report includes tests matching the filter, excluding those
// run in other shards. // run in other shards.
@ -808,12 +808,12 @@ class GTEST_API_ TestInfo {
// value-parameterized test. // value-parameterized test.
const std::unique_ptr<const ::std::string> value_param_; const std::unique_ptr<const ::std::string> value_param_;
internal::CodeLocation location_; internal::CodeLocation location_;
const internal::TypeId fixture_class_id_; // ID of the test fixture class const internal::TypeId fixture_class_id_; // ID of the test fixture class
bool should_run_; // True if this test should run bool should_run_; // True if and only if this test should run
bool is_disabled_; // True if this test is disabled bool is_disabled_; // True if and only if this test is disabled
bool matches_filter_; // True if this test matches the bool matches_filter_; // True if this test matches the
// user-specified filter. // user-specified filter.
bool is_in_another_shard_; // Will be run in another shard. bool is_in_another_shard_; // Will be run in another shard.
internal::TestFactoryBase* const factory_; // The factory that creates internal::TestFactoryBase* const factory_; // The factory that creates
// the test object // the test object
@ -885,10 +885,10 @@ class GTEST_API_ TestSuite {
// Gets the number of all tests in this test suite. // Gets the number of all tests in this test suite.
int total_test_count() const; 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(); } 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; } bool Failed() const { return failed_test_count() > 0; }
// Returns the elapsed time, in milliseconds. // 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) { static bool TestPassed(const TestInfo* test_info) {
return test_info->should_run() && test_info->result()->Passed(); 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) { static bool TestSkipped(const TestInfo* test_info) {
return test_info->should_run() && test_info->result()->Skipped(); 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) { static bool TestFailed(const TestInfo* test_info) {
return test_info->should_run() && test_info->result()->Failed(); return test_info->should_run() && test_info->result()->Failed();
} }
// Returns true if the test is disabled and will be reported in the XML // Returns true if and only if the test is disabled and will be reported in
// report. // the XML report.
static bool TestReportableDisabled(const TestInfo* test_info) { static bool TestReportableDisabled(const TestInfo* test_info) {
return test_info->is_reportable() && test_info->is_disabled_; 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) { static bool TestDisabled(const TestInfo* test_info) {
return test_info->is_disabled_; 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) { static bool TestReportable(const TestInfo* test_info) {
return test_info->is_reportable(); return test_info->is_reportable();
} }
@ -1014,7 +1014,7 @@ class GTEST_API_ TestSuite {
internal::SetUpTestSuiteFunc set_up_tc_; internal::SetUpTestSuiteFunc set_up_tc_;
// Pointer to the function that tears down the test suite. // Pointer to the function that tears down the test suite.
internal::TearDownTestSuiteFunc tear_down_tc_; 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_; bool should_run_;
// The start time, in milliseconds since UNIX Epoch. // The start time, in milliseconds since UNIX Epoch.
TimeInMillis start_timestamp_; TimeInMillis start_timestamp_;
@ -1349,11 +1349,12 @@ class GTEST_API_ UnitTest {
// Gets the elapsed time, in milliseconds. // Gets the elapsed time, in milliseconds.
TimeInMillis elapsed_time() const; 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; bool Passed() const;
// Returns true if the unit test failed (i.e. some test suite failed // Returns true if and only if the unit test failed (i.e. some test suite
// or something outside of all tests failed). // failed or something outside of all tests failed).
bool Failed() const; bool Failed() const;
// Gets the i-th test suite among all the test suites. i can range from 0 to // Gets the i-th test suite among all the test suites. i can range from 0 to
@ -2267,8 +2268,8 @@ class GTEST_API_ ScopedTrace {
// Compile-time assertion for type equality. // Compile-time assertion for type equality.
// StaticAssertTypeEq<type1, type2>() compiles if type1 and type2 are // StaticAssertTypeEq<type1, type2>() compiles if and only if type1 and type2
// the same type. The value it returns is not interesting. // are the same type. The value it returns is not interesting.
// //
// Instead of making StaticAssertTypeEq a class template, we make it a // Instead of making StaticAssertTypeEq a class template, we make it a
// function template that invokes a helper class template. This // function template that invokes a helper class template. This

View File

@ -110,7 +110,7 @@ class GTEST_API_ FilePath {
const FilePath& base_name, const FilePath& base_name,
const char* extension); const char* extension);
// Returns true if the path is "". // Returns true if and only if the path is "".
bool IsEmpty() const { return pathname_.empty(); } bool IsEmpty() const { return pathname_.empty(); }
// If input name has a trailing separator character, removes it and returns // If input name has a trailing separator character, removes it and returns

View File

@ -189,7 +189,7 @@ GTEST_API_ std::string DiffStrings(const std::string& left,
// expected_value: "5" // expected_value: "5"
// actual_value: "6" // 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 // *_STRCASEEQ*. When it's true, the string " (ignoring case)" will
// be inserted into the message. // be inserted into the message.
GTEST_API_ AssertionResult EqFailure(const char* expected_expression, GTEST_API_ AssertionResult EqFailure(const char* expected_expression,
@ -318,15 +318,15 @@ class FloatingPoint {
// Returns the sign bit of this number. // Returns the sign bit of this number.
Bits sign_bit() const { return kSignBitMask & u_.bits_; } 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 { bool is_nan() const {
// It's a NAN if the exponent bits are all ones and the fraction // It's a NAN if the exponent bits are all ones and the fraction
// bits are not entirely zeros. // bits are not entirely zeros.
return (exponent_bits() == kExponentBitMask) && (fraction_bits() != 0); return (exponent_bits() == kExponentBitMask) && (fraction_bits() != 0);
} }
// Returns true if this number is at most kMaxUlps ULP's away from // Returns true if and only if this number is at most kMaxUlps ULP's away
// rhs. In particular, this function: // from rhs. In particular, this function:
// //
// - returns false if either number is (or both are) NAN. // - returns false if either number is (or both are) NAN.
// - treats really large numbers as almost equal to infinity. // - treats really large numbers as almost equal to infinity.
@ -848,7 +848,7 @@ class GTEST_API_ Random {
}; };
// Defining a variable of type CompileAssertTypesEqual<T1, T2> will cause a // Defining a variable of type CompileAssertTypesEqual<T1, T2> will cause a
// compiler error if T1 and T2 are different types. // compiler error if and only if T1 and T2 are different types.
template <typename T1, typename T2> template <typename T1, typename T2>
struct CompileAssertTypesEqual; struct CompileAssertTypesEqual;
@ -895,7 +895,7 @@ struct RemoveConst<const T[N]> {
GTEST_REMOVE_CONST_(GTEST_REMOVE_REFERENCE_(T)) GTEST_REMOVE_CONST_(GTEST_REMOVE_REFERENCE_(T))
// IsAProtocolMessage<T>::value is a compile-time bool constant that's // 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> template <typename T>
struct IsAProtocolMessage struct IsAProtocolMessage
: public bool_constant< : public bool_constant<

View File

@ -362,7 +362,8 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
# include <android/api-level.h> // NOLINT # include <android/api-level.h> // NOLINT
#endif #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 #ifndef GTEST_HAS_POSIX_RE
# if GTEST_OS_LINUX_ANDROID # if GTEST_OS_LINUX_ANDROID
// On Android, <regex.h> is only available starting with Gingerbread. // On Android, <regex.h> is only available starting with Gingerbread.
@ -403,7 +404,7 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
// The user didn't tell us whether exceptions are enabled, so we need // The user didn't tell us whether exceptions are enabled, so we need
// to figure it out. // to figure it out.
# if defined(_MSC_VER) && defined(_CPPUNWIND) # 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 # define GTEST_HAS_EXCEPTIONS 1
# elif defined(__BORLANDC__) # elif defined(__BORLANDC__)
// C++Builder's implementation of the STL uses the _HAS_EXCEPTIONS // C++Builder's implementation of the STL uses the _HAS_EXCEPTIONS
@ -414,16 +415,17 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
# endif // _HAS_EXCEPTIONS # endif // _HAS_EXCEPTIONS
# define GTEST_HAS_EXCEPTIONS _HAS_EXCEPTIONS # define GTEST_HAS_EXCEPTIONS _HAS_EXCEPTIONS
# elif defined(__clang__) # elif defined(__clang__)
// clang defines __EXCEPTIONS if exceptions are enabled before clang 220714, // clang defines __EXCEPTIONS if and only if exceptions are enabled before clang
// but if cleanups are enabled after that. In Obj-C++ files, there can be // 220714, but if and only if cleanups are enabled after that. In Obj-C++ files,
// cleanups for ObjC exceptions which also need cleanups, even if C++ exceptions // there can be cleanups for ObjC exceptions which also need cleanups, even if
// are disabled. clang has __has_feature(cxx_exceptions) which checks for C++ // C++ exceptions are disabled. clang has __has_feature(cxx_exceptions) which
// exceptions starting at clang r206352, but which checked for cleanups prior to // checks for C++ exceptions starting at clang r206352, but which checked for
// that. To reliably check for C++ exception availability with clang, check for // cleanups prior to that. To reliably check for C++ exception availability with
// clang, check for
// __EXCEPTIONS && __has_feature(cxx_exceptions). // __EXCEPTIONS && __has_feature(cxx_exceptions).
# define GTEST_HAS_EXCEPTIONS (__EXCEPTIONS && __has_feature(cxx_exceptions)) # define GTEST_HAS_EXCEPTIONS (__EXCEPTIONS && __has_feature(cxx_exceptions))
# elif defined(__GNUC__) && __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 # define GTEST_HAS_EXCEPTIONS 1
# elif defined(__SUNPRO_CC) # elif defined(__SUNPRO_CC)
// Sun Pro CC supports exceptions. However, there is no compile-time way of // Sun Pro CC supports exceptions. However, there is no compile-time way of
@ -431,7 +433,7 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
// they are enabled unless the user tells us otherwise. // they are enabled unless the user tells us otherwise.
# define GTEST_HAS_EXCEPTIONS 1 # define GTEST_HAS_EXCEPTIONS 1
# elif defined(__IBMCPP__) && __EXCEPTIONS # 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 # define GTEST_HAS_EXCEPTIONS 1
# elif defined(__HP_aCC) # elif defined(__HP_aCC)
// Exception handling is in effect by default in HP aCC compiler. It has to // Exception handling is in effect by default in HP aCC compiler. It has to
@ -472,13 +474,14 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
# ifdef _MSC_VER # 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 # define GTEST_HAS_RTTI 1
# else # else
# define GTEST_HAS_RTTI 0 # define GTEST_HAS_RTTI 0
# endif # 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__) # elif defined(__GNUC__)
# ifdef __GXX_RTTI # ifdef __GXX_RTTI
@ -899,9 +902,9 @@ class GTEST_API_ RE {
// Returns the string representation of the regex. // Returns the string representation of the regex.
const char* pattern() const { return pattern_; } const char* pattern() const { return pattern_; }
// FullMatch(str, re) returns true if regular expression re matches // FullMatch(str, re) returns true if and only if regular expression re
// the entire str. // matches the entire str.
// PartialMatch(str, re) returns true if regular expression re // PartialMatch(str, re) returns true if and only if regular expression re
// matches a substring of str (including str itself). // matches a substring of str (including str itself).
static bool FullMatch(const ::std::string& str, const RE& re) { static bool FullMatch(const ::std::string& str, const RE& re) {
return FullMatch(str.c_str(), re); return FullMatch(str.c_str(), re);
@ -1256,7 +1259,8 @@ class GTEST_API_ AutoHandle {
void Reset(Handle handle); void Reset(Handle handle);
private: 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; bool IsCloseable() const;
Handle handle_; Handle handle_;
@ -1358,7 +1362,8 @@ class ThreadWithParam : public ThreadWithParamBase {
// When non-NULL, used to block execution until the controller thread // When non-NULL, used to block execution until the controller thread
// notifies. // notifies.
Notification* const thread_can_start_; 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. pthread_t thread_; // The native thread object.
GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadWithParam); GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadWithParam);

View File

@ -94,7 +94,8 @@ class GTEST_API_ String {
static const char* Utf16ToAnsi(LPCWSTR utf16_str); static const char* Utf16ToAnsi(LPCWSTR utf16_str);
#endif #endif
// Compares two C strings. Returns true if they have the same content. // Compares two C strings. Returns true if and only if they have the same
// content.
// //
// Unlike strcmp(), this function can handle NULL argument(s). A // Unlike strcmp(), this function can handle NULL argument(s). A
// NULL C string is considered different to any non-NULL C string, // NULL C string is considered different to any non-NULL C string,
@ -107,16 +108,16 @@ class GTEST_API_ String {
// returned. // returned.
static std::string ShowWideCString(const wchar_t* wide_c_str); static std::string ShowWideCString(const wchar_t* wide_c_str);
// Compares two wide C strings. Returns true if they have the same // Compares two wide C strings. Returns true if and only if they have the
// content. // same content.
// //
// Unlike wcscmp(), this function can handle NULL argument(s). A // Unlike wcscmp(), this function can handle NULL argument(s). A
// NULL C string is considered different to any non-NULL C string, // NULL C string is considered different to any non-NULL C string,
// including the empty string. // including the empty string.
static bool WideCStringEquals(const wchar_t* lhs, const wchar_t* rhs); static bool WideCStringEquals(const wchar_t* lhs, const wchar_t* rhs);
// Compares two C strings, ignoring case. Returns true if they // Compares two C strings, ignoring case. Returns true if and only if
// have the same content. // they have the same content.
// //
// Unlike strcasecmp(), this function can handle NULL argument(s). // Unlike strcasecmp(), this function can handle NULL argument(s).
// A NULL C string is considered different to any non-NULL C string, // A NULL C string is considered different to any non-NULL C string,
@ -124,8 +125,8 @@ class GTEST_API_ String {
static bool CaseInsensitiveCStringEquals(const char* lhs, static bool CaseInsensitiveCStringEquals(const char* lhs,
const char* rhs); const char* rhs);
// Compares two wide C strings, ignoring case. Returns true if they // Compares two wide C strings, ignoring case. Returns true if and only if
// have the same content. // they have the same content.
// //
// Unlike wcscasecmp(), this function can handle NULL argument(s). // Unlike wcscasecmp(), this function can handle NULL argument(s).
// A NULL C string is considered different to any non-NULL wide C string, // A NULL C string is considered different to any non-NULL wide C string,
@ -139,8 +140,8 @@ class GTEST_API_ String {
static bool CaseInsensitiveWideCStringEquals(const wchar_t* lhs, static bool CaseInsensitiveWideCStringEquals(const wchar_t* lhs,
const wchar_t* rhs); const wchar_t* rhs);
// Returns true if the given string ends with the given suffix, ignoring // Returns true if and only if the given string ends with the given suffix,
// case. Any string is considered to end with an empty suffix. // ignoring case. Any string is considered to end with an empty suffix.
static bool EndsWithCaseInsensitive( static bool EndsWithCaseInsensitive(
const std::string& str, const std::string& suffix); const std::string& str, const std::string& suffix);

View File

@ -43,7 +43,7 @@ class PrimeTable {
public: public:
virtual ~PrimeTable() {} virtual ~PrimeTable() {}
// Returns true if n is a prime number. // Returns true if and only if n is a prime number.
virtual bool IsPrime(int n) const = 0; virtual bool IsPrime(int n) const = 0;
// Returns the smallest prime number greater than p; or returns -1 // Returns the smallest prime number greater than p; or returns -1

View File

@ -41,7 +41,7 @@ int Factorial(int n) {
return result; return result;
} }
// Returns true if n is a prime number. // Returns true if and only if n is a prime number.
bool IsPrime(int n) { bool IsPrime(int n) {
// Trivial case 1: small numbers // Trivial case 1: small numbers
if (n <= 1) return false; if (n <= 1) return false;

View File

@ -35,7 +35,7 @@
// Returns n! (the factorial of n). For negative n, n! is defined to be 1. // Returns n! (the factorial of n). For negative n, n! is defined to be 1.
int Factorial(int n); int Factorial(int n);
// Returns true if n is a prime number. // Returns true if and only if n is a prime number.
bool IsPrime(int n); bool IsPrime(int n);
#endif // GTEST_SAMPLES_SAMPLE1_H_ #endif // GTEST_SAMPLES_SAMPLE1_H_

View File

@ -122,8 +122,8 @@ GTEST_DEFINE_string_(
"Indicates the file, line number, temporal index of " "Indicates the file, line number, temporal index of "
"the single death test to run, and a file descriptor to " "the single death test to run, and a file descriptor to "
"which a success code may be sent, all separated by " "which a success code may be sent, all separated by "
"the '|' characters. This flag is specified if and only if the current " "the '|' characters. This flag is specified if and only if the "
"process is a sub-process launched for running a thread-safe " "current process is a sub-process launched for running a thread-safe "
"death test. FOR INTERNAL USE ONLY."); "death test. FOR INTERNAL USE ONLY.");
} // namespace internal } // namespace internal
@ -563,8 +563,8 @@ static ::std::string FormatDeathTestOutput(const ::std::string& output) {
// status_ok: true if exit_status is acceptable in the context of // status_ok: true if exit_status is acceptable in the context of
// this particular death test, which fails if it is false // this particular death test, which fails if it is false
// //
// Returns true if all of the above conditions are met. Otherwise, the // Returns true if and only if all of the above conditions are met. Otherwise,
// first failing condition, in the order given above, is the one that is // the first failing condition, in the order given above, is the one that is
// reported. Also sets the last death test message string. // reported. Also sets the last death test message string.
bool DeathTestImpl::Passed(bool status_ok) { bool DeathTestImpl::Passed(bool status_ok) {
if (!spawned()) if (!spawned())

View File

@ -99,14 +99,14 @@ const char kFlagfileFlag[] = "flagfile";
// A valid random seed must be in [1, kMaxRandomSeed]. // A valid random seed must be in [1, kMaxRandomSeed].
const int kMaxRandomSeed = 99999; const int kMaxRandomSeed = 99999;
// g_help_flag is true if the --help flag or an equivalent form is // g_help_flag is true if and only if the --help flag or an equivalent form
// specified on the command line. // is specified on the command line.
GTEST_API_ extern bool g_help_flag; GTEST_API_ extern bool g_help_flag;
// Returns the current time in milliseconds. // Returns the current time in milliseconds.
GTEST_API_ TimeInMillis GetTimeInMillis(); GTEST_API_ TimeInMillis GetTimeInMillis();
// Returns true if Google Test should use colors in the output. // Returns true if and only if Google Test should use colors in the output.
GTEST_API_ bool ShouldUseColor(bool stdout_is_tty); GTEST_API_ bool ShouldUseColor(bool stdout_is_tty);
// Formats the given time in milliseconds as seconds. // Formats the given time in milliseconds as seconds.
@ -266,8 +266,8 @@ GTEST_API_ bool ShouldShard(const char* total_shards_str,
GTEST_API_ Int32 Int32FromEnvOrDie(const char* env_var, Int32 default_val); GTEST_API_ Int32 Int32FromEnvOrDie(const char* env_var, Int32 default_val);
// Given the total number of shards, the shard index, and the test id, // Given the total number of shards, the shard index, and the test id,
// returns true if the test should be run on this shard. The test id is // returns true if and only if the test should be run on this shard. The test id
// some arbitrary but unique non-negative integer assigned to each test // is some arbitrary but unique non-negative integer assigned to each test
// method. Assumes that 0 <= shard_index < total_shards. // method. Assumes that 0 <= shard_index < total_shards.
GTEST_API_ bool ShouldRunTestOnShard( GTEST_API_ bool ShouldRunTestOnShard(
int total_shards, int shard_index, int test_id); int total_shards, int shard_index, int test_id);
@ -352,7 +352,7 @@ class TestPropertyKeyIs {
// TestPropertyKeyIs has NO default constructor. // TestPropertyKeyIs has NO default constructor.
explicit TestPropertyKeyIs(const std::string& key) : key_(key) {} explicit TestPropertyKeyIs(const std::string& key) : key_(key) {}
// Returns true if the test name of test property matches on key_. // Returns true if and only if the test name of test property matches on key_.
bool operator()(const TestProperty& test_property) const { bool operator()(const TestProperty& test_property) const {
return test_property.key() == key_; return test_property.key() == key_;
} }
@ -385,15 +385,15 @@ class GTEST_API_ UnitTestOptions {
// Functions for processing the gtest_filter flag. // Functions for processing the gtest_filter flag.
// Returns true if the wildcard pattern matches the string. The // Returns true if and only if the wildcard pattern matches the string.
// first ':' or '\0' character in pattern marks the end of it. // The first ':' or '\0' character in pattern marks the end of it.
// //
// This recursive algorithm isn't very efficient, but is clear and // This recursive algorithm isn't very efficient, but is clear and
// works well enough for matching test names, which are short. // works well enough for matching test names, which are short.
static bool PatternMatchesString(const char *pattern, const char *str); static bool PatternMatchesString(const char *pattern, const char *str);
// Returns true if the user-specified filter matches the test suite // Returns true if and only if the user-specified filter matches the test
// name and the test name. // suite name and the test name.
static bool FilterMatchesTest(const std::string& test_suite_name, static bool FilterMatchesTest(const std::string& test_suite_name,
const std::string& test_name); const std::string& test_name);
@ -577,11 +577,12 @@ class GTEST_API_ UnitTestImpl {
// Gets the elapsed time, in milliseconds. // Gets the elapsed time, in milliseconds.
TimeInMillis elapsed_time() const { return elapsed_time_; } TimeInMillis elapsed_time() const { return elapsed_time_; }
// 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 { return !Failed(); } bool Passed() const { return !Failed(); }
// Returns true if the unit test failed (i.e. some test suite failed // Returns true if and only if the unit test failed (i.e. some test suite
// or something outside of all tests failed). // failed or something outside of all tests failed).
bool Failed() const { bool Failed() const {
return failed_test_suite_count() > 0 || ad_hoc_test_result()->Failed(); return failed_test_suite_count() > 0 || ad_hoc_test_result()->Failed();
} }
@ -911,7 +912,7 @@ class GTEST_API_ UnitTestImpl {
// desired. // desired.
OsStackTraceGetterInterface* os_stack_trace_getter_; OsStackTraceGetterInterface* os_stack_trace_getter_;
// True if PostFlagParsingInit() has been called. // True if and only if PostFlagParsingInit() has been called.
bool post_flag_parse_init_performed_; bool post_flag_parse_init_performed_;
// The random number seed used at the beginning of the test run. // The random number seed used at the beginning of the test run.

View File

@ -715,7 +715,7 @@ RE::~RE() {
free(const_cast<char*>(pattern_)); free(const_cast<char*>(pattern_));
} }
// Returns true if regular expression re matches the entire str. // Returns true if and only if regular expression re matches the entire str.
bool RE::FullMatch(const char* str, const RE& re) { bool RE::FullMatch(const char* str, const RE& re) {
if (!re.is_valid_) return false; if (!re.is_valid_) return false;
@ -723,8 +723,8 @@ bool RE::FullMatch(const char* str, const RE& re) {
return regexec(&re.full_regex_, str, 1, &match, 0) == 0; return regexec(&re.full_regex_, str, 1, &match, 0) == 0;
} }
// Returns true if regular expression re matches a substring of str // Returns true if and only if regular expression re matches a substring of
// (including str itself). // str (including str itself).
bool RE::PartialMatch(const char* str, const RE& re) { bool RE::PartialMatch(const char* str, const RE& re) {
if (!re.is_valid_) return false; if (!re.is_valid_) return false;
@ -764,14 +764,14 @@ void RE::Init(const char* regex) {
#elif GTEST_USES_SIMPLE_RE #elif GTEST_USES_SIMPLE_RE
// Returns true if ch appears anywhere in str (excluding the // Returns true if and only if ch appears anywhere in str (excluding the
// terminating '\0' character). // terminating '\0' character).
bool IsInSet(char ch, const char* str) { bool IsInSet(char ch, const char* str) {
return ch != '\0' && strchr(str, ch) != nullptr; return ch != '\0' && strchr(str, ch) != nullptr;
} }
// Returns true if ch belongs to the given classification. Unlike // Returns true if and only if ch belongs to the given classification.
// similar functions in <ctype.h>, these aren't affected by the // Unlike similar functions in <ctype.h>, these aren't affected by the
// current locale. // current locale.
bool IsAsciiDigit(char ch) { return '0' <= ch && ch <= '9'; } bool IsAsciiDigit(char ch) { return '0' <= ch && ch <= '9'; }
bool IsAsciiPunct(char ch) { bool IsAsciiPunct(char ch) {
@ -784,13 +784,13 @@ bool IsAsciiWordChar(char ch) {
('0' <= ch && ch <= '9') || ch == '_'; ('0' <= ch && ch <= '9') || ch == '_';
} }
// Returns true if "\\c" is a supported escape sequence. // Returns true if and only if "\\c" is a supported escape sequence.
bool IsValidEscape(char c) { bool IsValidEscape(char c) {
return (IsAsciiPunct(c) || IsInSet(c, "dDfnrsStvwW")); return (IsAsciiPunct(c) || IsInSet(c, "dDfnrsStvwW"));
} }
// Returns true if the given atom (specified by escaped and pattern) // Returns true if and only if the given atom (specified by escaped and
// matches ch. The result is undefined if the atom is invalid. // pattern) matches ch. The result is undefined if the atom is invalid.
bool AtomMatchesChar(bool escaped, char pattern_char, char ch) { bool AtomMatchesChar(bool escaped, char pattern_char, char ch) {
if (escaped) { // "\\p" where p is pattern_char. if (escaped) { // "\\p" where p is pattern_char.
switch (pattern_char) { switch (pattern_char) {
@ -828,7 +828,7 @@ bool ValidateRegex(const char* regex) {
bool is_valid = true; bool is_valid = true;
// True if ?, *, or + can follow the previous atom. // True if and only if ?, *, or + can follow the previous atom.
bool prev_repeatable = false; bool prev_repeatable = false;
for (int i = 0; regex[i]; i++) { for (int i = 0; regex[i]; i++) {
if (regex[i] == '\\') { // An escape sequence if (regex[i] == '\\') { // An escape sequence
@ -904,8 +904,8 @@ bool MatchRepetitionAndRegexAtHead(
return false; return false;
} }
// Returns true if regex matches a prefix of str. regex must be a // Returns true if and only if regex matches a prefix of str. regex must
// valid simple regular expression and not start with "^", or the // be a valid simple regular expression and not start with "^", or the
// result is undefined. // result is undefined.
bool MatchRegexAtHead(const char* regex, const char* str) { bool MatchRegexAtHead(const char* regex, const char* str) {
if (*regex == '\0') // An empty regex matches a prefix of anything. if (*regex == '\0') // An empty regex matches a prefix of anything.
@ -935,8 +935,8 @@ bool MatchRegexAtHead(const char* regex, const char* str) {
} }
} }
// Returns true if regex matches any substring of str. regex must be // Returns true if and only if regex matches any substring of str. regex must
// a valid simple regular expression, or the result is undefined. // be a valid simple regular expression, or the result is undefined.
// //
// The algorithm is recursive, but the recursion depth doesn't exceed // The algorithm is recursive, but the recursion depth doesn't exceed
// the regex length, so we won't need to worry about running out of // the regex length, so we won't need to worry about running out of
@ -964,13 +964,13 @@ RE::~RE() {
free(const_cast<char*>(full_pattern_)); free(const_cast<char*>(full_pattern_));
} }
// Returns true if regular expression re matches the entire str. // Returns true if and only if regular expression re matches the entire str.
bool RE::FullMatch(const char* str, const RE& re) { bool RE::FullMatch(const char* str, const RE& re) {
return re.is_valid_ && MatchRegexAnywhere(re.full_pattern_, str); return re.is_valid_ && MatchRegexAnywhere(re.full_pattern_, str);
} }
// Returns true if regular expression re matches a substring of str // Returns true if and only if regular expression re matches a substring of
// (including str itself). // str (including str itself).
bool RE::PartialMatch(const char* str, const RE& re) { bool RE::PartialMatch(const char* str, const RE& re) {
return re.is_valid_ && MatchRegexAnywhere(re.pattern_, str); return re.is_valid_ && MatchRegexAnywhere(re.pattern_, str);
} }
@ -1330,7 +1330,7 @@ bool ParseInt32(const Message& src_text, const char* str, Int32* value) {
// Reads and returns the Boolean environment variable corresponding to // Reads and returns the Boolean environment variable corresponding to
// the given flag; if it's not set, returns default_value. // the given flag; if it's not set, returns default_value.
// //
// The value is considered true if it's not "0". // The value is considered true if and only if it's not "0".
bool BoolFromGTestEnv(const char* flag, bool default_value) { bool BoolFromGTestEnv(const char* flag, bool default_value) {
#if defined(GTEST_GET_BOOL_FROM_ENV_) #if defined(GTEST_GET_BOOL_FROM_ENV_)
return GTEST_GET_BOOL_FROM_ENV_(flag, default_value); return GTEST_GET_BOOL_FROM_ENV_(flag, default_value);

View File

@ -177,8 +177,8 @@ namespace internal {
// stack trace. // stack trace.
const char kStackTraceMarker[] = "\nStack trace:\n"; const char kStackTraceMarker[] = "\nStack trace:\n";
// g_help_flag is true if the --help flag or an equivalent form is // g_help_flag is true if and only if the --help flag or an equivalent form
// specified on the command line. // is specified on the command line.
bool g_help_flag = false; bool g_help_flag = false;
// Utilty function to Open File for Writing // Utilty function to Open File for Writing
@ -217,12 +217,13 @@ GTEST_DEFINE_bool_(
GTEST_DEFINE_bool_( GTEST_DEFINE_bool_(
break_on_failure, break_on_failure,
internal::BoolFromGTestEnv("break_on_failure", false), internal::BoolFromGTestEnv("break_on_failure", false),
"True if a failed assertion should be a debugger break-point."); "True if and only if a failed assertion should be a debugger "
"break-point.");
GTEST_DEFINE_bool_( GTEST_DEFINE_bool_(
catch_exceptions, catch_exceptions,
internal::BoolFromGTestEnv("catch_exceptions", true), internal::BoolFromGTestEnv("catch_exceptions", true),
"True if " GTEST_NAME_ "True if and only if " GTEST_NAME_
" should catch exceptions and treat them as test failures."); " should catch exceptions and treat them as test failures.");
GTEST_DEFINE_string_( GTEST_DEFINE_string_(
@ -273,13 +274,13 @@ GTEST_DEFINE_string_(
GTEST_DEFINE_bool_( GTEST_DEFINE_bool_(
print_time, print_time,
internal::BoolFromGTestEnv("print_time", true), internal::BoolFromGTestEnv("print_time", true),
"True if " GTEST_NAME_ "True if and only if " GTEST_NAME_
" should display elapsed time in text output."); " should display elapsed time in text output.");
GTEST_DEFINE_bool_( GTEST_DEFINE_bool_(
print_utf8, print_utf8,
internal::BoolFromGTestEnv("print_utf8", true), internal::BoolFromGTestEnv("print_utf8", true),
"True if " GTEST_NAME_ "True if and only if " GTEST_NAME_
" prints UTF8 characters as text."); " prints UTF8 characters as text.");
GTEST_DEFINE_int32_( GTEST_DEFINE_int32_(
@ -296,13 +297,13 @@ GTEST_DEFINE_int32_(
GTEST_DEFINE_bool_( GTEST_DEFINE_bool_(
show_internal_stack_frames, false, show_internal_stack_frames, false,
"True if " GTEST_NAME_ " should include internal stack frames when " "True if and only if " GTEST_NAME_ " should include internal stack frames when "
"printing test failure stack traces."); "printing test failure stack traces.");
GTEST_DEFINE_bool_( GTEST_DEFINE_bool_(
shuffle, shuffle,
internal::BoolFromGTestEnv("shuffle", false), internal::BoolFromGTestEnv("shuffle", false),
"True if " GTEST_NAME_ "True if and only if " GTEST_NAME_
" should randomize tests' order on every run."); " should randomize tests' order on every run.");
GTEST_DEFINE_int32_( GTEST_DEFINE_int32_(
@ -354,7 +355,7 @@ UInt32 Random::Generate(UInt32 range) {
return state_ % range; return state_ % range;
} }
// GTestIsInitialized() returns true if the user has initialized // GTestIsInitialized() returns true if and only if the user has initialized
// Google Test. Useful for catching the user mistake of not initializing // Google Test. Useful for catching the user mistake of not initializing
// Google Test before calling RUN_ALL_TESTS(). // Google Test before calling RUN_ALL_TESTS().
static bool GTestIsInitialized() { return GetArgvs().size() > 0; } static bool GTestIsInitialized() { return GetArgvs().size() > 0; }
@ -371,18 +372,18 @@ static int SumOverTestSuiteList(const std::vector<TestSuite*>& case_list,
return sum; return sum;
} }
// Returns true if the test suite passed. // Returns true if and only if the test suite passed.
static bool TestSuitePassed(const TestSuite* test_suite) { static bool TestSuitePassed(const TestSuite* test_suite) {
return test_suite->should_run() && test_suite->Passed(); return test_suite->should_run() && test_suite->Passed();
} }
// Returns true if the test suite failed. // Returns true if and only if the test suite failed.
static bool TestSuiteFailed(const TestSuite* test_suite) { static bool TestSuiteFailed(const TestSuite* test_suite) {
return test_suite->should_run() && test_suite->Failed(); return test_suite->should_run() && test_suite->Failed();
} }
// Returns true if test_suite contains at least one test that should // Returns true if and only if test_suite contains at least one test that
// run. // should run.
static bool ShouldRunTestSuite(const TestSuite* test_suite) { static bool ShouldRunTestSuite(const TestSuite* test_suite) {
return test_suite->should_run(); return test_suite->should_run();
} }
@ -482,8 +483,8 @@ std::string UnitTestOptions::GetAbsolutePathToOutputFile() {
return result.string(); return result.string();
} }
// Returns true if the wildcard pattern matches the string. The // Returns true if and only if the wildcard pattern matches the string.
// first ':' or '\0' character in pattern marks the end of it. // The first ':' or '\0' character in pattern marks the end of it.
// //
// This recursive algorithm isn't very efficient, but is clear and // This recursive algorithm isn't very efficient, but is clear and
// works well enough for matching test names, which are short. // works well enough for matching test names, which are short.
@ -525,8 +526,8 @@ bool UnitTestOptions::MatchesFilter(
} }
} }
// Returns true if the user-specified filter matches the test suite // Returns true if and only if the user-specified filter matches the test
// name and the test name. // suite name and the test name.
bool UnitTestOptions::FilterMatchesTest(const std::string& test_suite_name, bool UnitTestOptions::FilterMatchesTest(const std::string& test_suite_name,
const std::string& test_name) { const std::string& test_name) {
const std::string& full_name = test_suite_name + "." + test_name.c_str(); const std::string& full_name = test_suite_name + "." + test_name.c_str();
@ -910,7 +911,8 @@ const char* String::Utf16ToAnsi(LPCWSTR utf16_str) {
#endif // GTEST_OS_WINDOWS_MOBILE #endif // GTEST_OS_WINDOWS_MOBILE
// Compares two C strings. Returns true if they have the same content. // Compares two C strings. Returns true if and only if they have the same
// content.
// //
// Unlike strcmp(), this function can handle NULL argument(s). A NULL // Unlike strcmp(), this function can handle NULL argument(s). A NULL
// C string is considered different to any non-NULL C string, // C string is considered different to any non-NULL C string,
@ -1320,7 +1322,7 @@ std::vector<std::string> SplitEscapedString(const std::string& str) {
// lhs_value: "5" // lhs_value: "5"
// rhs_value: "6" // rhs_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 // *_STRCASEEQ*. When it's true, the string "Ignoring case" will
// be inserted into the message. // be inserted into the message.
AssertionResult EqFailure(const char* lhs_expression, AssertionResult EqFailure(const char* lhs_expression,
@ -1563,9 +1565,9 @@ namespace {
// Helper functions for implementing IsSubString() and IsNotSubstring(). // Helper functions for implementing IsSubString() and IsNotSubstring().
// This group of overloaded functions return true if needle is a // This group of overloaded functions return true if and only if needle
// substring of haystack. NULL is considered a substring of itself // is a substring of haystack. NULL is considered a substring of
// only. // itself only.
bool IsSubstringPred(const char* needle, const char* haystack) { bool IsSubstringPred(const char* needle, const char* haystack) {
if (needle == nullptr || haystack == nullptr) return needle == haystack; if (needle == nullptr || haystack == nullptr) return needle == haystack;
@ -1865,8 +1867,8 @@ std::string String::ShowWideCString(const wchar_t * wide_c_str) {
return internal::WideStringToUtf8(wide_c_str, -1); return internal::WideStringToUtf8(wide_c_str, -1);
} }
// Compares two wide C strings. Returns true if they have the same // Compares two wide C strings. Returns true if and only if they have the
// content. // same content.
// //
// Unlike wcscmp(), this function can handle NULL argument(s). A NULL // Unlike wcscmp(), this function can handle NULL argument(s). A NULL
// C string is considered different to any non-NULL C string, // C string is considered different to any non-NULL C string,
@ -1910,7 +1912,7 @@ AssertionResult CmpHelperSTRNE(const char* s1_expression,
<< " vs " << PrintToString(s2); << " vs " << PrintToString(s2);
} }
// Compares two C strings, ignoring case. Returns true if they have // Compares two C strings, ignoring case. Returns true if and only if they have
// the same content. // the same content.
// //
// Unlike strcasecmp(), this function can handle NULL argument(s). A // Unlike strcasecmp(), this function can handle NULL argument(s). A
@ -1922,18 +1924,18 @@ bool String::CaseInsensitiveCStringEquals(const char * lhs, const char * rhs) {
return posix::StrCaseCmp(lhs, rhs) == 0; return posix::StrCaseCmp(lhs, rhs) == 0;
} }
// Compares two wide C strings, ignoring case. Returns true if they // Compares two wide C strings, ignoring case. Returns true if and only if they
// have the same content. // have the same content.
// //
// Unlike wcscasecmp(), this function can handle NULL argument(s). // Unlike wcscasecmp(), this function can handle NULL argument(s).
// A NULL C string is considered different to any non-NULL wide C string, // A NULL C string is considered different to any non-NULL wide C string,
// including the empty string. // including the empty string.
// NB: The implementations on different platforms slightly differ. // NB: The implementations on different platforms slightly differ.
// On windows, this method uses _wcsicmp which compares according to LC_CTYPE // On windows, this method uses _wcsicmp which compares according to LC_CTYPE
// environment variable. On GNU platform this method uses wcscasecmp // environment variable. On GNU platform this method uses wcscasecmp
// which compares according to LC_CTYPE category of the current locale. // which compares according to LC_CTYPE category of the current locale.
// On MacOS X, it uses towlower, which also uses LC_CTYPE category of the // On MacOS X, it uses towlower, which also uses LC_CTYPE category of the
// current locale. // current locale.
bool String::CaseInsensitiveWideCStringEquals(const wchar_t* lhs, bool String::CaseInsensitiveWideCStringEquals(const wchar_t* lhs,
const wchar_t* rhs) { const wchar_t* rhs) {
if (lhs == nullptr) return rhs == nullptr; if (lhs == nullptr) return rhs == nullptr;
@ -1956,7 +1958,7 @@ bool String::CaseInsensitiveWideCStringEquals(const wchar_t* lhs,
#endif // OS selector #endif // OS selector
} }
// Returns true if str ends with the given suffix, ignoring case. // Returns true if and only if str ends with the given suffix, ignoring case.
// Any string is considered to end with an empty suffix. // Any string is considered to end with an empty suffix.
bool String::EndsWithCaseInsensitive( bool String::EndsWithCaseInsensitive(
const std::string& str, const std::string& suffix) { const std::string& str, const std::string& suffix) {
@ -2198,12 +2200,12 @@ static bool TestPartSkipped(const TestPartResult& result) {
return result.skipped(); return result.skipped();
} }
// Returns true if the test was skipped. // Returns true if and only if the test was skipped.
bool TestResult::Skipped() const { bool TestResult::Skipped() const {
return !Failed() && CountIf(test_part_results_, TestPartSkipped) > 0; return !Failed() && CountIf(test_part_results_, TestPartSkipped) > 0;
} }
// Returns true if the test failed. // Returns true if and only if the test failed.
bool TestResult::Failed() const { bool TestResult::Failed() const {
for (int i = 0; i < total_part_count(); ++i) { for (int i = 0; i < total_part_count(); ++i) {
if (GetTestPartResult(i).failed()) if (GetTestPartResult(i).failed())
@ -2212,22 +2214,22 @@ bool TestResult::Failed() const {
return false; return false;
} }
// Returns true if the test part fatally failed. // Returns true if and only if the test part fatally failed.
static bool TestPartFatallyFailed(const TestPartResult& result) { static bool TestPartFatallyFailed(const TestPartResult& result) {
return result.fatally_failed(); return result.fatally_failed();
} }
// Returns true if the test fatally failed. // Returns true if and only if the test fatally failed.
bool TestResult::HasFatalFailure() const { bool TestResult::HasFatalFailure() const {
return CountIf(test_part_results_, TestPartFatallyFailed) > 0; return CountIf(test_part_results_, TestPartFatallyFailed) > 0;
} }
// Returns true if the test part non-fatally failed. // Returns true if and only if the test part non-fatally failed.
static bool TestPartNonfatallyFailed(const TestPartResult& result) { static bool TestPartNonfatallyFailed(const TestPartResult& result) {
return result.nonfatally_failed(); return result.nonfatally_failed();
} }
// Returns true if the test has a non-fatal failure. // Returns true if and only if the test has a non-fatal failure.
bool TestResult::HasNonfatalFailure() const { bool TestResult::HasNonfatalFailure() const {
return CountIf(test_part_results_, TestPartNonfatallyFailed) > 0; return CountIf(test_part_results_, TestPartNonfatallyFailed) > 0;
} }
@ -2523,18 +2525,18 @@ void Test::Run() {
this, &Test::TearDown, "TearDown()"); this, &Test::TearDown, "TearDown()");
} }
// Returns true if the current test has a fatal failure. // Returns true if and only if the current test has a fatal failure.
bool Test::HasFatalFailure() { bool Test::HasFatalFailure() {
return internal::GetUnitTestImpl()->current_test_result()->HasFatalFailure(); return internal::GetUnitTestImpl()->current_test_result()->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.
bool Test::HasNonfatalFailure() { bool Test::HasNonfatalFailure() {
return internal::GetUnitTestImpl()->current_test_result()-> return internal::GetUnitTestImpl()->current_test_result()->
HasNonfatalFailure(); HasNonfatalFailure();
} }
// Returns true if the current test was skipped. // Returns true if and only if the current test was skipped.
bool Test::IsSkipped() { bool Test::IsSkipped() {
return internal::GetUnitTestImpl()->current_test_result()->Skipped(); return internal::GetUnitTestImpl()->current_test_result()->Skipped();
} }
@ -2633,7 +2635,7 @@ class TestNameIs {
explicit TestNameIs(const char* name) explicit TestNameIs(const char* name)
: name_(name) {} : name_(name) {}
// Returns true if the test name of test_info matches name_. // Returns true if and only if the test name of test_info matches name_.
bool operator()(const TestInfo * test_info) const { bool operator()(const TestInfo * test_info) const {
return test_info && test_info->name() == name_; return test_info && test_info->name() == name_;
} }
@ -2992,7 +2994,7 @@ static const char* GetAnsiColorCode(GTestColor color) {
#endif // GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE #endif // GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE
// Returns true if Google Test should use colors in the output. // Returns true if and only if Google Test should use colors in the output.
bool ShouldUseColor(bool stdout_is_tty) { bool ShouldUseColor(bool stdout_is_tty) {
const char* const gtest_color = GTEST_FLAG(color).c_str(); const char* const gtest_color = GTEST_FLAG(color).c_str();
@ -4709,11 +4711,12 @@ internal::TimeInMillis UnitTest::elapsed_time() const {
return impl()->elapsed_time(); return impl()->elapsed_time();
} }
// 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 UnitTest::Passed() const { return impl()->Passed(); } bool UnitTest::Passed() const { return impl()->Passed(); }
// Returns true if the unit test failed (i.e. some test suite failed // Returns true if and only if the unit test failed (i.e. some test suite
// or something outside of all tests failed). // failed or something outside of all tests failed).
bool UnitTest::Failed() const { return impl()->Failed(); } bool UnitTest::Failed() const { return impl()->Failed(); }
// Gets the i-th test suite among all the test suites. i can range from 0 to // Gets the i-th test suite among all the test suites. i can range from 0 to
@ -5161,7 +5164,7 @@ class TestSuiteNameIs {
// Constructor. // Constructor.
explicit TestSuiteNameIs(const std::string& name) : name_(name) {} explicit TestSuiteNameIs(const std::string& name) : name_(name) {}
// Returns true if the name of test_suite matches name_. // Returns true if and only if the name of test_suite matches name_.
bool operator()(const TestSuite* test_suite) const { bool operator()(const TestSuite* test_suite) const {
return test_suite != nullptr && return test_suite != nullptr &&
strcmp(test_suite->name(), name_.c_str()) == 0; strcmp(test_suite->name(), name_.c_str()) == 0;
@ -5232,7 +5235,8 @@ static void TearDownEnvironment(Environment* env) { env->TearDown(); }
// All other functions called from RunAllTests() may safely assume that // All other functions called from RunAllTests() may safely assume that
// parameterized tests are ready to be counted and run. // parameterized tests are ready to be counted and run.
bool UnitTestImpl::RunAllTests() { bool UnitTestImpl::RunAllTests() {
// True if Google Test is initialized before RUN_ALL_TESTS() is called. // True if and only if Google Test is initialized before RUN_ALL_TESTS() is
// called.
const bool gtest_is_initialized_before_run_all_tests = GTestIsInitialized(); const bool gtest_is_initialized_before_run_all_tests = GTestIsInitialized();
// Do not run any test if the --help flag was specified. // Do not run any test if the --help flag was specified.
@ -5248,7 +5252,7 @@ bool UnitTestImpl::RunAllTests() {
// protocol. // protocol.
internal::WriteToShardStatusFileIfNeeded(); internal::WriteToShardStatusFileIfNeeded();
// True if we are in a subprocess for running a thread-safe-style // True if and only if we are in a subprocess for running a thread-safe-style
// death test. // death test.
bool in_subprocess_for_death_test = false; bool in_subprocess_for_death_test = false;
@ -5281,7 +5285,7 @@ bool UnitTestImpl::RunAllTests() {
random_seed_ = GTEST_FLAG(shuffle) ? random_seed_ = GTEST_FLAG(shuffle) ?
GetRandomSeedFromFlag(GTEST_FLAG(random_seed)) : 0; GetRandomSeedFromFlag(GTEST_FLAG(random_seed)) : 0;
// True if at least one test has failed. // True if and only if at least one test has failed.
bool failed = false; bool failed = false;
TestEventListener* repeater = listeners()->repeater(); TestEventListener* repeater = listeners()->repeater();
@ -5479,8 +5483,8 @@ Int32 Int32FromEnvOrDie(const char* var, Int32 default_val) {
} }
// Given the total number of shards, the shard index, and the test id, // Given the total number of shards, the shard index, and the test id,
// returns true if the test should be run on this shard. The test id is // returns true if and only if the test should be run on this shard. The test id
// some arbitrary but unique non-negative integer assigned to each test // is some arbitrary but unique non-negative integer assigned to each test
// method. Assumes that 0 <= shard_index < total_shards. // method. Assumes that 0 <= shard_index < total_shards.
bool ShouldRunTestOnShard(int total_shards, int shard_index, int test_id) { bool ShouldRunTestOnShard(int total_shards, int shard_index, int test_id) {
return (test_id % total_shards) == shard_index; return (test_id % total_shards) == shard_index;
@ -6053,7 +6057,7 @@ void ParseGoogleTestFlagsOnlyImpl(int* argc, CharType** argv) {
void ParseGoogleTestFlagsOnly(int* argc, char** argv) { void ParseGoogleTestFlagsOnly(int* argc, char** argv) {
ParseGoogleTestFlagsOnlyImpl(argc, argv); ParseGoogleTestFlagsOnlyImpl(argc, argv);
// Fix the value of *_NSGetArgc() on macOS, but if // Fix the value of *_NSGetArgc() on macOS, but if and only if
// *_NSGetArgv() == argv // *_NSGetArgv() == argv
// Only applicable to char** version of argv // Only applicable to char** version of argv
#if GTEST_OS_MAC #if GTEST_OS_MAC

View File

@ -141,7 +141,7 @@ class TestForDeathTest : public testing::Test {
DieInside("MemberFunction"); DieInside("MemberFunction");
} }
// True if MemberFunction() should die. // True if and only if MemberFunction() should die.
bool should_die_; bool should_die_;
const FilePath original_dir_; const FilePath original_dir_;
}; };
@ -158,7 +158,7 @@ class MayDie {
} }
private: private:
// True if MemberFunction() should die. // True if and only if MemberFunction() should die.
bool should_die_; bool should_die_;
}; };
@ -573,8 +573,8 @@ TEST_F(TestForDeathTest, ErrorMessageMismatch) {
}, "died but not with expected error"); }, "died but not with expected error");
} }
// On exit, *aborted will be true if the EXPECT_DEATH() statement // On exit, *aborted will be true if and only if the EXPECT_DEATH()
// aborted the function. // statement aborted the function.
void ExpectDeathTestHelper(bool* aborted) { void ExpectDeathTestHelper(bool* aborted) {
*aborted = true; *aborted = true;
EXPECT_DEATH(DieIf(false), "DieIf"); // This assertion should fail. EXPECT_DEATH(DieIf(false), "DieIf"); // This assertion should fail.

View File

@ -86,7 +86,7 @@ class ThrowOnFailureTest(gtest_test_utils.TestCase):
variable; None if the variable should be unset. variable; None if the variable should be unset.
flag_value: value of the --gtest_break_on_failure flag; flag_value: value of the --gtest_break_on_failure flag;
None if the flag should not be present. None if the flag should not be present.
should_fail: True if the program is expected to fail. should_fail: True if and only if the program is expected to fail.
""" """
SetEnvVar(THROW_ON_FAILURE, env_var_value) SetEnvVar(THROW_ON_FAILURE, env_var_value)

View File

@ -116,7 +116,7 @@ void Check(bool condition, const char* msg) {
} }
} }
// Runs the tests. Return true if successful. // Runs the tests. Return true if and only if successful.
// //
// The 'failure' parameter specifies the type of failure that should // The 'failure' parameter specifies the type of failure that should
// be generated by the global set-up. // be generated by the global set-up.

View File

@ -144,10 +144,10 @@ class Predicate1Test : public testing::Test {
} }
} }
// true if the test function is expected to run to finish. // true if and only if the test function is expected to run to finish.
static bool expected_to_finish_; static bool expected_to_finish_;
// true if the test function did run to finish. // true if and only if the test function did run to finish.
static bool finished_; static bool finished_;
static int n1_; static int n1_;
@ -539,10 +539,10 @@ class Predicate2Test : public testing::Test {
} }
} }
// true if the test function is expected to run to finish. // true if and only if the test function is expected to run to finish.
static bool expected_to_finish_; static bool expected_to_finish_;
// true if the test function did run to finish. // true if and only if the test function did run to finish.
static bool finished_; static bool finished_;
static int n1_; static int n1_;
@ -976,10 +976,10 @@ class Predicate3Test : public testing::Test {
} }
} }
// true if the test function is expected to run to finish. // true if and only if the test function is expected to run to finish.
static bool expected_to_finish_; static bool expected_to_finish_;
// true if the test function did run to finish. // true if and only if the test function did run to finish.
static bool finished_; static bool finished_;
static int n1_; static int n1_;
@ -1455,10 +1455,10 @@ class Predicate4Test : public testing::Test {
} }
} }
// true if the test function is expected to run to finish. // true if and only if the test function is expected to run to finish.
static bool expected_to_finish_; static bool expected_to_finish_;
// true if the test function did run to finish. // true if and only if the test function did run to finish.
static bool finished_; static bool finished_;
static int n1_; static int n1_;
@ -1976,10 +1976,10 @@ class Predicate5Test : public testing::Test {
} }
} }
// true if the test function is expected to run to finish. // true if and only if the test function is expected to run to finish.
static bool expected_to_finish_; static bool expected_to_finish_;
// true if the test function did run to finish. // true if and only if the test function did run to finish.
static bool finished_; static bool finished_;
static int n1_; static int n1_;

View File

@ -45,7 +45,7 @@ namespace {
class PrematureExitTest : public Test { class PrematureExitTest : public Test {
public: public:
// Returns true if the given file exists. // Returns true if and only if the given file exists.
static bool FileExists(const char* filepath) { static bool FileExists(const char* filepath) {
StatStruct stat; StatStruct stat;
return Stat(filepath, &stat) == 0; return Stat(filepath, &stat) == 0;
@ -61,7 +61,7 @@ class PrematureExitTest : public Test {
} }
} }
// Returns true if the premature-exit file exists. // Returns true if and only if the premature-exit file exists.
bool PrematureExitFileExists() const { bool PrematureExitFileExists() const {
return FileExists(premature_exit_file_path_); return FileExists(premature_exit_file_path_);
} }

View File

@ -215,10 +215,10 @@ class Subprocess:
Returns: Returns:
An object that represents outcome of the executed process. It has the An object that represents outcome of the executed process. It has the
following attributes: following attributes:
terminated_by_signal True if the child process has been terminated terminated_by_signal True if and only if the child process has been
by a signal. terminated by a signal.
signal Sygnal that terminated the child process. signal Sygnal that terminated the child process.
exited True if the child process exited normally. exited True if and only if the child process exited normally.
exit_code The code with which the child process exited. exit_code The code with which the child process exited.
output Child process's stdout and stderr output output Child process's stdout and stderr output
combined in a string. combined in a string.

View File

@ -2170,12 +2170,12 @@ static Environment* record_property_env GTEST_ATTRIBUTE_UNUSED_ =
// First, some predicates and predicate-formatters needed by the tests. // First, some predicates and predicate-formatters needed by the tests.
// Returns true if the argument is an even number. // Returns true if and only if the argument is an even number.
bool IsEven(int n) { bool IsEven(int n) {
return (n % 2) == 0; return (n % 2) == 0;
} }
// A functor that returns true if the argument is an even number. // A functor that returns true if and only if the argument is an even number.
struct IsEvenFunctor { struct IsEvenFunctor {
bool operator()(int n) { return IsEven(n); } bool operator()(int n) { return IsEven(n); }
}; };
@ -2219,13 +2219,13 @@ struct AssertIsEvenFunctor {
} }
}; };
// Returns true if the sum of the arguments is an even number. // Returns true if and only if the sum of the arguments is an even number.
bool SumIsEven2(int n1, int n2) { bool SumIsEven2(int n1, int n2) {
return IsEven(n1 + n2); return IsEven(n1 + n2);
} }
// A functor that returns true if the sum of the arguments is an even // A functor that returns true if and only if the sum of the arguments is an
// number. // even number.
struct SumIsEven3Functor { struct SumIsEven3Functor {
bool operator()(int n1, int n2, int n3) { bool operator()(int n1, int n2, int n3) {
return IsEven(n1 + n2 + n3); return IsEven(n1 + n2 + n3);