mirror of https://github.com/google/googletest.git
Merge 4eb909a945 into 283c17563f
This commit is contained in:
commit
146ec70ae4
|
|
@ -1701,9 +1701,9 @@ checkpoints to implement a resource leak checker, for example.
|
|||
|
||||
### Defining Event Listeners
|
||||
|
||||
To define a event listener, you subclass either
|
||||
To define an event listener, you subclass either
|
||||
[`testing::TestEventListener`](reference/testing.md#TestEventListener) or
|
||||
[`testing::EmptyTestEventListener`](reference/testing.md#EmptyTestEventListener)
|
||||
[`testing::EmptyTestEventListener`](reference/testing.md#EmptyTestEventListener).
|
||||
The former is an (abstract) interface, where *each pure virtual method can be
|
||||
overridden to handle a test event* (For example, when a test starts, the
|
||||
`OnTestStart()` method will be called.). The latter provides an empty
|
||||
|
|
|
|||
|
|
@ -1242,7 +1242,7 @@ Field(&Foo::number, Ge(3))
|
|||
matches a plain pointer `p` where `p->number >= 3`. If `p` is `NULL`, the match
|
||||
will always fail regardless of the inner matcher.
|
||||
|
||||
What if you want to validate more than one members at the same time? Remember
|
||||
What if you want to validate more than one member at the same time? Remember
|
||||
that there are [`AllOf()` and `AllOfArray()`](#CombiningMatchers).
|
||||
|
||||
Finally `Field()` and `Property()` provide overloads that take the field or
|
||||
|
|
|
|||
|
|
@ -4,5 +4,5 @@ GoogleTest follows Google's
|
|||
[Foundational C++ Support Policy](https://opensource.google/documentation/policies/cplusplus-support).
|
||||
See
|
||||
[this table](https://github.com/google/oss-policies-info/blob/main/foundational-cxx-support-matrix.md)
|
||||
for a list of currently supported versions compilers, platforms, and build
|
||||
for a list of currently supported compiler versions, platforms, and build
|
||||
tools.
|
||||
|
|
|
|||
|
|
@ -457,7 +457,7 @@ int main(int argc, char **argv) {
|
|||
The `testing::InitGoogleTest()` function parses the command line for GoogleTest
|
||||
flags, and removes all recognized flags. This allows the user to control a test
|
||||
program's behavior via various flags, which we'll cover in the
|
||||
[AdvancedGuide](advanced.md). You **must** call this function before calling
|
||||
[Advanced Guide](advanced.md). You **must** call this function before calling
|
||||
`RUN_ALL_TESTS()`, or the flags won't be properly initialized.
|
||||
|
||||
On Windows, `InitGoogleTest()` also works with wide strings, so it can be used
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ See also
|
|||
|
||||
The functions listed in the table above appear to return generators that create
|
||||
values of the desired types, but this is not generally the case. Rather, they
|
||||
typically return factory objects that convert to the the desired generators.
|
||||
typically return factory objects that convert to the desired generators.
|
||||
This affords some flexibility in allowing you to specify values of types that
|
||||
are different from, yet implicitly convertible to, the actual parameter type
|
||||
required by your fixture class.
|
||||
|
|
|
|||
|
|
@ -849,7 +849,7 @@ class [[nodiscard]] Action<R(Args...)> {
|
|||
|
||||
// The PolymorphicAction class template makes it easy to implement a
|
||||
// polymorphic action (i.e. an action that can be used in mock
|
||||
// functions of than one type, e.g. Return()).
|
||||
// functions of more than one type, e.g. Return()).
|
||||
//
|
||||
// To define a polymorphic action, a user first provides a COPYABLE
|
||||
// implementation class that has a Perform() method template:
|
||||
|
|
|
|||
|
|
@ -1778,7 +1778,7 @@ class [[nodiscard]] FloatingEqMatcher {
|
|||
nan_eq_nan_(nan_eq_nan),
|
||||
max_abs_error_(max_abs_error) {
|
||||
GTEST_CHECK_(max_abs_error >= 0)
|
||||
<< ", where max_abs_error is" << max_abs_error;
|
||||
<< ", where max_abs_error is " << max_abs_error;
|
||||
}
|
||||
|
||||
// Implements floating point equality matcher as a Matcher<T>.
|
||||
|
|
@ -5906,7 +5906,7 @@ PolymorphicMatcher<internal::ExceptionMatcherImpl<Err>> ThrowsMessage(
|
|||
EXPECT_PRED_FORMAT1( \
|
||||
::testing::internal::MakePredicateFormatterFromMatcher(matcher), value)
|
||||
|
||||
// MATCHER* macros itself are listed below.
|
||||
// MATCHER* macros themselves are listed below.
|
||||
#define MATCHER(name, description) \
|
||||
class name##Matcher \
|
||||
: public ::testing::internal::MatcherBaseImpl<name##Matcher> { \
|
||||
|
|
|
|||
|
|
@ -373,10 +373,10 @@ bool UnorderedElementsAreMatcherImplBase::VerifyMatchMatrix(
|
|||
return true;
|
||||
}
|
||||
|
||||
const bool is_exact_match_with_size_discrepency =
|
||||
const bool is_exact_match_with_size_discrepancy =
|
||||
match_flags() == UnorderedMatcherRequire::ExactMatch &&
|
||||
matrix.LhsSize() != matrix.RhsSize();
|
||||
if (is_exact_match_with_size_discrepency) {
|
||||
if (is_exact_match_with_size_discrepancy) {
|
||||
// The element count doesn't match. If the container is empty,
|
||||
// there's no need to explain anything as Google Mock already
|
||||
// prints the empty container. Otherwise we just need to show
|
||||
|
|
@ -386,7 +386,7 @@ bool UnorderedElementsAreMatcherImplBase::VerifyMatchMatrix(
|
|||
}
|
||||
}
|
||||
|
||||
bool result = !is_exact_match_with_size_discrepency;
|
||||
bool result = !is_exact_match_with_size_discrepancy;
|
||||
::std::vector<char> element_matched(matrix.LhsSize(), 0);
|
||||
::std::vector<char> matcher_matched(matrix.RhsSize(), 0);
|
||||
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ sudo make install # Install in /usr/local/ by default
|
|||
```
|
||||
|
||||
If you use Windows and have Visual Studio installed, a `gtest.sln` file and
|
||||
several `.vcproj` files will be created. You can then build them using Visual
|
||||
several `.vcxproj` files will be created. You can then build them using Visual
|
||||
Studio.
|
||||
|
||||
On Mac OS X with Xcode installed, a `.xcodeproj` file will be generated.
|
||||
|
|
|
|||
|
|
@ -114,14 +114,14 @@ GTEST_DECLARE_bool_(list_tests);
|
|||
// in addition to its normal textual output.
|
||||
GTEST_DECLARE_string_(output);
|
||||
|
||||
// This flags control whether Google Test prints only test failures.
|
||||
// This flag controls whether Google Test prints only test failures.
|
||||
GTEST_DECLARE_bool_(brief);
|
||||
|
||||
// This flags control whether Google Test prints the elapsed time for each
|
||||
// This flag controls whether Google Test prints the elapsed time for each
|
||||
// test.
|
||||
GTEST_DECLARE_bool_(print_time);
|
||||
|
||||
// This flags control whether Google Test prints UTF8 characters as text.
|
||||
// This flag controls whether Google Test prints UTF8 characters as text.
|
||||
GTEST_DECLARE_bool_(print_utf8);
|
||||
|
||||
// This flag specifies the random number seed.
|
||||
|
|
|
|||
|
|
@ -481,7 +481,7 @@ struct CodeLocation {
|
|||
};
|
||||
|
||||
// Helper to identify which setup function for TestCase / TestSuite to call.
|
||||
// Only one function is allowed, either TestCase or TestSute but not both.
|
||||
// Only one function is allowed, either TestCase or TestSuite but not both.
|
||||
|
||||
// Utility functions to help SuiteApiResolver
|
||||
using SetUpTearDownSuiteFuncType = void (*)();
|
||||
|
|
|
|||
|
|
@ -332,7 +332,7 @@ class [[nodiscard]] ValuesInIteratorRangeGenerator
|
|||
return new Iterator(*this);
|
||||
}
|
||||
// We need to use cached value referenced by iterator_ because *iterator_
|
||||
// can return a temporary object (and of type other then T), so just
|
||||
// can return a temporary object (and of type other than T), so just
|
||||
// having "return &*iterator_;" doesn't work.
|
||||
// value_ is updated here and not in Advance() because Advance()
|
||||
// can advance iterator_ beyond the end of the range, and we cannot
|
||||
|
|
@ -761,19 +761,19 @@ class [[nodiscard]] ParameterizedTestSuiteRegistry {
|
|||
const ParameterizedTestSuiteRegistry&) = delete;
|
||||
};
|
||||
|
||||
// Keep track of what type-parameterized test suite are defined and
|
||||
// where as well as which are intatiated. This allows susequently
|
||||
// identifying suits that are defined but never used.
|
||||
// Keep track of what type-parameterized test suites are defined and
|
||||
// where as well as which are instantiated. This allows subsequently
|
||||
// identifying suites that are defined but never used.
|
||||
class [[nodiscard]] TypeParameterizedTestSuiteRegistry {
|
||||
public:
|
||||
// Add a suite definition
|
||||
void RegisterTestSuite(const char* test_suite_name,
|
||||
CodeLocation code_location);
|
||||
|
||||
// Add an instantiation of a suit.
|
||||
// Add an instantiation of a suite.
|
||||
void RegisterInstantiation(const char* test_suite_name);
|
||||
|
||||
// For each suit repored as defined but not reported as instantiation,
|
||||
// For each suite reported as defined but not reported as instantiation,
|
||||
// emit a test that reports that fact (configurably, as an error).
|
||||
void CheckForInstantiations();
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
// The Google C++ Testing and Mocking Framework (Google Test)
|
||||
//
|
||||
// This header file declares the String class and functions used internally by
|
||||
// Google Test. They are subject to change without notice. They should not used
|
||||
// Google Test. They are subject to change without notice. They should not be used
|
||||
// by code external to Google Test.
|
||||
//
|
||||
// This header file is #included by gtest-internal.h.
|
||||
|
|
|
|||
|
|
@ -724,7 +724,7 @@ int WindowsDeathTest::Wait() {
|
|||
|
||||
ReadAndInterpretStatusByte();
|
||||
|
||||
// Waits for the child process to exit if it haven't already. This
|
||||
// Waits for the child process to exit if it hasn't already. This
|
||||
// returns immediately if the child has already exited, regardless of
|
||||
// whether previous calls to WaitForMultipleObjects synchronized on this
|
||||
// handle or not.
|
||||
|
|
@ -773,7 +773,7 @@ DeathTest::TestRole WindowsDeathTest::AssumeRole() {
|
|||
&handles_are_inheritable,
|
||||
TRUE, // The event will automatically reset to non-signaled state.
|
||||
FALSE, // The initial state is non-signalled.
|
||||
nullptr)); // The even is unnamed.
|
||||
nullptr)); // The event is unnamed.
|
||||
GTEST_DEATH_TEST_CHECK_(event_handle_.Get() != nullptr);
|
||||
const std::string filter_flag = std::string("--") + GTEST_FLAG_PREFIX_ +
|
||||
"filter=" + info->test_suite_name() + "." +
|
||||
|
|
|
|||
|
|
@ -711,8 +711,8 @@ class GTEST_API_ UnitTestImpl {
|
|||
|
||||
// Registers all parameterized tests defined using TEST_P and
|
||||
// INSTANTIATE_TEST_SUITE_P, creating regular tests for each test/parameter
|
||||
// combination. This method can be called more then once; it has guards
|
||||
// protecting from registering the tests more then once. If
|
||||
// combination. This method can be called more than once; it has guards
|
||||
// protecting from registering the tests more than once. If
|
||||
// value-parameterized tests are disabled, RegisterParameterizedTests is
|
||||
// present but does nothing.
|
||||
void RegisterParameterizedTests();
|
||||
|
|
|
|||
|
|
@ -1136,7 +1136,7 @@ class CapturedStream {
|
|||
#elif defined(GTEST_OS_IOS)
|
||||
char user_temp_dir[PATH_MAX + 1];
|
||||
|
||||
// Documented alternative to NSTemporaryDirectory() (for obtaining creating
|
||||
// Documented alternative to NSTemporaryDirectory() (for creating
|
||||
// a temporary directory) at
|
||||
// https://developer.apple.com/library/archive/documentation/Security/Conceptual/SecureCodingGuide/Articles/RaceConditions.html#//apple_ref/doc/uid/TP40002585-SW10
|
||||
//
|
||||
|
|
|
|||
|
|
@ -527,7 +527,7 @@ namespace {
|
|||
|
||||
// When TEST_P is found without a matching INSTANTIATE_TEST_SUITE_P
|
||||
// to creates test cases for it, a synthetic test case is
|
||||
// inserted to report ether an error or a log message.
|
||||
// inserted to report either an error or a log message.
|
||||
//
|
||||
// This configuration bit will likely be removed at some point.
|
||||
constexpr bool kErrorOnUninstantiatedParameterizedTest = true;
|
||||
|
|
@ -590,7 +590,7 @@ void InsertSyntheticTestCase(const std::string& name, CodeLocation location,
|
|||
"defined via TEST_P . No test cases will run."
|
||||
"\n\n"
|
||||
"Ideally, INSTANTIATE_TEST_SUITE_P should only ever be invoked from "
|
||||
"code that always depend on code that provides TEST_P. Failing to do "
|
||||
"code that always depends on code that provides TEST_P. Failing to do "
|
||||
"so is often an indication of dead code, e.g. the last TEST_P was "
|
||||
"removed but the rest got left behind.";
|
||||
|
||||
|
|
@ -638,7 +638,7 @@ void TypeParameterizedTestSuiteRegistry::RegisterInstantiation(
|
|||
if (it != suites_.end()) {
|
||||
it->second.instantiated = true;
|
||||
} else {
|
||||
GTEST_LOG_(ERROR) << "Unknown type parameterized test suit '"
|
||||
GTEST_LOG_(ERROR) << "Unknown type parameterized test suite '"
|
||||
<< test_suite_name << "'";
|
||||
}
|
||||
}
|
||||
|
|
@ -893,7 +893,7 @@ class PositiveAndNegativeUnitTestFilter {
|
|||
}
|
||||
|
||||
// Returns true if and only if test name (this is generated by appending test
|
||||
// suit name and test name via a '.' character) matches the positive filter
|
||||
// suite name and test name via a '.' character) matches the positive filter
|
||||
// and does not match the negative filter.
|
||||
bool MatchesTest(const std::string& test_suite_name,
|
||||
const std::string& test_name) const {
|
||||
|
|
@ -2427,7 +2427,7 @@ static std::vector<std::string> GetReservedAttributesForElement(
|
|||
} else {
|
||||
GTEST_CHECK_(false) << "Unrecognized xml_element provided: " << xml_element;
|
||||
}
|
||||
// This code is unreachable but some compilers may not realizes that.
|
||||
// This code is unreachable but some compilers may not realize that.
|
||||
return std::vector<std::string>();
|
||||
}
|
||||
|
||||
|
|
@ -2445,7 +2445,7 @@ static std::vector<std::string> GetReservedOutputAttributesForElement(
|
|||
} else {
|
||||
GTEST_CHECK_(false) << "Unrecognized xml_element provided: " << xml_element;
|
||||
}
|
||||
// This code is unreachable but some compilers may not realizes that.
|
||||
// This code is unreachable but some compilers may not realize that.
|
||||
return std::vector<std::string>();
|
||||
}
|
||||
#endif
|
||||
|
|
@ -2493,7 +2493,7 @@ void TestResult::Clear() {
|
|||
elapsed_time_ = 0;
|
||||
}
|
||||
|
||||
// Returns true off the test part was skipped.
|
||||
// Returns true if the test part was skipped.
|
||||
static bool TestPartSkipped(const TestPartResult& result) {
|
||||
return result.skipped();
|
||||
}
|
||||
|
|
@ -4535,19 +4535,19 @@ void XmlUnitTestResultPrinter::OutputXmlTestProperties(
|
|||
#endif // GTEST_HAS_FILE_SYSTEM
|
||||
|
||||
#if GTEST_HAS_FILE_SYSTEM
|
||||
// This class generates an JSON output file.
|
||||
// This class generates a JSON output file.
|
||||
class JsonUnitTestResultPrinter : public EmptyTestEventListener {
|
||||
public:
|
||||
explicit JsonUnitTestResultPrinter(const char* output_file);
|
||||
|
||||
void OnTestIterationEnd(const UnitTest& unit_test, int iteration) override;
|
||||
|
||||
// Prints an JSON summary of all unit tests.
|
||||
// Prints a JSON summary of all unit tests.
|
||||
static void PrintJsonTestList(::std::ostream* stream,
|
||||
const std::vector<TestSuite*>& test_suites);
|
||||
|
||||
private:
|
||||
// Returns an JSON-escaped copy of the input string str.
|
||||
// Returns a JSON-escaped copy of the input string str.
|
||||
static std::string EscapeJson(const std::string& str);
|
||||
|
||||
//// Verifies that the given attribute belongs to the given element and
|
||||
|
|
@ -4620,7 +4620,7 @@ void JsonUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test,
|
|||
fclose(jsonout);
|
||||
}
|
||||
|
||||
// Returns an JSON-escaped copy of the input string str.
|
||||
// Returns a JSON-escaped copy of the input string str.
|
||||
std::string JsonUnitTestResultPrinter::EscapeJson(const std::string& str) {
|
||||
Message m;
|
||||
|
||||
|
|
@ -4660,7 +4660,7 @@ std::string JsonUnitTestResultPrinter::EscapeJson(const std::string& str) {
|
|||
return m.GetString();
|
||||
}
|
||||
|
||||
// The following routines generate an JSON representation of a UnitTest
|
||||
// The following routines generate a JSON representation of a UnitTest
|
||||
// object.
|
||||
|
||||
// Formats the given time in milliseconds as seconds.
|
||||
|
|
@ -4872,7 +4872,7 @@ void JsonUnitTestResultPrinter::OutputJsonTestResult(::std::ostream* stream,
|
|||
*stream << "\n" << Indent(8) << "}";
|
||||
}
|
||||
|
||||
// Prints an JSON representation of a TestSuite object
|
||||
// Prints a JSON representation of a TestSuite object
|
||||
void JsonUnitTestResultPrinter::PrintJsonTestSuite(
|
||||
std::ostream* stream, const TestSuite& test_suite) {
|
||||
const std::string kTestsuite = "testsuite";
|
||||
|
|
|
|||
|
|
@ -731,7 +731,7 @@ class GTestJsonOutputUnitTest(gtest_test_utils.TestCase):
|
|||
def testNoTestJsonOutput(self):
|
||||
"""Verifies JSON output for a Google Test binary without actual tests.
|
||||
|
||||
Runs a test program that generates an JSON output for a binary with no
|
||||
Runs a test program that generates a JSON output for a binary with no
|
||||
tests, and tests that the JSON output is expected.
|
||||
"""
|
||||
|
||||
|
|
@ -750,7 +750,7 @@ class GTestJsonOutputUnitTest(gtest_test_utils.TestCase):
|
|||
match = re.match(r'(\d+)-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d)', date_time_str)
|
||||
self.assertTrue(
|
||||
re.match,
|
||||
'JSON datettime string %s has incorrect format' % date_time_str,
|
||||
'JSON datetime string %s has incorrect format' % date_time_str,
|
||||
)
|
||||
date_time_from_json = datetime.datetime(
|
||||
year=int(match.group(1)),
|
||||
|
|
@ -771,7 +771,7 @@ class GTestJsonOutputUnitTest(gtest_test_utils.TestCase):
|
|||
def testDefaultOutputFile(self):
|
||||
"""Verifies the default output file name.
|
||||
|
||||
Confirms that Google Test produces an JSON output file with the expected
|
||||
Confirms that Google Test produces a JSON output file with the expected
|
||||
default name if no name is explicitly specified.
|
||||
"""
|
||||
output_file = os.path.join(
|
||||
|
|
|
|||
|
|
@ -1002,7 +1002,7 @@ Stack trace: (omitted)
|
|||
googletest-output-test_.cc:#: Failure
|
||||
Parameterized test suite NoTests is instantiated via INSTANTIATE_TEST_SUITE_P, but no tests are defined via TEST_P . No test cases will run.
|
||||
|
||||
Ideally, INSTANTIATE_TEST_SUITE_P should only ever be invoked from code that always depend on code that provides TEST_P. Failing to do so is often an indication of dead code, e.g. the last TEST_P was removed but the rest got left behind.
|
||||
Ideally, INSTANTIATE_TEST_SUITE_P should only ever be invoked from code that always depends on code that provides TEST_P. Failing to do so is often an indication of dead code, e.g. the last TEST_P was removed but the rest got left behind.
|
||||
|
||||
To suppress this error for this test suite, insert the following line (in a non-header) in the namespace it is defined in:
|
||||
|
||||
|
|
|
|||
|
|
@ -960,7 +960,7 @@ TEST(MacroNameing, LookupNames) {
|
|||
}
|
||||
}
|
||||
|
||||
// Check that the expected form of the test suit name actually exists.
|
||||
// Check that the expected form of the test suite name actually exists.
|
||||
EXPECT_NE( //
|
||||
know_suite_names.find("FortyTwo/MacroNamingTest"),
|
||||
know_suite_names.end());
|
||||
|
|
|
|||
Loading…
Reference in New Issue