From 315f5f0a8d648322d5d635ba2ae814ca52ec12c6 Mon Sep 17 00:00:00 2001 From: htt1997 Date: Mon, 20 Feb 2023 11:12:00 +0800 Subject: [PATCH 1/2] update googletest Signed-off-by: htt1997 --- .../.github/ISSUE_TEMPLATE/00-bug_report.md | 4 +- .../ISSUE_TEMPLATE/10-feature_request.md | 2 +- googletest/BUILD.bazel | 28 +- googletest/CONTRIBUTING.md | 4 +- googletest/LICENSE | 2 +- googletest/README.md | 10 +- googletest/WORKSPACE | 6 +- googletest/docs/_layouts/default.html | 2 +- googletest/docs/advanced.md | 106 ++--- googletest/docs/faq.md | 20 +- googletest/docs/gmock_cheat_sheet.md | 4 +- googletest/docs/gmock_cook_book.md | 48 +-- googletest/docs/gmock_for_dummies.md | 4 +- googletest/docs/primer.md | 18 +- googletest/docs/quickstart-bazel.md | 4 +- googletest/docs/reference/mocking.md | 14 +- googletest/docs/reference/testing.md | 70 ++-- googletest/googlemock/README.md | 4 + .../googlemock/include/gmock/gmock-actions.h | 2 + .../include/gmock/gmock-cardinalities.h | 2 + .../include/gmock/gmock-function-mocker.h | 122 ++---- .../googlemock/include/gmock/gmock-matchers.h | 252 ++---------- .../include/gmock/gmock-more-actions.h | 2 + .../include/gmock/gmock-more-matchers.h | 2 + .../include/gmock/gmock-nice-strict.h | 2 + .../include/gmock/gmock-spec-builders.h | 6 +- googletest/googlemock/include/gmock/gmock.h | 6 +- .../include/gmock/internal/custom/README.md | 14 +- .../internal/custom/gmock-generated-actions.h | 2 + .../gmock/internal/custom/gmock-matchers.h | 2 + .../gmock/internal/custom/gmock-port.h | 2 + .../gmock/internal/gmock-internal-utils.h | 6 +- .../include/gmock/internal/gmock-port.h | 42 +- .../googlemock/src/gmock-internal-utils.cc | 58 +-- .../googlemock/src/gmock-spec-builders.cc | 20 +- googletest/googlemock/src/gmock.cc | 60 ++- googletest/googlemock/src/gmock_main.cc | 1 + googletest/googlemock/test/BUILD.bazel | 20 +- .../googlemock/test/gmock-actions_test.cc | 2 +- .../test/gmock-internal-utils_test.cc | 71 +--- .../googlemock/test/gmock-matchers_test.cc | 185 ++------- .../googlemock/test/gmock-nice-strict_test.cc | 43 +- .../test/gmock-spec-builders_test.cc | 43 +- .../googlemock/test/gmock_output_test_.cc | 12 +- googletest/googlemock/test/gmock_test.cc | 36 +- googletest/googletest/README.md | 10 +- .../googletest/cmake/internal_utils.cmake | 4 +- .../include/gtest/gtest-death-test.h | 7 +- .../googletest/include/gtest/gtest-message.h | 2 + .../include/gtest/gtest-param-test.h | 2 + .../googletest/include/gtest/gtest-printers.h | 24 +- .../googletest/include/gtest/gtest-spi.h | 2 + .../include/gtest/gtest-test-part.h | 2 + .../include/gtest/gtest-typed-test.h | 2 + googletest/googletest/include/gtest/gtest.h | 44 +- .../include/gtest/gtest_pred_impl.h | 3 +- .../googletest/include/gtest/gtest_prod.h | 1 + .../include/gtest/hwext/gtest-tag.h | 8 +- .../include/gtest/internal/custom/README.md | 16 +- .../internal/gtest-death-test-internal.h | 7 +- .../include/gtest/internal/gtest-filepath.h | 2 + .../include/gtest/internal/gtest-internal.h | 6 +- .../include/gtest/internal/gtest-param-util.h | 2 + .../include/gtest/internal/gtest-port-arch.h | 2 - .../include/gtest/internal/gtest-port.h | 179 ++++---- .../include/gtest/internal/gtest-string.h | 2 + .../include/gtest/internal/gtest-type-util.h | 2 + googletest/googletest/src/gtest-all.cc | 7 +- googletest/googletest/src/gtest-death-test.cc | 87 ++-- .../googletest/src/gtest-internal-inl.h | 113 ++--- googletest/googletest/src/gtest-port.cc | 30 +- googletest/googletest/src/gtest-printers.cc | 47 +-- googletest/googletest/src/gtest.cc | 386 ++++++++---------- googletest/googletest/src/gtest_main.cc | 1 + googletest/googletest/src/hwext/gtest-tag.cc | 34 +- googletest/googletest/test/BUILD.bazel | 118 +++--- .../test/googletest-catch-exceptions-test.py | 10 +- .../test/googletest-death-test-test.cc | 54 ++- .../test/googletest-death-test_ex_test.cc | 6 +- .../test/googletest-env-var-test_.cc | 26 +- .../googletest-global-environment-unittest.py | 60 +-- .../test/googletest-listener-test.cc | 2 +- .../test/googletest-options-test.cc | 24 +- .../googletest-output-test-golden-lin.txt | 28 +- .../test/googletest-output-test_.cc | 12 +- .../googletest/test/googletest-port-test.cc | 85 ++-- .../test/googletest-printers-test.cc | 29 -- .../googletest/test/gtest_environment_test.cc | 6 +- .../googletest/test/gtest_ext_unittest.cc | 339 +++++++++++++++ googletest/googletest/test/gtest_help_test.py | 3 +- .../test/gtest_pred_impl_unittest.cc | 12 +- googletest/googletest/test/gtest_prod_test.cc | 4 + .../googletest/test/gtest_repeat_test.cc | 30 +- .../googletest/test/gtest_test_utils.py | 83 +++- .../test/gtest_throw_on_failure_ex_test.cc | 2 +- googletest/googletest/test/gtest_unittest.cc | 295 +++++++------ .../huks/libhukssdk/include/hks_template.h | 8 + 97 files changed, 1708 insertions(+), 1927 deletions(-) create mode 100644 googletest/googletest/test/gtest_ext_unittest.cc create mode 100644 mock/innerkits/huks/libhukssdk/include/hks_template.h diff --git a/googletest/.github/ISSUE_TEMPLATE/00-bug_report.md b/googletest/.github/ISSUE_TEMPLATE/00-bug_report.md index 0f7e8b53..3255b345 100644 --- a/googletest/.github/ISSUE_TEMPLATE/00-bug_report.md +++ b/googletest/.github/ISSUE_TEMPLATE/00-bug_report.md @@ -1,5 +1,5 @@ --- -name: Bug report +name_: Bug report about: Create a report to help us improve title: '' labels: 'bug' @@ -25,7 +25,7 @@ We recommend using the latest commit in the master branch in your projects. **What operating system and version are you using?** -If you are using a Linux distribution please include the name and version of the +If you are using a Linux distribution please include the name_ and version of the distribution as well. **What compiler and version are you using?** diff --git a/googletest/.github/ISSUE_TEMPLATE/10-feature_request.md b/googletest/.github/ISSUE_TEMPLATE/10-feature_request.md index 70a3a209..25d03292 100644 --- a/googletest/.github/ISSUE_TEMPLATE/10-feature_request.md +++ b/googletest/.github/ISSUE_TEMPLATE/10-feature_request.md @@ -1,5 +1,5 @@ --- -name: Feature request +name_: Feature request about: Propose a new feature title: '' labels: 'enhancement' diff --git a/googletest/BUILD.bazel b/googletest/BUILD.bazel index 1df5ff5f..39c757e2 100644 --- a/googletest/BUILD.bazel +++ b/googletest/BUILD.bazel @@ -12,7 +12,7 @@ # copyright notice, this list of conditions and the following disclaimer # in the documentation and/or other materials provided with the # distribution. -# * Neither the name of Google Inc. nor the names of its +# * Neither the name_ of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # @@ -37,27 +37,27 @@ licenses(["notice"]) exports_files(["LICENSE"]) config_setting( - name = "qnx", + name_ = "qnx", constraint_values = ["@platforms//os:qnx"], ) config_setting( - name = "windows", + name_ = "windows", constraint_values = ["@platforms//os:windows"], ) config_setting( - name = "freebsd", + name_ = "freebsd", constraint_values = ["@platforms//os:freebsd"], ) config_setting( - name = "openbsd", + name_ = "openbsd", constraint_values = ["@platforms//os:openbsd"], ) config_setting( - name = "msvc_compiler", + name_ = "msvc_compiler", flag_values = { "@bazel_tools//tools/cpp:compiler": "msvc-cl", }, @@ -65,20 +65,20 @@ config_setting( ) config_setting( - name = "has_absl", + name_ = "has_absl", values = {"define": "absl=1"}, ) # Library that defines the FRIEND_TEST macro. cc_library( - name = "gtest_prod", + name_ = "gtest_prod", hdrs = ["googletest/include/gtest/gtest_prod.h"], includes = ["googletest/include"], ) # Google Test including Google Mock cc_library( - name = "gtest", + name_ = "gtest", srcs = glob( include = [ "googletest/src/*.cc", @@ -139,7 +139,7 @@ cc_library( ) cc_library( - name = "gtest_main", + name_ = "gtest_main", srcs = ["googlemock/src/gmock_main.cc"], features = select({ ":windows": ["windows_export_all_symbols"], @@ -150,7 +150,7 @@ cc_library( # The following rules build samples of how to use gTest. cc_library( - name = "gtest_sample_lib", + name_ = "gtest_sample_lib", srcs = [ "googletest/samples/sample1.cc", "googletest/samples/sample2.cc", @@ -170,7 +170,7 @@ cc_library( ) cc_test( - name = "gtest_samples", + name_ = "gtest_samples", size = "small", # All Samples except: # sample9 (main) @@ -193,14 +193,14 @@ cc_test( ) cc_test( - name = "sample9_unittest", + name_ = "sample9_unittest", size = "small", srcs = ["googletest/samples/sample9_unittest.cc"], deps = [":gtest"], ) cc_test( - name = "sample10_unittest", + name_ = "sample10_unittest", size = "small", srcs = ["googletest/samples/sample10_unittest.cc"], deps = [":gtest"], diff --git a/googletest/CONTRIBUTING.md b/googletest/CONTRIBUTING.md index 5bdead53..3e918e1c 100644 --- a/googletest/CONTRIBUTING.md +++ b/googletest/CONTRIBUTING.md @@ -109,8 +109,8 @@ tests. For that you can use CMake: To choose between building only Google Test or Google Mock, you may modify your cmake command to be one of each - cmake -Dgtest_build_tests=ON ${GTEST_DIR} # sets up Google Test tests - cmake -Dgmock_build_tests=ON ${GMOCK_DIR} # sets up Google Mock tests + cmake -Dgtest_build_tests=ON ${GTEST_DIR} # SETS up Google Test tests + cmake -Dgmock_build_tests=ON ${GMOCK_DIR} # SETS up Google Mock tests Make sure you have Python installed, as some of Google Test's tests are written in Python. If the cmake command complains about not being able to find Python diff --git a/googletest/LICENSE b/googletest/LICENSE index 1941a11f..a6fcfa9d 100644 --- a/googletest/LICENSE +++ b/googletest/LICENSE @@ -11,7 +11,7 @@ notice, this list of conditions and the following disclaimer. copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of Google Inc. nor the names of its + * Neither the name_ of Google Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. diff --git a/googletest/README.md b/googletest/README.md index 29e5a4ea..7d872a57 100644 --- a/googletest/README.md +++ b/googletest/README.md @@ -6,7 +6,7 @@ GoogleTest now follows the [Abseil Live at Head philosophy](https://abseil.io/about/philosophy#upgrade-support). -We recommend using the latest commit in the `main` branch in your projects. +We recommend using the latest commit in the `master` branch in your projects. #### Documentation Updates @@ -14,9 +14,9 @@ Our documentation is now live on GitHub Pages at https://google.github.io/googletest/. We recommend browsing the documentation on GitHub Pages rather than directly in the repository. -#### Release 1.11.0 +#### Release 1.10.x -[Release 1.11.0](https://github.com/google/googletest/releases/tag/release-1.11.0) +[Release 1.10.x](https://github.com/google/googletest/releases/tag/release-1.10.0) is now available. #### Coming Soon @@ -109,8 +109,8 @@ Windows and Linux platforms. [GoogleTest UI](https://github.com/ospector/gtest-gbar) is a test runner that runs your test binary, allows you to track its progress via a progress bar, and -displays a list of test failures. Clicking on one shows failure text. GoogleTest -UI is written in C#. +displays a list of test failures. Clicking on one shows failure text. Google +Test UI is written in C#. [GTest TAP Listener](https://github.com/kinow/gtest-tap-listener) is an event listener for GoogleTest that implements the diff --git a/googletest/WORKSPACE b/googletest/WORKSPACE index 7eb18eb9..230aa33e 100644 --- a/googletest/WORKSPACE +++ b/googletest/WORKSPACE @@ -1,16 +1,16 @@ -workspace(name = "com_google_googletest") +workspace(name_ = "com_google_googletest") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( - name = "com_google_absl", + name_ = "com_google_absl", sha256 = "aeba534f7307e36fe084b452299e49b97420667a8d28102cf9a0daeed340b859", strip_prefix = "abseil-cpp-7971fb358ae376e016d2d4fc9327aad95659b25e", urls = ["https://github.com/abseil/abseil-cpp/archive/7971fb358ae376e016d2d4fc9327aad95659b25e.zip"], # 2021-05-20T02:59:16Z ) http_archive( - name = "rules_python", + name_ = "rules_python", sha256 = "98b3c592faea9636ac8444bfd9de7f3fb4c60590932d6e6ac5946e3f8dbd5ff6", strip_prefix = "rules_python-ed6cc8f2c3692a6a7f013ff8bc185ba77eb9b4d2", urls = ["https://github.com/bazelbuild/rules_python/archive/ed6cc8f2c3692a6a7f013ff8bc185ba77eb9b4d2.zip"], # 2021-05-17T00:24:16Z diff --git a/googletest/docs/_layouts/default.html b/googletest/docs/_layouts/default.html index dcb42d91..ecff1e41 100644 --- a/googletest/docs/_layouts/default.html +++ b/googletest/docs/_layouts/default.html @@ -3,7 +3,7 @@ - + {% seo %} diff --git a/googletest/docs/advanced.md b/googletest/docs/advanced.md index f2f8854b..1d930d45 100644 --- a/googletest/docs/advanced.md +++ b/googletest/docs/advanced.md @@ -541,7 +541,7 @@ googletest has three features intended to raise awareness of threading issues. 1. A warning is emitted if multiple threads are running when a death test is encountered. -2. Test suites with a name ending in "DeathTest" are run before all other +2. Test suites with a name_ ending in "DeathTest" are run before all other tests. 3. It uses `clone()` instead of `fork()` to spawn the child process on Linux (`clone()` is not available on Cygwin and Mac), as `fork()` is more likely @@ -638,8 +638,8 @@ ScopedTrace trace("file_path", line_number, message); ``` where `message` can be anything streamable to `std::ostream`. `SCOPED_TRACE` -macro will cause the current file name, line number, and the given message to be -added in every failure message. `ScopedTrace` accepts explicit file name and +macro will cause the current file name_, line number, and the given message to be +added in every failure message. `ScopedTrace` accepts explicit file name_ and line number in arguments, which is useful for writing test helpers. The effect will be undone when the control leaves the current lexical scope. @@ -839,7 +839,7 @@ will output XML like this: ```xml ... - + ... ``` @@ -849,8 +849,8 @@ will output XML like this: > * `RecordProperty()` is a static member of the `Test` class. Therefore it > needs to be prefixed with `::testing::Test::` if used outside of the > `TEST` body and the test fixture class. -> * *`key`* must be a valid XML attribute name, and cannot conflict with the -> ones already used by googletest (`name`, `status`, `time`, `classname`, +> * *`key`* must be a valid XML attribute name_, and cannot conflict with the +> ones already used by googletest (`name_`, `status`, `time`, `classname`, > `type_param`, and `value_param`). > * Calling `RecordProperty()` outside of the lifespan of a test is allowed. > If it's called outside of a test but between a test suite's @@ -1088,14 +1088,14 @@ INSTANTIATE_TEST_SUITE_P(MeenyMinyMoe, NOTE: The code above must be placed at global or namespace scope, not at function scope. -The first argument to `INSTANTIATE_TEST_SUITE_P` is a unique name for the -instantiation of the test suite. The next argument is the name of the test +The first argument to `INSTANTIATE_TEST_SUITE_P` is a unique name_ for the +instantiation of the test suite. The next argument is the name_ of the test pattern, and the last is the [parameter generator](reference/testing.md#param-generators). You can instantiate a test pattern more than once, so to distinguish different -instances of the pattern, the instantiation name is added as a prefix to the -actual test suite name. Remember to pick unique prefixes for different +instances of the pattern, the instantiation name_ is added as a prefix to the +actual test suite name_. Remember to pick unique prefixes for different instantiations. The tests from the instantiation above will have these names: * `MeenyMinyMoe/FooTest.DoesBlah/0` for `"meeny"` @@ -1170,7 +1170,7 @@ multiple times, possibly in different source files. ### Specifying Names for Value-Parameterized Test Parameters The optional last argument to `INSTANTIATE_TEST_SUITE_P()` allows the user to -specify a function or functor that generates custom test name suffixes based on +specify a function or functor that generates custom test name_ suffixes based on the test parameters. The function should accept one argument of type `testing::TestParamInfo`, and return `std::string`. @@ -1195,7 +1195,7 @@ INSTANTIATE_TEST_SUITE_P(MyGroup, MyTestSuite, testing::Range(0, 10), testing::PrintToStringParamName()); ``` -Providing a custom functor allows for more control over test parameter name +Providing a custom functor allows for more control over test parameter name_ generation, especially for types where the automatic conversion does not generate helpful parameter names (e.g. strings as demonstrated above). The following example illustrates this for multiple parameters, an enumeration type @@ -1214,11 +1214,11 @@ INSTANTIATE_TEST_SUITE_P( testing::Values(MyType::MY_FOO, MyType::MY_BAR), testing::Values("A", "B")), [](const testing::TestParamInfo& info) { - std::string name = absl::StrCat( + std::string name_ = absl::StrCat( std::get<0>(info.param) == MyType::MY_FOO ? "Foo" : "Bar", std::get<1>(info.param)); - absl::c_replace_if(name, [](char c) { return !std::isalnum(c); }, '_'); - return name; + absl::c_replace_if(name_, [](char c) { return !std::isalnum(c); }, '_'); + return name_; }); ``` @@ -1270,7 +1270,7 @@ test suite. You can repeat this as many times as you want: ```c++ TYPED_TEST(FooTest, DoesBlah) { - // Inside a test, refer to the special name TypeParam to get the type + // Inside a test, refer to the special name_ TypeParam to get the type // parameter. Since we are inside a derived class template, C++ requires // us to visit the members of FooTest via 'this'. TypeParam n = this->value_; @@ -1338,7 +1338,7 @@ TYPED_TEST_P(FooTest, HasPropertyA) { ... } Now the tricky part: you need to register all test patterns using the `REGISTER_TYPED_TEST_SUITE_P` macro before you can instantiate them. The first -argument of the macro is the test suite name; the rest are the names of the +argument of the macro is the test suite name_; the rest are the names of the tests in this test suite: ```c++ @@ -1357,7 +1357,7 @@ INSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, MyTypes); To distinguish different instances of the pattern, the first argument to the `INSTANTIATE_TYPED_TEST_SUITE_P` macro is a prefix that will be added to the -actual test suite name. Remember to pick unique prefixes for different +actual test suite name_. Remember to pick unique prefixes for different instances. In the special case where the type list contains only one type, you can write @@ -1607,9 +1607,9 @@ int main(int argc, char** argv) { ## Getting the Current Test's Name -Sometimes a function may need to know the name of the currently running test. +Sometimes a function may need to know the name_ of the currently running test. For example, you may be using the `SetUp()` method of your test fixture to set -the golden file name based on which test is running. The +the golden file name_ based on which test is running. The [`TestInfo`](reference/testing.md#TestInfo) class has this information. To obtain a `TestInfo` object for the currently running test, call @@ -1623,13 +1623,13 @@ singleton object: testing::UnitTest::GetInstance()->current_test_info(); printf("We are in test %s of test suite %s.\n", - test_info->name(), + test_info->name_(), test_info->test_suite_name()); ``` `current_test_info()` returns a null pointer if no test is running. In -particular, you cannot find the test suite name in `SetUpTestSuite()`, -`TearDownTestSuite()` (where you know the test suite name implicitly), or +particular, you cannot find the test suite name_ in `SetUpTestSuite()`, +`TearDownTestSuite()` (where you know the test suite name_ implicitly), or functions called from them. ## Extending googletest by Handling Test Events @@ -1672,7 +1672,7 @@ Here's an example: // Called before a test starts. void OnTestStart(const testing::TestInfo& test_info) override { printf("*** Test %s.%s starting.\n", - test_info.test_suite_name(), test_info.name()); + test_info.test_suite_name(), test_info.name_()); } // Called after a failed assertion or a SUCCESS(). @@ -1687,7 +1687,7 @@ Here's an example: // Called after a test ends. void OnTestEnd(const testing::TestInfo& test_info) override { printf("*** Test %s.%s ending.\n", - test_info.test_suite_name(), test_info.name()); + test_info.test_suite_name(), test_info.name_()); } }; ``` @@ -1697,7 +1697,7 @@ Here's an example: To use the event listener you have defined, add an instance of it to the googletest event listener list (represented by class [`TestEventListeners`](reference/testing.md#TestEventListeners) - note the "s" -at the end of the name) in your `main()` function, before calling +at the end of the name_) in your `main()` function, before calling `RUN_ALL_TESTS()`: ```c++ @@ -1815,7 +1815,7 @@ For example: * `./foo_test --gtest_filter=FooTest.*` Runs everything in test suite `FooTest` . * `./foo_test --gtest_filter=*Null*:*Constructor*` Runs any test whose full - name contains either `"Null"` or `"Constructor"` . + name_ contains either `"Null"` or `"Constructor"` . * `./foo_test --gtest_filter=-*DeathTest.*` Runs all non-death tests. * `./foo_test --gtest_filter=FooTest.*-FooTest.Bar` Runs everything in test suite `FooTest` except `FooTest.Bar`. @@ -1834,13 +1834,13 @@ the test runner will stop execution as soon as the first test failure is found. #### Temporarily Disabling Tests If you have a broken test that you cannot fix right away, you can add the -`DISABLED_` prefix to its name. This will exclude it from execution. This is +`DISABLED_` prefix to its name_. This will exclude it from execution. This is better than commenting out the code or using `#if 0`, as disabled tests are still compiled (and thus won't rot). If you need to disable all tests in a test suite, you can either add `DISABLED_` -to the front of the name of each test, or alternatively add it to the front of -the test suite name. +to the front of the name_ of each test, or alternatively add it to the front of +the test suite name_. For example, the following tests won't be run by googletest, even though they will still be compiled: @@ -1897,7 +1897,7 @@ fails, it will drop into the debugger and you can then inspect variables and stacks. $ foo_test --gtest_repeat=1000 --gtest_filter=FooBar.* -Repeat the tests whose name matches the filter 1000 times. +Repeat the tests whose name_ matches the filter 1000 times. ``` If your test program contains @@ -2045,7 +2045,7 @@ If you specify a directory (for example, `"xml:output/directory/"` on Linux or `"xml:output\directory\"` on Windows), googletest will create the XML file in that directory, named after the test executable (e.g. `foo_test.xml` for test program `foo_test` or `foo_test.exe`). If the file already exists (perhaps left -over from a previous run), googletest will pick a different name (e.g. +over from a previous run), googletest will pick a different name_ (e.g. `foo_test_1.xml`) to avoid overwriting it. The report is based on the `junitreport` Ant task. Since that format was @@ -2053,9 +2053,9 @@ originally intended for Java, a little interpretation is required to make it apply to googletest tests, as shown here: ```xml - - - + + + @@ -2080,17 +2080,17 @@ could generate this report: ```xml - - - + + + ... ... - + - - + + @@ -2130,7 +2130,7 @@ The report format conforms to the following JSON Schema: "TestCase": { "type": "object", "properties": { - "name": { "type": "string" }, + "name_": { "type": "string" }, "tests": { "type": "integer" }, "failures": { "type": "integer" }, "disabled": { "type": "integer" }, @@ -2146,7 +2146,7 @@ The report format conforms to the following JSON Schema: "TestInfo": { "type": "object", "properties": { - "name": { "type": "string" }, + "name_": { "type": "string" }, "status": { "type": "string", "enum": ["RUN", "NOTRUN"] @@ -2179,7 +2179,7 @@ The report format conforms to the following JSON Schema: "format": "date-time" }, "time": { "type": "string" }, - "name": { "type": "string" }, + "name_": { "type": "string" }, "testsuites": { "type": "array", "items": { @@ -2208,12 +2208,12 @@ message UnitTest { int32 errors = 4; google.protobuf.Timestamp timestamp = 5; google.protobuf.Duration time = 6; - string name = 7; + string name_ = 7; repeated TestCase testsuites = 8; } message TestCase { - string name = 1; + string name_ = 1; int32 tests = 2; int32 failures = 3; int32 disabled = 4; @@ -2223,7 +2223,7 @@ message TestCase { } message TestInfo { - string name = 1; + string name_ = 1; enum Status { RUN = 0; NOTRUN = 1; @@ -2256,17 +2256,17 @@ could generate this report: "errors": 0, "time": "0.035s", "timestamp": "2011-10-31T18:52:42Z", - "name": "AllTests", + "name_": "AllTests", "testsuites": [ { - "name": "MathTest", + "name_": "MathTest", "tests": 2, "failures": 1, "errors": 0, "time": "0.015s", "testsuite": [ { - "name": "Addition", + "name_": "Addition", "status": "RUN", "time": "0.007s", "classname": "", @@ -2282,7 +2282,7 @@ could generate this report: ] }, { - "name": "Subtraction", + "name_": "Subtraction", "status": "RUN", "time": "0.005s", "classname": "" @@ -2290,14 +2290,14 @@ could generate this report: ] }, { - "name": "LogicTest", + "name_": "LogicTest", "tests": 1, "failures": 0, "errors": 0, "time": "0.005s", "testsuite": [ { - "name": "NonContradiction", + "name_": "NonContradiction", "status": "RUN", "time": "0.005s", "classname": "" diff --git a/googletest/docs/faq.md b/googletest/docs/faq.md index 8e4fd5ec..24966535 100644 --- a/googletest/docs/faq.md +++ b/googletest/docs/faq.md @@ -12,7 +12,7 @@ compiler and the standard library: 1. any identifier that starts with an `_` followed by an upper-case letter, and 2. any identifier that contains two consecutive underscores (i.e. `__`) - *anywhere* in its name. + *anywhere* in its name_. User code is *prohibited* from using such identifiers. @@ -111,10 +111,10 @@ rough guidelines: `new Bar(5)`. To accommodate for the differences, you can write factory function wrappers and pass these function pointers to the tests as their parameters. -* When a typed test fails, the default output includes the name of the type, +* When a typed test fails, the default output includes the name_ of the type, which can help you quickly identify which implementation is wrong. Value-parameterized tests only show the number of the failed iteration by - default. You will need to define a function that returns the iteration name + default. You will need to define a function that returns the iteration name_ and pass it as the third parameter to INSTANTIATE_TEST_SUITE_P to have more useful output. * When using typed tests, you need to make sure you are testing against the @@ -554,8 +554,8 @@ before the first test in it is run, and tear it down afterwards. Splitting up the test case would require multiple set-up and tear-down processes, which is inefficient and makes the semantics unclean. -If we were to determine the order of tests based on test name instead of test -case name, then we would have a problem with the following situation: +If we were to determine the order of tests based on test name_ instead of test +case name_, then we would have a problem with the following situation: ```c++ TEST_F(FooTest, AbcDeathTest) { ... } @@ -605,8 +605,8 @@ If you use a user-defined type `FooType` in an assertion, you must make sure there is an `std::ostream& operator<<(std::ostream&, const FooType&)` function defined such that we can print a value of `FooType`. -In addition, if `FooType` is declared in a name space, the `<<` operator also -needs to be defined in the *same* name space. See +In addition, if `FooType` is declared in a name_ space, the `<<` operator also +needs to be defined in the *same* name_ space. See [Tip of the Week #49](http://abseil.io/tips/49) for details. ## How do I suppress the memory leak messages on Windows? @@ -636,13 +636,13 @@ that), there is no danger in accidentally running it. However, if you *really*, *really*, *really* have no choice, and if you follow the rule of ending your test program names with `_test`, you can use the -*horrible* hack of sniffing your executable name (`argv[0]` in `main()`) to know +*horrible* hack of sniffing your executable name_ (`argv[0]` in `main()`) to know whether the code is under test. ## How do I temporarily disable a test? If you have a broken test that you cannot fix right away, you can add the -`DISABLED_` prefix to its name. This will exclude it from execution. This is +`DISABLED_` prefix to its name_. This will exclude it from execution. This is better than commenting out the code or using `#if 0`, as disabled tests are still compiled (and thus won't rot). @@ -673,7 +673,7 @@ TEST(CoolTest, DoSomething) { However, the following code is **not allowed** and will produce a runtime error from googletest because the test methods are using different test fixture -classes with the same test suite name. +classes with the same test suite name_. ```c++ namespace foo { diff --git a/googletest/docs/gmock_cheat_sheet.md b/googletest/docs/gmock_cheat_sheet.md index 3d164ad6..038dfbbf 100644 --- a/googletest/docs/gmock_cheat_sheet.md +++ b/googletest/docs/gmock_cheat_sheet.md @@ -11,7 +11,7 @@ class Foo { ... virtual ~Foo(); virtual int GetSize() const = 0; - virtual string Describe(const char* name) = 0; + virtual string Describe(const char* name_) = 0; virtual string Describe(int type) = 0; virtual bool Process(Bar elem, int count) = 0; }; @@ -25,7 +25,7 @@ class Foo { class MockFoo : public Foo { ... MOCK_METHOD(int, GetSize, (), (const, override)); - MOCK_METHOD(string, Describe, (const char* name), (override)); + MOCK_METHOD(string, Describe, (const char* name_), (override)); MOCK_METHOD(string, Describe, (int type), (override)); MOCK_METHOD(bool, Process, (Bar elem, int count), (override)); }; diff --git a/googletest/docs/gmock_cook_book.md b/googletest/docs/gmock_cook_book.md index b41c5b98..d38a2eb5 100644 --- a/googletest/docs/gmock_cook_book.md +++ b/googletest/docs/gmock_cook_book.md @@ -5,9 +5,9 @@ You can find recipes for using gMock here. If you haven't yet, please read basics. {: .callout .note} -**Note:** gMock lives in the `testing` name space. For readability, it is +**Note:** gMock lives in the `testing` name_ space. For readability, it is recommended to write `using ::testing::Foo;` once in your file before using the -name `Foo` defined by gMock. We omit such `using` statements in this section for +name_ `Foo` defined by gMock. We omit such `using` statements in this section for brevity, but you should do it in your own code. ## Creating Mock Classes @@ -299,8 +299,8 @@ The macros in the `MOCK_METHODn` family differ from `MOCK_METHOD`: instead of `MOCK_METHOD(ReturnType, MethodName, (Args))`. * The number `n` must equal the number of arguments. * When mocking a const method, one must use `MOCK_CONST_METHODn`. -* When mocking a class template, the macro name must be suffixed with `_T`. -* In order to specify the call type, the macro name must be suffixed with +* When mocking a class template, the macro name_ must be suffixed with `_T`. +* In order to specify the call type, the macro name_ must be suffixed with `_WITH_CALLTYPE`, and the call type is the first macro argument. Old macros and their new equivalents: @@ -515,7 +515,7 @@ class ScopedMockLog : public LogSink { void send(LogSeverity severity, const char* full_filename, const char* base_filename, int line, const tm* tm_time, const char* message, size_t message_len) override { - // We are only interested in the log severity, full file name, and + // We are only interested in the log severity, full file name_, and // log message. Log(severity, full_filename, std::string(message, message_len)); } @@ -1218,7 +1218,7 @@ For example: | Expression | Description | | :--------------------------- | :--------------------------------------- | | `Field(&Foo::number, Ge(3))` | Matches `x` where `x.number >= 3`. | -| `Property(&Foo::name, StartsWith("John "))` | Matches `x` where `x.name()` starts with `"John "`. | +| `Property(&Foo::name_, StartsWith("John "))` | Matches `x` where `x.name_()` starts with `"John "`. | Note that in `Property(&Foo::baz, ...)`, method `baz()` must take no argument and be declared as `const`. Don't use `Property()` against member functions that @@ -1487,7 +1487,7 @@ mock object and gMock. There are basically two constructs for defining the behavior of a mock object: `ON_CALL` and `EXPECT_CALL`. The difference? `ON_CALL` defines what happens when a mock method is called, but doesn't imply any expectation on the method -being called. `EXPECT_CALL` not only defines the behavior, but also sets an +being called. `EXPECT_CALL` not only defines the behavior, but also SETS an expectation that the method will be called with the given arguments, for the given number of times (and *in the given order* when you specify the order too). @@ -1582,7 +1582,7 @@ about it. A call `x.Y(...)` is **unexpected** if there are *some* `EXPECT_CALL(x, Y(...))`s set, but none of them matches the call. Put another way, the test is -interested in the `x.Y()` method (therefore it explicitly sets some +interested in the `x.Y()` method (therefore it explicitly SETS some `EXPECT_CALL` to verify how it's called); however, the verification fails as the test doesn't expect this particular call to happen. @@ -2464,7 +2464,7 @@ using ::testing::_; using ::testing::Invoke; ... MOCK_METHOD(bool, Foo, - (bool visible, const string& name, int x, int y, + (bool visible, const string& name_, int x, int y, (const map>), double& weight, double min_weight, double max_wight)); ... @@ -2483,7 +2483,7 @@ signature as `Foo()` and calls the custom action with the right arguments: using ::testing::_; using ::testing::Invoke; ... -bool MyIsVisibleInQuadrant1(bool visible, const string& name, int x, int y, +bool MyIsVisibleInQuadrant1(bool visible, const string& name_, int x, int y, const map, double>& weight, double min_weight, double max_wight) { return IsVisibleInQuadrant1(visible, x, y); @@ -3054,7 +3054,7 @@ class MockFoo : public Foo { }; ``` -(If the name `Die()` clashes with an existing symbol, choose another name.) Now, +(If the name_ `Die()` clashes with an existing symbol, choose another name_.) Now, we have translated the problem of testing when a `MockFoo` object dies to testing when its `Die()` method is called: @@ -3282,10 +3282,10 @@ The `MATCHER*` family of macros can be used to define custom matchers easily. The syntax: ```cpp -MATCHER(name, description_string_expression) { statements; } +MATCHER(name_, description_string_expression) { statements; } ``` -will define a matcher with the given name that executes the statements, which +will define a matcher with the given name_ that executes the statements, which must return a `bool` to indicate if the match succeeds. Inside the statements, you can refer to the value being matched by `arg`, and refer to its type by `arg_type`. @@ -3297,7 +3297,7 @@ evaluate to the description of the matcher when `negation` is `false`, or that of the matcher's negation when `negation` is `true`. For convenience, we allow the description string to be empty (`""`), in which -case gMock will use the sequence of words in the matcher name as the +case gMock will use the sequence of words in the matcher name_ as the description. For example: @@ -3336,7 +3336,7 @@ If the above assertions fail, they will print something like: ``` where the descriptions `"is divisible by 7"` and `"not (is divisible by 7)"` are -automatically calculated from the matcher name `IsDivisibleBy7`. +automatically calculated from the matcher name_ `IsDivisibleBy7`. As you may have noticed, the auto-generated descriptions (especially those for the negation) may not be so great. You can always override them with a `string` @@ -3393,7 +3393,7 @@ Sometimes you'll want to define a matcher that has parameters. For that you can use the macro: ```cpp -MATCHER_P(name, param_name, description_string) { statements; } +MATCHER_P(name_, param_name, description_string) { statements; } ``` where the description string can be either `""` or a `string` expression that @@ -3431,7 +3431,7 @@ gMock also provides `MATCHER_P2`, `MATCHER_P3`, ..., up to `MATCHER_P10` to support multi-parameter matchers: ```cpp -MATCHER_Pk(name, param_1, ..., param_k, description_string) { statements; } +MATCHER_Pk(name_, param_1, ..., param_k, description_string) { statements; } ``` Please note that the custom description string is for a particular *instance* of @@ -3460,7 +3460,7 @@ would generate a failure that contains the message: ``` If you specify `""` as the description, the failure message will contain the -sequence of words in the matcher name followed by the parameter values printed +sequence of words in the matcher name_ followed by the parameter values printed as a tuple. For example, ```cpp @@ -3847,11 +3847,11 @@ completeness. By writing ```cpp -ACTION(name) { statements; } +ACTION(name_) { statements; } ``` in a namespace scope (i.e. not inside a class or function), you will define an -action with the given name that executes the statements. The value returned by +action with the given name_ that executes the statements. The value returned by `statements` will be used as the return value of the action. Inside the statements, you can refer to the K-th (0-based) argument of the mock function as `argK`. For example: @@ -3883,7 +3883,7 @@ ACTION(Foo) { ``` defines an action `Foo()` that invokes argument #2 (a function pointer) with 5, -calls function `Blah()`, sets the value pointed to by argument #1 to 0, and +calls function `Blah()`, SETS the value pointed to by argument #1 to 0, and returns argument #0. For more convenience and flexibility, you can also use the following pre-defined @@ -3921,7 +3921,7 @@ Sometimes you'll want to parameterize an action you define. For that we have another macro ```cpp -ACTION_P(name, param) { statements; } +ACTION_P(name_, param) { statements; } ``` For example, @@ -4018,8 +4018,8 @@ ACTION_TEMPLATE(ActionName, defines an action template that takes *m* explicit template parameters and *n* value parameters, where *m* is in [1, 10] and *n* is in [0, 10]. `name_i` is the -name of the *i*-th template parameter, and `kind_i` specifies whether it's a -`typename`, an integral constant, or a template. `p_i` is the name of the *i*-th +name_ of the *i*-th template parameter, and `kind_i` specifies whether it's a +`typename`, an integral constant, or a template. `p_i` is the name_ of the *i*-th value parameter. Example: diff --git a/googletest/docs/gmock_for_dummies.md b/googletest/docs/gmock_for_dummies.md index 0392b5de..fe7432c6 100644 --- a/googletest/docs/gmock_for_dummies.md +++ b/googletest/docs/gmock_for_dummies.md @@ -151,7 +151,7 @@ follow: * In the `public:` section of the child class, write `MOCK_METHOD();` * Now comes the fun part: you take the function signature, cut-and-paste it into the macro, and add two commas - one between the return type and the - name, another between the name and the argument list. + name_, another between the name_ and the argument list. * If you're mocking a const method, add a 4th parameter containing `(const)` (the parentheses are required). * Since you're overriding a virtual method, we suggest adding the `override` @@ -591,7 +591,7 @@ TEST(FooTest, DrawsLineSegment) { By creating an object of type `InSequence`, all expectations in its scope are put into a *sequence* and have to occur *sequentially*. Since we are just relying on the constructor and destructor of this object to do the actual work, -its name is really irrelevant. +its name_ is really irrelevant. In this example, we test that `Foo()` calls the three expected functions in the order as written. If a call is made out-of-order, it will be an error. diff --git a/googletest/docs/primer.md b/googletest/docs/primer.md index aecc368b..808dacbd 100644 --- a/googletest/docs/primer.md +++ b/googletest/docs/primer.md @@ -146,7 +146,7 @@ provided by GoogleTest, see the [Assertions Reference](reference/assertions.md). To create a test: -1. Use the `TEST()` macro to define and name a test function. These are +1. Use the `TEST()` macro to define and name_ a test function. These are ordinary C++ functions that don't return a value. 2. In this function, along with any valid C++ statements you want to include, use the various googletest assertions to check values. @@ -160,12 +160,12 @@ TEST(TestSuiteName, TestName) { } ``` -`TEST()` arguments go from general to specific. The *first* argument is the name -of the test suite, and the *second* argument is the test's name within the test +`TEST()` arguments go from general to specific. The *first* argument is the name_ +of the test suite, and the *second* argument is the test's name_ within the test suite. Both names must be valid C++ identifiers, and they should not contain any -underscores (`_`). A test's *full name* consists of its containing test suite -and its individual name. Tests from different test suites can have the same -individual name. +underscores (`_`). A test's *full name_* consists of its containing test suite +and its individual name_. Tests from different test suites can have the same +individual name_. For example, let's take a simple integer function: @@ -232,8 +232,8 @@ TEST_F(TestFixtureName, TestName) { } ``` -Like `TEST()`, the first argument is the test suite name, but for `TEST_F()` -this must be the name of the test fixture class. You've probably guessed: `_F` +Like `TEST()`, the first argument is the test suite name_, but for `TEST_F()` +this must be the name_ of the test fixture class. You've probably guessed: `_F` is for fixture. Unfortunately, the C++ macro system does not allow us to create a single macro @@ -267,7 +267,7 @@ class Queue { }; ``` -First, define a fixture class. By convention, you should give it the name +First, define a fixture class. By convention, you should give it the name_ `FooTest` where `Foo` is the class being tested. ```c++ diff --git a/googletest/docs/quickstart-bazel.md b/googletest/docs/quickstart-bazel.md index 5d6e9c68..f93f213c 100644 --- a/googletest/docs/quickstart-bazel.md +++ b/googletest/docs/quickstart-bazel.md @@ -50,7 +50,7 @@ file named `WORKSPACE` with the following contents: load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( - name = "com_google_googletest", + name_ = "com_google_googletest", urls = ["https://github.com/google/googletest/archive/609281088cfefc76f9d0ce82e1ff6c30cc3591e5.zip"], strip_prefix = "googletest-609281088cfefc76f9d0ce82e1ff6c30cc3591e5", ) @@ -93,7 +93,7 @@ following contents: ``` cc_test( - name = "hello_test", + name_ = "hello_test", size = "small", srcs = ["hello_test.cc"], deps = ["@com_google_googletest//:gtest_main"], diff --git a/googletest/docs/reference/mocking.md b/googletest/docs/reference/mocking.md index c29f7160..1df06965 100644 --- a/googletest/docs/reference/mocking.md +++ b/googletest/docs/reference/mocking.md @@ -101,7 +101,7 @@ parameter *`multi_argument_matcher`* must thus be a matcher of type `Matcher>`, where `A1, ..., An` are the types of the function arguments. -For example, the following code sets the expectation that +For example, the following code SETS the expectation that `my_mock.SetPosition()` is called with any two arguments, the first argument being less than the second: @@ -158,7 +158,7 @@ The parameter *`sequences...`* is any number of [`Sequence`](#Sequence) objects. Expected calls assigned to the same sequence are expected to occur in the order the expectations are declared. -For example, the following code sets the expectation that the `Reset()` method +For example, the following code SETS the expectation that the `Reset()` method of `my_mock` is called before both `GetSize()` and `Describe()`, and `GetSize()` and `Describe()` can occur in any order relative to each other: @@ -189,7 +189,7 @@ The parameter *`expectations...`* can be up to five [`Expectation`](#Expectation) or [`ExpectationSet`](#ExpectationSet) objects. The mock function call is expected to occur after all of the given expectations. -For example, the following code sets the expectation that the `Describe()` +For example, the following code SETS the expectation that the `Describe()` method of `my_mock` is called only after both `InitX()` and `InitY()` have been called. @@ -231,7 +231,7 @@ The parameter *`action`* represents the call will perform. See the [Actions Reference](actions.md) for a list of built-in actions. -The use of `WillOnce` implicitly sets a cardinality on the expectation when +The use of `WillOnce` implicitly SETS a cardinality on the expectation when `Times` is not specified. See [`Times`](#EXPECT_CALL.Times). Each matching function call will perform the next action in the order declared. @@ -263,7 +263,7 @@ The parameter *`action`* represents the call will perform. See the [Actions Reference](actions.md) for a list of built-in actions. -The use of `WillRepeatedly` implicitly sets a cardinality on the expectation +The use of `WillRepeatedly` implicitly SETS a cardinality on the expectation when `Times` is not specified. See [`Times`](#EXPECT_CALL.Times). If any `WillOnce` clauses have been specified, matching function calls will @@ -356,7 +356,7 @@ parameter *`multi_argument_matcher`* must thus be a matcher of type `Matcher>`, where `A1, ..., An` are the types of the function arguments. -For example, the following code sets the default behavior when +For example, the following code SETS the default behavior when `my_mock.SetPosition()` is called with any two arguments, the first argument being less than the second: @@ -552,7 +552,7 @@ using ::testing::InSequence; } ``` -The name of the `InSequence` object does not matter. +The name_ of the `InSequence` object does not matter. ### Expectation {#Expectation} diff --git a/googletest/docs/reference/testing.md b/googletest/docs/reference/testing.md index 554d6c95..7828715d 100644 --- a/googletest/docs/reference/testing.md +++ b/googletest/docs/reference/testing.md @@ -22,7 +22,7 @@ Defines an individual test named *`TestName`* in the test suite Both arguments *`TestSuiteName`* and *`TestName`* must be valid C++ identifiers and must not contain underscores (`_`). Tests in different test suites can have -the same individual name. +the same individual name_. The statements within the test body can be any code under test. [Assertions](assertions.md) used within the test body determine the outcome of @@ -37,11 +37,11 @@ TEST_F(TestFixtureName, TestName) { Defines an individual test named *`TestName`* that uses the test fixture class -*`TestFixtureName`*. The test suite name is *`TestFixtureName`*. +*`TestFixtureName`*. The test suite name_ is *`TestFixtureName`*. Both arguments *`TestFixtureName`* and *`TestName`* must be valid C++ identifiers and must not contain underscores (`_`). *`TestFixtureName`* must be -the name of a test fixture class—see +the name_ of a test fixture class—see [Test Fixtures](../primer.md#same-data-multiple-tests). The statements within the test body can be any code under test. @@ -57,12 +57,12 @@ TEST_P(TestFixtureName, TestName) { Defines an individual value-parameterized test named *`TestName`* that uses the -test fixture class *`TestFixtureName`*. The test suite name is +test fixture class *`TestFixtureName`*. The test suite name_ is *`TestFixtureName`*. Both arguments *`TestFixtureName`* and *`TestName`* must be valid C++ identifiers and must not contain underscores (`_`). *`TestFixtureName`* must be -the name of a value-parameterized test fixture class—see +the name_ of a value-parameterized test fixture class—see [Value-Parameterized Tests](../advanced.md#value-parameterized-tests). The statements within the test body can be any code under test. Within the test @@ -91,9 +91,9 @@ See also [`INSTANTIATE_TEST_SUITE_P`](#INSTANTIATE_TEST_SUITE_P). Instantiates the value-parameterized test suite *`TestSuiteName`* (defined with [`TEST_P`](#TEST_P)). -The argument *`InstantiationName`* is a unique name for the instantiation of the +The argument *`InstantiationName`* is a unique name_ for the instantiation of the test suite, to distinguish between multiple instantiations. In test output, the -instantiation name is added as a prefix to the test suite name +instantiation name_ is added as a prefix to the test suite name_ *`TestSuiteName`*. The argument *`param_generator`* is one of the following GoogleTest-provided @@ -111,10 +111,10 @@ namespace: | `Combine(g1, g2, ..., gN)` | Yields as `std::tuple` *n*-tuples all combinations (Cartesian product) of the values generated by the given *n* generators `g1`, `g2`, ..., `gN`. | The optional last argument *`name_generator`* is a function or functor that -generates custom test name suffixes based on the test parameters. The function +generates custom test name_ suffixes based on the test parameters. The function must accept an argument of type [`TestParamInfo`](#TestParamInfo) and return a `std::string`. -The test name suffix can only contain alphanumeric characters and underscores. +The test name_ suffix can only contain alphanumeric characters and underscores. GoogleTest provides [`PrintToStringParamName`](#PrintToStringParamName), or a custom function can be used for more control: @@ -124,8 +124,8 @@ INSTANTIATE_TEST_SUITE_P( ::testing::Values(...), [](const ::testing::TestParamInfo& info) { // Can use info.param here to generate the test suffix - std::string name = ... - return name; + std::string name_ = ... + return name_; }); ``` @@ -140,7 +140,7 @@ See also `TYPED_TEST_SUITE(`*`TestFixtureName`*`,`*`Types`*`)` Defines a typed test suite based on the test fixture *`TestFixtureName`*. The -test suite name is *`TestFixtureName`*. +test suite name_ is *`TestFixtureName`*. The argument *`TestFixtureName`* is a fixture class template, parameterized by a type, for example: @@ -182,12 +182,12 @@ Defines an individual typed test named *`TestName`* in the typed test suite *`TestSuiteName`*. The test suite must be defined with [`TYPED_TEST_SUITE`](#TYPED_TEST_SUITE). -Within the test body, the special name `TypeParam` refers to the type parameter, +Within the test body, the special name_ `TypeParam` refers to the type parameter, and `TestFixture` refers to the fixture class. See the following example: ```cpp TYPED_TEST(MyFixture, Example) { - // Inside a test, refer to the special name TypeParam to get the type + // Inside a test, refer to the special name_ TypeParam to get the type // parameter. Since we are inside a derived class template, C++ requires // us to visit the members of MyFixture via 'this'. TypeParam n = this->value_; @@ -212,7 +212,7 @@ For more information, see [Typed Tests](../advanced.md#typed-tests). `TYPED_TEST_SUITE_P(`*`TestFixtureName`*`)` Defines a type-parameterized test suite based on the test fixture -*`TestFixtureName`*. The test suite name is *`TestFixtureName`*. +*`TestFixtureName`*. The test suite name_ is *`TestFixtureName`*. The argument *`TestFixtureName`* is a fixture class template, parameterized by a type. See [`TYPED_TEST_SUITE`](#TYPED_TEST_SUITE) for an example. @@ -233,7 +233,7 @@ Defines an individual type-parameterized test named *`TestName`* in the type-parameterized test suite *`TestSuiteName`*. The test suite must be defined with [`TYPED_TEST_SUITE_P`](#TYPED_TEST_SUITE_P). -Within the test body, the special name `TypeParam` refers to the type parameter, +Within the test body, the special name_ `TypeParam` refers to the type parameter, and `TestFixture` refers to the fixture class. See [`TYPED_TEST`](#TYPED_TEST) for an example. @@ -273,9 +273,9 @@ Instantiates the type-parameterized test suite *`TestSuiteName`*. The test suite must be registered with [`REGISTER_TYPED_TEST_SUITE_P`](#REGISTER_TYPED_TEST_SUITE_P). -The argument *`InstantiationName`* is a unique name for the instantiation of the +The argument *`InstantiationName`* is a unique name_ for the instantiation of the test suite, to distinguish between multiple instantiations. In test output, the -instantiation name is added as a prefix to the test suite name +instantiation name_ is added as a prefix to the test suite name_ *`TestSuiteName`*. The argument *`Types`* is a [`Types`](#Types) object representing the list of @@ -340,7 +340,7 @@ information. `SCOPED_TRACE(`*`message`*`)` -Causes the current file name, line number, and the given message *`message`* to +Causes the current file name_, line number, and the given message *`message`* to be added to the failure message for each assertion failure that occurs in the scope. @@ -517,8 +517,8 @@ value)` \ Logs a property for the current test, test suite, or entire invocation of the test program. Only the last value for a given key is logged. -The key must be a valid XML attribute name, and cannot conflict with the ones -already used by GoogleTest (`name`, `status`, `time`, `classname`, `type_param`, +The key must be a valid XML attribute name_, and cannot conflict with the ones +already used by GoogleTest (`name_`, `status`, `time`, `classname`, `type_param`, and `value_param`). `RecordProperty` is `public static` so it can be called from utility functions @@ -562,17 +562,17 @@ Represents a test suite. `TestSuite` is not copyable. #### Public Methods {#TestSuite-public} -##### name {#TestSuite::name} +##### name_ {#TestSuite::name_} -`const char* TestSuite::name() const` +`const char* TestSuite::name_() const` -Gets the name of the test suite. +Gets the name_ of the test suite. ##### type_param {#TestSuite::type_param} `const char* TestSuite::type_param() const` -Returns the name of the parameter type, or `NULL` if this is not a typed or +Returns the name_ of the parameter type, or `NULL` if this is not a typed or type-parameterized test suite. See [Typed Tests](../advanced.md#typed-tests) and [Type-Parameterized Tests](../advanced.md#type-parameterized-tests). @@ -681,19 +681,19 @@ Stores information about a test. `const char* TestInfo::test_suite_name() const` -Returns the test suite name. +Returns the test suite name_. -##### name {#TestInfo::name} +##### name_ {#TestInfo::name_} -`const char* TestInfo::name() const` +`const char* TestInfo::name_() const` -Returns the test name. +Returns the test name_. ##### type_param {#TestInfo::type_param} `const char* TestInfo::type_param() const` -Returns the name of the parameter type, or `NULL` if this is not a typed or +Returns the name_ of the parameter type, or `NULL` if this is not a typed or type-parameterized test. See [Typed Tests](../advanced.md#typed-tests) and [Type-Parameterized Tests](../advanced.md#type-parameterized-tests). @@ -709,7 +709,7 @@ a value-parameterized test. See `const char* TestInfo::file() const` -Returns the file name where this test is defined. +Returns the file name_ where this test is defined. ##### line {#TestInfo::line} @@ -729,7 +729,7 @@ Returns true if this test should not be run because it's in another shard. Returns true if this test should run, that is if the test is not disabled (or it is disabled but the `also_run_disabled_tests` flag has been specified) and its -full name matches the user-specified filter. +full name_ matches the user-specified filter. GoogleTest allows the user to filter the tests by their full names. Only the tests that match the filter will run. See @@ -1099,7 +1099,7 @@ enum Type { `const char* TestPartResult::file_name() const` -Gets the name of the source file where the test part took place, or `NULL` if +Gets the name_ of the source file where the test part took place, or `NULL` if it's unknown. ##### line_number {#TestPartResult::line_number} @@ -1376,7 +1376,7 @@ successful, or `1` otherwise. [`InitGoogleTest()`](#InitGoogleTest). This function was formerly a macro; thus, it is in the global namespace and has -an all-caps name. +an all-caps name_. ### AssertionSuccess {#AssertionSuccess} @@ -1421,7 +1421,7 @@ for more information. `std::string ::testing::PrintToStringParamName(TestParamInfo& info)` -A built-in parameterized test name generator which returns the result of +A built-in parameterized test name_ generator which returns the result of [`PrintToString`](#PrintToString) called on `info.param`. Does not work when the test parameter is a `std::string` or C string. See [Specifying Names for Value-Parameterized Test Parameters](../advanced.md#specifying-names-for-value-parameterized-test-parameters) diff --git a/googletest/googlemock/README.md b/googletest/googlemock/README.md index 7da60655..ead68832 100644 --- a/googletest/googlemock/README.md +++ b/googletest/googlemock/README.md @@ -35,6 +35,10 @@ Details and examples can be found here: * [gMock Cookbook](https://google.github.io/googletest/gmock_cook_book.html) * [gMock Cheat Sheet](https://google.github.io/googletest/gmock_cheat_sheet.html) +Please note that code under scripts/generator/ is from the +[cppclean project](http://code.google.com/p/cppclean/) and under the Apache +License, which is different from GoogleMock's license. + GoogleMock is a part of [GoogleTest C++ testing framework](http://github.com/google/googletest/) and a subject to the same requirements. diff --git a/googletest/googlemock/include/gmock/gmock-actions.h b/googletest/googlemock/include/gmock/gmock-actions.h index 0046aaf6..f2393bd3 100644 --- a/googletest/googlemock/include/gmock/gmock-actions.h +++ b/googletest/googlemock/include/gmock/gmock-actions.h @@ -125,6 +125,8 @@ // To learn more about using these macros, please search for 'ACTION' on // https://github.com/google/googletest/blob/master/docs/gmock_cook_book.md +// GOOGLETEST_CM0002 DO NOT DELETE + #ifndef GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_ #define GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_ diff --git a/googletest/googlemock/include/gmock/gmock-cardinalities.h b/googletest/googlemock/include/gmock/gmock-cardinalities.h index c45fd641..fc7f803a 100644 --- a/googletest/googlemock/include/gmock/gmock-cardinalities.h +++ b/googletest/googlemock/include/gmock/gmock-cardinalities.h @@ -34,6 +34,8 @@ // cardinalities can be defined by the user implementing the // CardinalityInterface interface if necessary. +// GOOGLETEST_CM0002 DO NOT DELETE + #ifndef GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_CARDINALITIES_H_ #define GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_CARDINALITIES_H_ diff --git a/googletest/googlemock/include/gmock/gmock-function-mocker.h b/googletest/googlemock/include/gmock/gmock-function-mocker.h index e6913e58..0fc6f6f3 100644 --- a/googletest/googlemock/include/gmock/gmock-function-mocker.h +++ b/googletest/googlemock/include/gmock/gmock-function-mocker.h @@ -31,6 +31,8 @@ // // This file implements MOCK_METHOD. +// GOOGLETEST_CM0002 DO NOT DELETE + #ifndef GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_FUNCTION_MOCKER_H_ // NOLINT #define GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_FUNCTION_MOCKER_H_ // NOLINT @@ -62,39 +64,6 @@ struct ThisRefAdjuster { } }; -constexpr bool PrefixOf(const char* a, const char* b) { - return *a == 0 || (*a == *b && internal::PrefixOf(a + 1, b + 1)); -} - -template -constexpr bool StartsWith(const char (&prefix)[N], const char (&str)[M]) { - return N <= M && internal::PrefixOf(prefix, str); -} - -template -constexpr bool EndsWith(const char (&suffix)[N], const char (&str)[M]) { - return N <= M && internal::PrefixOf(suffix, str + M - N); -} - -template -constexpr bool Equals(const char (&a)[N], const char (&b)[M]) { - return N == M && internal::PrefixOf(a, b); -} - -template -constexpr bool ValidateSpec(const char (&spec)[N]) { - return internal::Equals("const", spec) || - internal::Equals("override", spec) || - internal::Equals("final", spec) || - internal::Equals("noexcept", spec) || - (internal::StartsWith("noexcept(", spec) && - internal::EndsWith(")", spec)) || - internal::Equals("ref(&)", spec) || - internal::Equals("ref(&&)", spec) || - (internal::StartsWith("Calltype(", spec) && - internal::EndsWith(")", spec)); -} - } // namespace internal // The style guide prohibits "using" statements in a namespace scope @@ -117,18 +86,17 @@ using internal::FunctionMocker; #define GMOCK_INTERNAL_MOCK_METHOD_ARG_3(_Ret, _MethodName, _Args) \ GMOCK_INTERNAL_MOCK_METHOD_ARG_4(_Ret, _MethodName, _Args, ()) -#define GMOCK_INTERNAL_MOCK_METHOD_ARG_4(_Ret, _MethodName, _Args, _Spec) \ - GMOCK_INTERNAL_ASSERT_PARENTHESIS(_Args); \ - GMOCK_INTERNAL_ASSERT_PARENTHESIS(_Spec); \ - GMOCK_INTERNAL_ASSERT_VALID_SIGNATURE( \ - GMOCK_PP_NARG0 _Args, GMOCK_INTERNAL_SIGNATURE(_Ret, _Args)); \ - GMOCK_INTERNAL_ASSERT_VALID_SPEC(_Spec) \ - GMOCK_INTERNAL_MOCK_METHOD_IMPL( \ - GMOCK_PP_NARG0 _Args, _MethodName, GMOCK_INTERNAL_HAS_CONST(_Spec), \ - GMOCK_INTERNAL_HAS_OVERRIDE(_Spec), GMOCK_INTERNAL_HAS_FINAL(_Spec), \ - GMOCK_INTERNAL_GET_NOEXCEPT_SPEC(_Spec), \ - GMOCK_INTERNAL_GET_CALLTYPE_SPEC(_Spec), \ - GMOCK_INTERNAL_GET_REF_SPEC(_Spec), \ +#define GMOCK_INTERNAL_MOCK_METHOD_ARG_4(_Ret, _MethodName, _Args, _Spec) \ + GMOCK_INTERNAL_ASSERT_PARENTHESIS(_Args); \ + GMOCK_INTERNAL_ASSERT_PARENTHESIS(_Spec); \ + GMOCK_INTERNAL_ASSERT_VALID_SIGNATURE( \ + GMOCK_PP_NARG0 _Args, GMOCK_INTERNAL_SIGNATURE(_Ret, _Args)); \ + GMOCK_INTERNAL_ASSERT_VALID_SPEC(_Spec) \ + GMOCK_INTERNAL_MOCK_METHOD_IMPL( \ + GMOCK_PP_NARG0 _Args, _MethodName, GMOCK_INTERNAL_HAS_CONST(_Spec), \ + GMOCK_INTERNAL_HAS_OVERRIDE(_Spec), GMOCK_INTERNAL_HAS_FINAL(_Spec), \ + GMOCK_INTERNAL_GET_NOEXCEPT_SPEC(_Spec), \ + GMOCK_INTERNAL_GET_CALLTYPE(_Spec), GMOCK_INTERNAL_GET_REF_SPEC(_Spec), \ (GMOCK_INTERNAL_SIGNATURE(_Ret, _Args))) #define GMOCK_INTERNAL_MOCK_METHOD_ARG_5(...) \ @@ -202,7 +170,7 @@ using internal::FunctionMocker; #define GMOCK_INTERNAL_EXPAND(...) __VA_ARGS__ -// Valid modifiers. +// Five Valid modifiers. #define GMOCK_INTERNAL_HAS_CONST(_Tuple) \ GMOCK_PP_HAS_COMMA(GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_DETECT_CONST, ~, _Tuple)) @@ -221,14 +189,6 @@ using internal::FunctionMocker; GMOCK_PP_HAS_COMMA(GMOCK_INTERNAL_DETECT_NOEXCEPT(_i, _, _elem)), \ _elem, ) -#define GMOCK_INTERNAL_GET_CALLTYPE_SPEC(_Tuple) \ - GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_CALLTYPE_SPEC_IF_CALLTYPE, ~, _Tuple) - -#define GMOCK_INTERNAL_CALLTYPE_SPEC_IF_CALLTYPE(_i, _, _elem) \ - GMOCK_PP_IF( \ - GMOCK_PP_HAS_COMMA(GMOCK_INTERNAL_DETECT_CALLTYPE(_i, _, _elem)), \ - GMOCK_PP_CAT(GMOCK_INTERNAL_UNPACK_, _elem), ) - #define GMOCK_INTERNAL_GET_REF_SPEC(_Tuple) \ GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_REF_SPEC_IF_REF, ~, _Tuple) @@ -236,25 +196,19 @@ using internal::FunctionMocker; GMOCK_PP_IF(GMOCK_PP_HAS_COMMA(GMOCK_INTERNAL_DETECT_REF(_i, _, _elem)), \ GMOCK_PP_CAT(GMOCK_INTERNAL_UNPACK_, _elem), ) -#ifdef GMOCK_INTERNAL_STRICT_SPEC_ASSERT -#define GMOCK_INTERNAL_ASSERT_VALID_SPEC_ELEMENT(_i, _, _elem) \ - static_assert( \ - ::testing::internal::ValidateSpec(GMOCK_PP_STRINGIZE(_elem)), \ - "Token \'" GMOCK_PP_STRINGIZE( \ - _elem) "\' cannot be recognized as a valid specification " \ - "modifier. Is a ',' missing?"); -#else -#define GMOCK_INTERNAL_ASSERT_VALID_SPEC_ELEMENT(_i, _, _elem) \ - static_assert( \ - (GMOCK_PP_HAS_COMMA(GMOCK_INTERNAL_DETECT_CONST(_i, _, _elem)) + \ - GMOCK_PP_HAS_COMMA(GMOCK_INTERNAL_DETECT_OVERRIDE(_i, _, _elem)) + \ - GMOCK_PP_HAS_COMMA(GMOCK_INTERNAL_DETECT_FINAL(_i, _, _elem)) + \ - GMOCK_PP_HAS_COMMA(GMOCK_INTERNAL_DETECT_NOEXCEPT(_i, _, _elem)) + \ - GMOCK_PP_HAS_COMMA(GMOCK_INTERNAL_DETECT_REF(_i, _, _elem)) + \ - GMOCK_PP_HAS_COMMA(GMOCK_INTERNAL_DETECT_CALLTYPE(_i, _, _elem))) == 1, \ - GMOCK_PP_STRINGIZE( \ +#define GMOCK_INTERNAL_GET_CALLTYPE(_Tuple) \ + GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_GET_CALLTYPE_IMPL, ~, _Tuple) + +#define GMOCK_INTERNAL_ASSERT_VALID_SPEC_ELEMENT(_i, _, _elem) \ + static_assert( \ + (GMOCK_PP_HAS_COMMA(GMOCK_INTERNAL_DETECT_CONST(_i, _, _elem)) + \ + GMOCK_PP_HAS_COMMA(GMOCK_INTERNAL_DETECT_OVERRIDE(_i, _, _elem)) + \ + GMOCK_PP_HAS_COMMA(GMOCK_INTERNAL_DETECT_FINAL(_i, _, _elem)) + \ + GMOCK_PP_HAS_COMMA(GMOCK_INTERNAL_DETECT_NOEXCEPT(_i, _, _elem)) + \ + GMOCK_PP_HAS_COMMA(GMOCK_INTERNAL_DETECT_REF(_i, _, _elem)) + \ + GMOCK_INTERNAL_IS_CALLTYPE(_elem)) == 1, \ + GMOCK_PP_STRINGIZE( \ _elem) " cannot be recognized as a valid specification modifier."); -#endif // GMOCK_INTERNAL_STRICT_SPEC_ASSERT // Modifiers implementation. #define GMOCK_INTERNAL_DETECT_CONST(_i, _, _elem) \ @@ -284,12 +238,26 @@ using internal::FunctionMocker; #define GMOCK_INTERNAL_UNPACK_ref(x) x -#define GMOCK_INTERNAL_DETECT_CALLTYPE(_i, _, _elem) \ - GMOCK_PP_CAT(GMOCK_INTERNAL_DETECT_CALLTYPE_I_, _elem) - -#define GMOCK_INTERNAL_DETECT_CALLTYPE_I_Calltype , +#define GMOCK_INTERNAL_GET_CALLTYPE_IMPL(_i, _, _elem) \ + GMOCK_PP_IF(GMOCK_INTERNAL_IS_CALLTYPE(_elem), \ + GMOCK_INTERNAL_GET_VALUE_CALLTYPE, GMOCK_PP_EMPTY) \ + (_elem) -#define GMOCK_INTERNAL_UNPACK_Calltype(...) __VA_ARGS__ +// TODO(iserna): GMOCK_INTERNAL_IS_CALLTYPE and +// GMOCK_INTERNAL_GET_VALUE_CALLTYPE needed more expansions to work on windows +// maybe they can be simplified somehow. +#define GMOCK_INTERNAL_IS_CALLTYPE(_arg) \ + GMOCK_INTERNAL_IS_CALLTYPE_I( \ + GMOCK_PP_CAT(GMOCK_INTERNAL_IS_CALLTYPE_HELPER_, _arg)) +#define GMOCK_INTERNAL_IS_CALLTYPE_I(_arg) GMOCK_PP_IS_ENCLOSED_PARENS(_arg) + +#define GMOCK_INTERNAL_GET_VALUE_CALLTYPE(_arg) \ + GMOCK_INTERNAL_GET_VALUE_CALLTYPE_I( \ + GMOCK_PP_CAT(GMOCK_INTERNAL_IS_CALLTYPE_HELPER_, _arg)) +#define GMOCK_INTERNAL_GET_VALUE_CALLTYPE_I(_arg) \ + GMOCK_PP_IDENTITY _arg + +#define GMOCK_INTERNAL_IS_CALLTYPE_HELPER_Calltype // Note: The use of `identity_t` here allows _Ret to represent return types that // would normally need to be specified in a different way. For example, a method diff --git a/googletest/googlemock/include/gmock/gmock-matchers.h b/googletest/googlemock/include/gmock/gmock-matchers.h index d9523695..86be9c17 100644 --- a/googletest/googlemock/include/gmock/gmock-matchers.h +++ b/googletest/googlemock/include/gmock/gmock-matchers.h @@ -250,6 +250,8 @@ // See googletest/include/gtest/gtest-matchers.h for the definition of class // Matcher, class MatcherInterface, and others. +// GOOGLETEST_CM0002 DO NOT DELETE + #ifndef GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_MATCHERS_H_ #define GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_MATCHERS_H_ @@ -1122,45 +1124,6 @@ class EndsWithMatcher { const StringType suffix_; }; -// Implements the polymorphic WhenBase64Unescaped(matcher) matcher, which can be -// used as a Matcher as long as T can be converted to a string. -class WhenBase64UnescapedMatcher { - public: - using is_gtest_matcher = void; - - explicit WhenBase64UnescapedMatcher( - const Matcher& internal_matcher) - : internal_matcher_(internal_matcher) {} - - // Matches anything that can convert to std::string. - template - bool MatchAndExplain(const MatcheeStringType& s, - MatchResultListener* listener) const { - const std::string s2(s); // NOLINT (needed for working with string_view). - std::string unescaped; - if (!internal::Base64Unescape(s2, &unescaped)) { - if (listener != nullptr) { - *listener << "is not a valid base64 escaped string"; - } - return false; - } - return MatchPrintAndExplain(unescaped, internal_matcher_, listener); - } - - void DescribeTo(::std::ostream* os) const { - *os << "matches after Base64Unescape "; - internal_matcher_.DescribeTo(os); - } - - void DescribeNegationTo(::std::ostream* os) const { - *os << "does not match after Base64Unescape "; - internal_matcher_.DescribeTo(os); - } - - private: - const Matcher internal_matcher_; -}; - // Implements a matcher that compares the two fields of a 2-tuple // using one of the ==, <=, <, etc, operators. The two fields being // compared don't have to have the same type. @@ -1442,30 +1405,6 @@ class AnyOfMatcherImpl : public MatcherInterface { template using AnyOfMatcher = VariadicMatcher; -// ConditionalMatcher is the implementation of Conditional(cond, m1, m2) -template -class ConditionalMatcher { - public: - ConditionalMatcher(bool condition, MatcherTrue matcher_true, - MatcherFalse matcher_false) - : condition_(condition), - matcher_true_(std::move(matcher_true)), - matcher_false_(std::move(matcher_false)) {} - - template - operator Matcher() const { // NOLINT(runtime/explicit) - return condition_ ? SafeMatcherCast(matcher_true_) - : SafeMatcherCast(matcher_false_); - } - - private: - bool condition_; - MatcherTrue matcher_true_; - MatcherFalse matcher_false_; - - GTEST_DISALLOW_ASSIGN_(ConditionalMatcher); -}; - // Wrapper for implementation of Any/AllOfArray(). template