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

Merge pull request #2387 from kuzkry:iff

PiperOrigin-RevId: 268693457
parents ac24edd6 7bd4a7f3
...@@ -94,7 +94,8 @@ class GTEST_API_ String { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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);
......
...@@ -43,7 +43,7 @@ class PrimeTable { ...@@ -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
......
...@@ -41,7 +41,7 @@ int Factorial(int n) { ...@@ -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;
......
...@@ -35,7 +35,7 @@ ...@@ -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_
...@@ -122,8 +122,8 @@ GTEST_DEFINE_string_( ...@@ -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) { ...@@ -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())
......
...@@ -99,14 +99,14 @@ const char kFlagfileFlag[] = "flagfile"; ...@@ -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, ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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.
......
...@@ -715,7 +715,7 @@ RE::~RE() { ...@@ -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) { ...@@ -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) { ...@@ -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) { ...@@ -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) { ...@@ -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( ...@@ -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) { ...@@ -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() { ...@@ -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) { ...@@ -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);
......
...@@ -177,8 +177,8 @@ namespace internal { ...@@ -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
...@@ -215,14 +215,13 @@ GTEST_DEFINE_bool_( ...@@ -215,14 +215,13 @@ GTEST_DEFINE_bool_(
"Run disabled tests too, in addition to the tests normally being run."); "Run disabled tests too, in addition to the tests normally being run.");
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 and only if a failed assertion should be a debugger "
"True if a failed assertion should be a debugger break-point."); "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_(
...@@ -270,16 +269,12 @@ GTEST_DEFINE_string_( ...@@ -270,16 +269,12 @@ GTEST_DEFINE_string_(
"executable's name and, if necessary, made unique by adding " "executable's name and, if necessary, made unique by adding "
"digits."); "digits.");
GTEST_DEFINE_bool_( GTEST_DEFINE_bool_(print_time, internal::BoolFromGTestEnv("print_time", true),
print_time, "True if and only if " GTEST_NAME_
internal::BoolFromGTestEnv("print_time", true),
"True 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, internal::BoolFromGTestEnv("print_utf8", true),
print_utf8, "True if and only if " GTEST_NAME_
internal::BoolFromGTestEnv("print_utf8", true),
"True if " GTEST_NAME_
" prints UTF8 characters as text."); " prints UTF8 characters as text.");
GTEST_DEFINE_int32_( GTEST_DEFINE_int32_(
...@@ -294,15 +289,13 @@ GTEST_DEFINE_int32_( ...@@ -294,15 +289,13 @@ GTEST_DEFINE_int32_(
"How many times to repeat each test. Specify a negative number " "How many times to repeat each test. Specify a negative number "
"for repeating forever. Useful for shaking out flaky tests."); "for repeating forever. Useful for shaking out flaky tests.");
GTEST_DEFINE_bool_( GTEST_DEFINE_bool_(show_internal_stack_frames, false,
show_internal_stack_frames, false, "True if and only if " GTEST_NAME_
"True if " GTEST_NAME_ " should include internal stack frames when " " should include internal stack frames when "
"printing test failure stack traces."); "printing test failure stack traces.");
GTEST_DEFINE_bool_( GTEST_DEFINE_bool_(shuffle, internal::BoolFromGTestEnv("shuffle", false),
shuffle, "True if and only if " GTEST_NAME_
internal::BoolFromGTestEnv("shuffle", false),
"True 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 +347,7 @@ UInt32 Random::Generate(UInt32 range) { ...@@ -354,7 +347,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 +364,18 @@ static int SumOverTestSuiteList(const std::vector<TestSuite*>& case_list, ...@@ -371,18 +364,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 +475,8 @@ std::string UnitTestOptions::GetAbsolutePathToOutputFile() { ...@@ -482,8 +475,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 +518,8 @@ bool UnitTestOptions::MatchesFilter( ...@@ -525,8 +518,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 +903,8 @@ const char* String::Utf16ToAnsi(LPCWSTR utf16_str) { ...@@ -910,7 +903,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 +1314,7 @@ std::vector<std::string> SplitEscapedString(const std::string& str) { ...@@ -1320,7 +1314,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 +1557,9 @@ namespace { ...@@ -1563,9 +1557,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 +1859,8 @@ std::string String::ShowWideCString(const wchar_t * wide_c_str) { ...@@ -1865,8 +1859,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 +1904,7 @@ AssertionResult CmpHelperSTRNE(const char* s1_expression, ...@@ -1910,7 +1904,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 +1916,18 @@ bool String::CaseInsensitiveCStringEquals(const char * lhs, const char * rhs) { ...@@ -1922,18 +1916,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 +1950,7 @@ bool String::CaseInsensitiveWideCStringEquals(const wchar_t* lhs, ...@@ -1956,7 +1950,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 +2192,12 @@ static bool TestPartSkipped(const TestPartResult& result) { ...@@ -2198,12 +2192,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 +2206,22 @@ bool TestResult::Failed() const { ...@@ -2212,22 +2206,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 +2517,18 @@ void Test::Run() { ...@@ -2523,18 +2517,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 +2627,7 @@ class TestNameIs { ...@@ -2633,7 +2627,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 +2986,7 @@ static const char* GetAnsiColorCode(GTestColor color) { ...@@ -2992,7 +2986,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 +4703,12 @@ internal::TimeInMillis UnitTest::elapsed_time() const { ...@@ -4709,11 +4703,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 +5156,7 @@ class TestSuiteNameIs { ...@@ -5161,7 +5156,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 +5227,8 @@ static void TearDownEnvironment(Environment* env) { env->TearDown(); } ...@@ -5232,7 +5227,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 +5244,7 @@ bool UnitTestImpl::RunAllTests() { ...@@ -5248,7 +5244,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 +5277,7 @@ bool UnitTestImpl::RunAllTests() { ...@@ -5281,7 +5277,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 +5475,8 @@ Int32 Int32FromEnvOrDie(const char* var, Int32 default_val) { ...@@ -5479,8 +5475,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 +6049,7 @@ void ParseGoogleTestFlagsOnlyImpl(int* argc, CharType** argv) { ...@@ -6053,7 +6049,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
......
...@@ -141,7 +141,7 @@ class TestForDeathTest : public testing::Test { ...@@ -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 { ...@@ -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) { ...@@ -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.
......
...@@ -86,7 +86,7 @@ class ThrowOnFailureTest(gtest_test_utils.TestCase): ...@@ -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)
......
...@@ -116,7 +116,7 @@ void Check(bool condition, const char* msg) { ...@@ -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.
......
...@@ -144,10 +144,10 @@ class Predicate1Test : public testing::Test { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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_;
......
...@@ -45,7 +45,7 @@ namespace { ...@@ -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 { ...@@ -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_);
} }
......
...@@ -215,10 +215,11 @@ class Subprocess: ...@@ -215,10 +215,11 @@ 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.
......
...@@ -2167,12 +2167,12 @@ static Environment* record_property_env GTEST_ATTRIBUTE_UNUSED_ = ...@@ -2167,12 +2167,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); }
}; };
...@@ -2216,13 +2216,13 @@ struct AssertIsEvenFunctor { ...@@ -2216,13 +2216,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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment