16 #ifndef HWY_TESTS_HWY_GTEST_H_
17 #define HWY_TESTS_HWY_GTEST_H_
27 #include "gtest/gtest.h"
34 #ifdef INSTANTIATE_TEST_SUITE_P
35 #define HWY_GTEST_INSTANTIATE_TEST_SUITE_P INSTANTIATE_TEST_SUITE_P
37 #define HWY_GTEST_INSTANTIATE_TEST_SUITE_P INSTANTIATE_TEST_CASE_P
55 #if (HWY_TARGETS & (HWY_TARGETS - 1)) != 0
57 <<
"This hwy target parametric test doesn't use dynamic-dispatch and "
58 "doesn't need to be parametric.";
67 const testing::TestParamInfo<uint32_t>& info) {
71 #define HWY_TARGET_INSTANTIATE_TEST_SUITE_P(suite) \
72 HWY_GTEST_INSTANTIATE_TEST_SUITE_P( \
73 suite##Group, suite, \
74 testing::ValuesIn(::hwy::SupportedAndGeneratedTargets()), \
75 ::hwy::TestParamTargetName)
88 :
public ::testing::TestWithParam<std::tuple<uint32_t, T>> {
97 ::testing::TestWithParam<std::tuple<uint32_t, T>>::
GetParam()));
104 #if (HWY_TARGETS & (HWY_TARGETS - 1)) != 0
106 <<
"This hwy target parametric test doesn't use dynamic-dispatch and "
107 "doesn't need to be parametric.";
114 ::testing::TestWithParam<std::tuple<uint32_t, T>>::
GetParam());
118 template <
typename T>
120 const testing::TestParamInfo<std::tuple<uint32_t, T>>& info) {
121 return std::string(
TargetName(std::get<0>(info.param))) +
"_" +
122 ::testing::PrintToString(std::get<1>(info.param));
125 #define HWY_TARGET_INSTANTIATE_TEST_SUITE_P_T(suite, generator) \
126 HWY_GTEST_INSTANTIATE_TEST_SUITE_P( \
127 suite##Group, suite, \
128 ::testing::Combine( \
129 testing::ValuesIn(::hwy::SupportedAndGeneratedTargets()), \
131 ::hwy::TestParamTargetNameAndT<suite::HwyParamType>)
140 #define HWY_EXPORT_AND_TEST_P(suite, func_name) \
141 HWY_EXPORT(func_name); \
142 TEST_P(suite, func_name) { HWY_DYNAMIC_DISPATCH(func_name)(); } \
143 static_assert(true, "For requiring trailing semicolon")
145 #define HWY_EXPORT_AND_TEST_P_T(suite, func_name) \
146 HWY_EXPORT(func_name); \
147 TEST_P(suite, func_name) { HWY_DYNAMIC_DISPATCH(func_name)(GetParam()); } \
148 static_assert(true, "For requiring trailing semicolon")
150 #define HWY_BEFORE_TEST(suite) \
151 class suite : public hwy::TestWithParamTarget {}; \
152 HWY_TARGET_INSTANTIATE_TEST_SUITE_P(suite); \
153 static_assert(true, "For requiring trailing semicolon")
Definition: hwy_gtest.h:88
void TearDown() override
Definition: hwy_gtest.h:100
T GetParam()
Definition: hwy_gtest.h:112
T HwyParamType
Definition: hwy_gtest.h:92
void SetUp() override
Definition: hwy_gtest.h:95
Definition: hwy_gtest.h:47
void TearDown() override
Definition: hwy_gtest.h:51
void SetUp() override
Definition: hwy_gtest.h:49
Definition: aligned_allocator.h:27
HWY_DLLEXPORT void SetSupportedTargetsForTest(uint32_t targets)
static std::string TestParamTargetName(const testing::TestParamInfo< uint32_t > &info)
Definition: hwy_gtest.h:66
static HWY_MAYBE_UNUSED const char * TargetName(uint32_t target)
Definition: targets.h:80
HWY_DLLEXPORT bool SupportedTargetsCalledForTest()
std::string TestParamTargetNameAndT(const testing::TestParamInfo< std::tuple< uint32_t, T >> &info)
Definition: hwy_gtest.h:119