Google Test TYPED_TESTs which are defined in a namespace are instead put into the anonymous namespace in the Test Explorer list if a custom name generator is provided which generates names not starting with a digit.
Without a name generator:
#include <gtest/gtest.h>
#include <string>
namespace example
{
template <typename T> struct TestSuite : public ::testing::Test {};
using TestTypes = ::testing::Types<int, float>;
TYPED_TEST_SUITE(TestSuite, TestTypes);
TYPED_TEST(TestSuite, test_zero){}
TYPED_TEST(TestSuite, test_one){}
}
You end up with integers for the test type names but the tests end up in the correct namespace:

Adding a name generator with simple names:
#include <gtest/gtest.h>
#include <string>
namespace example
{
class NameGenerator
{
public:
template <typename T> static std::string GetName(int i)
{
if constexpr (std::is_same_v<T, int>) return "int";
if constexpr (std::is_same_v<T, float>) return "float";
}
};
template <typename T> struct TestSuite : public ::testing::Test{};
using TestTypes = ::testing::Types<int, float>;
TYPED_TEST_SUITE(TestSuite, TestTypes, NameGenerator);
TYPED_TEST(TestSuite, test_zero){}
TYPED_TEST(TestSuite, test_one){}
}
You end up with nicer test type names but the tests end up in the anonymous namespace:

Changing the name generator to start with a digit:
#include <gtest/gtest.h>
#include <string>
namespace example
{
class NameGenerator
{
public:
template <typename T> static std::string GetName(int i)
{
if constexpr (std::is_same_v<T, int>) return "0_int";
if constexpr (std::is_same_v<T, float>) return "0_float";
}
};
template <typename T> struct TestSuite : public ::testing::Test{};
using TestTypes = ::testing::Types<int, float>;
TYPED_TEST_SUITE(TestSuite, TestTypes, NameGenerator);
TYPED_TEST(TestSuite, test_zero){}
TYPED_TEST(TestSuite, test_one){}
}
Which ends up with somewhat more correct naming, but it shouldn't be necessary.

Google Test
TYPED_TESTs which are defined in a namespace are instead put into the anonymous namespace in the Test Explorer list if a custom name generator is provided which generates names not starting with a digit.Without a name generator:
You end up with integers for the test type names but the tests end up in the correct namespace:

Adding a name generator with simple names:
You end up with nicer test type names but the tests end up in the anonymous namespace:

Changing the name generator to start with a digit:
Which ends up with somewhat more correct naming, but it shouldn't be necessary.
