11#include <gtest/gtest.h>
13#include <userver/utils/meta_light.hpp>
15USERVER_NAMESPACE_BEGIN
22using HasTestName =
decltype(T::test_name);
24template <
typename ParamType>
25std::string TestParamToString(
const ParamType& param) {
26 if constexpr (meta::IsDetected<HasTestName, ParamType>) {
27 static_assert(std::is_same_v<std::string,
decltype(param.test_name)>,
"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),
"Test parameters should have at least one dimension");
43 [](
const auto& first,
const auto&... rest) {
44 return (TestParamToString(first) + ... + (
"_" + TestParamToString(rest)));
101struct PrintTestName
final {
102 template <
typename ParamType>
103 std::string operator()(
const testing::TestParamInfo<ParamType>& info)
const {
104 if constexpr (meta::IsDetected<impl::HasTupleSize, ParamType>) {
105 return impl::TestTupleParamToString(info.param);
107 return impl::TestParamToString(info.param);