10#include <gtest/gtest.h>
12#include <userver/utils/meta_light.hpp>
14USERVER_NAMESPACE_BEGIN
21using HasTestName =
decltype(T::test_name);
23template <
typename ParamType>
24std::string TestParamToString(
const ParamType& param) {
25 if constexpr (meta::kIsDetected<HasTestName, ParamType>) {
26 static_assert(std::is_same_v<std::string,
decltype(param.test_name)>,
27 "Test name should be a string");
28 return param.test_name;
30 return ::testing::PrintToString(param);
35using HasTupleSize =
decltype(std::tuple_size<T>::value);
37template <
typename... Args>
38std::string TestTupleParamToString(
const std::tuple<Args...>& params_tuple) {
39 static_assert((
sizeof...(Args) != 0),
40 "Test parameters should have at least one dimension");
44 [](
const auto& first,
const auto&... rest) {
45 return (TestParamToString(first) + ... +
46 (
"_" + TestParamToString(rest)));
102struct PrintTestName
final {
103 template <
typename ParamType>
104 std::string operator()(
const testing::TestParamInfo<ParamType>& info)
const {
105 if constexpr (meta::kIsDetected<impl::HasTupleSize, ParamType>) {
106 return impl::TestTupleParamToString(info.param);
108 return impl::TestParamToString(info.param);