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)>,
"Test name should be a string");
27 return param.test_name;
29 return ::testing::PrintToString(param);
34using HasTupleSize =
decltype(std::tuple_size<T>::value);
36template <
typename... Args>
37std::string TestTupleParamToString(
const std::tuple<Args...>& params_tuple) {
38 static_assert((
sizeof...(Args) != 0),
"Test parameters should have at least one dimension");
42 [](
const auto& first,
const auto&... rest) {
43 return (TestParamToString(first) + ... + (
"_" + TestParamToString(rest)));
100struct PrintTestName
final {
101 template <
typename ParamType>
102 std::string operator()(
const testing::TestParamInfo<ParamType>& info)
const {
103 if constexpr (meta::kIsDetected<impl::HasTupleSize, ParamType>) {
104 return impl::TestTupleParamToString(info.param);
106 return impl::TestParamToString(info.param);