]> git-server-git.apps.pok.os.sepia.ceph.com Git - googletest.git/commitdiff
Mention the optional third argument to TYPED_TEST_SUITE
authorAbseil Team <absl-team@google.com>
Tue, 28 May 2024 14:41:56 +0000 (07:41 -0700)
committerCopybara-Service <copybara-worker@google.com>
Tue, 28 May 2024 14:42:39 +0000 (07:42 -0700)
PiperOrigin-RevId: 637896001
Change-Id: Ia3a61ceec4b842e864a0cdfad13e9897bf0ecaaa

docs/reference/testing.md

index c93556e6624b5052d75893dac6d49db0b09cea84..3ed5211117870eb1e4c18919c120b5380c644263 100644 (file)
@@ -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.