diff options
author | Abseil Team <absl-team@google.com> | 2024-05-28 14:41:56 (GMT) |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2024-05-28 14:42:39 (GMT) |
commit | a7f443b80b105f940225332ed3c31f2790092f47 (patch) | |
tree | 47adc96a2e3c035b0ae3f87e3c48e44e74d1244e | |
parent | 305e5a238b3c8d11266fbafd85520fb6b3184851 (diff) | |
download | googletest-a7f443b80b105f940225332ed3c31f2790092f47.zip googletest-a7f443b80b105f940225332ed3c31f2790092f47.tar.gz googletest-a7f443b80b105f940225332ed3c31f2790092f47.tar.bz2 |
Mention the optional third argument to TYPED_TEST_SUITE
PiperOrigin-RevId: 637896001
Change-Id: Ia3a61ceec4b842e864a0cdfad13e9897bf0ecaaa
-rw-r--r-- | docs/reference/testing.md | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/docs/reference/testing.md b/docs/reference/testing.md index c93556e..3ed5211 100644 --- a/docs/reference/testing.md +++ b/docs/reference/testing.md @@ -140,6 +140,7 @@ See also ### TYPED_TEST_SUITE {#TYPED_TEST_SUITE} `TYPED_TEST_SUITE(`*`TestFixtureName`*`,`*`Types`*`)` +`TYPED_TEST_SUITE(`*`TestFixtureName`*`,`*`Types`*`,`*`NameGenerator`*`)` Defines a typed test suite based on the test fixture *`TestFixtureName`*. The test suite name is *`TestFixtureName`*. @@ -169,6 +170,22 @@ TYPED_TEST_SUITE(MyFixture, MyTypes); The type alias (`using` or `typedef`) is necessary for the `TYPED_TEST_SUITE` macro to parse correctly. +The optional third argument *`NameGenerator`* allows specifying a class that +exposes a templated static function `GetName(int)`. For example: + +```cpp +class NameGenerator { + public: + template <typename T> + static std::string GetName(int) { + if constexpr (std::is_same_v<T, char>) return "char"; + if constexpr (std::is_same_v<T, int>) return "int"; + if constexpr (std::is_same_v<T, unsigned int>) return "unsignedInt"; + } +}; +TYPED_TEST_SUITE(MyFixture, MyTypes, NameGenerator); +``` + See also [`TYPED_TEST`](#TYPED_TEST) and [Typed Tests](../advanced.md#typed-tests) for more information. |