66
77#include < concepts>
88#include < csignal>
9+ #include < cstddef>
910#include < functional>
1011#include < string>
1112#include < tuple>
13+ #include < utility>
1214
1315#include " core/task/include/task.hpp"
1416#include " core/util/include/util.hpp"
@@ -45,44 +47,44 @@ class BaseRunFuncTests : public ::testing::TestWithParam<FuncTestParam<InType, O
4547 return std::get<GTestParamIndex::kNameTest >(info.param ) + " _" + Derived::PrintTestParam (test_param);
4648 }
4749
50+ protected:
51+ const std::string kUnknownTest = " unknown" ;
52+ const std::string kDisabledTest = " disabled" ;
53+ const std::string kAllTask = " _all" ;
54+ const std::string kMpiTask = " _mpi" ;
55+
4856 void ExecuteTest (FuncTestParam<InType, OutType, TestType> test_param) {
4957 const std::string& test_name = std::get<GTestParamIndex::kNameTest >(test_param);
5058
51- validateTestName (test_name);
59+ ValidateTestName (test_name);
5260
53- if (isTestDisabled (test_name)) {
61+ if (IsTestDisabled (test_name)) {
5462 GTEST_SKIP ();
5563 }
5664
57- if (shouldSkipNonMpiTask (test_name)) {
65+ if (ShouldSkipNonMpiTask (test_name)) {
5866 std::cerr << " kALL and kMPI tasks are not under mpirun\n " ;
5967 GTEST_SKIP ();
6068 }
6169
62- initializeAndRunTask (test_param);
70+ InitializeAndRunTask (test_param);
6371 }
6472
65- private:
66- static constexpr std::string UNKNOWN_TEST = " unknown" ;
67- static constexpr std::string DISABLED_TEST = " disabled" ;
68- static constexpr std::string ALL_TASK = " _all" ;
69- static constexpr std::string MPI_TASK = " _mpi" ;
70-
71- void validateTestName (const std::string& test_name) {
72- EXPECT_FALSE (test_name.find (UNKNOWN_TEST) != std::string::npos);
73+ void ValidateTestName (const std::string& test_name) {
74+ EXPECT_FALSE (test_name.find (kUnknownTest ) != std::string::npos);
7375 }
7476
75- bool isTestDisabled (const std::string& test_name) { return test_name.find (DISABLED_TEST ) != std::string::npos; }
77+ bool IsTestDisabled (const std::string& test_name) { return test_name.find (kDisabledTest ) != std::string::npos; }
7678
77- bool shouldSkipNonMpiTask (const std::string& test_name) {
78- auto containsSubstring = [&](const std::string& substring) {
79+ bool ShouldSkipNonMpiTask (const std::string& test_name) {
80+ auto contains_substring = [&](const std::string& substring) {
7981 return test_name.find (substring) != std::string::npos;
8082 };
8183
82- return !ppc::util::IsUnderMpirun () && (containsSubstring (ALL_TASK ) || containsSubstring (MPI_TASK ));
84+ return !ppc::util::IsUnderMpirun () && (contains_substring ( kAllTask ) || contains_substring ( kMpiTask ));
8385 }
8486
85- void initializeAndRunTask (const FuncTestParam<InType, OutType, TestType>& test_param) {
87+ void InitializeAndRunTask (const FuncTestParam<InType, OutType, TestType>& test_param) {
8688 task_ = std::get<GTestParamIndex::kTaskGetter >(test_param)(GetTestInputData ());
8789
8890 EXPECT_TRUE (task_->Validation ());
@@ -92,6 +94,7 @@ class BaseRunFuncTests : public ::testing::TestWithParam<FuncTestParam<InType, O
9294 EXPECT_TRUE (CheckTestOutputData (task_->GetOutput ()));
9395 }
9496
97+ private:
9598 ppc::core::TaskPtr<InType, OutType> task_;
9699};
97100
@@ -106,21 +109,23 @@ auto ExpandToValues(const Tuple& t) {
106109 return ExpandToValuesImpl (t, std::make_index_sequence<kN >{});
107110}
108111
109- #define INIT_FUNC_TASK_GENERATOR (InTypeParam, SizesParam, SettingsPath ) \
110- template <typename Task, std::size_t ... Is> \
111- auto GenTaskTuplesImpl (std::index_sequence<Is...>) { \
112- return std::make_tuple ( \
113- std::make_tuple (ppc::core::TaskGetter<Task, InTypeParam>, \
114- std::string (ppc::util::GetNamespace<Task>()) + std::string (" _" ) + \
115- ppc::core::GetStringTaskType (Task::GetStaticTypeOfTask (), SettingsPath), \
116- SizesParam[Is])...); \
117- } \
118- \
119- template <typename Task> \
120- auto TaskListGenerator () { \
121- return GenTaskTuplesImpl<Task>(std::make_index_sequence<SizesParam.size ()>{}); \
122- }
112+ template <typename Task, typename InType, typename SizesContainer, std::size_t ... Is>
113+ auto GenTaskTuplesImpl (const SizesContainer& sizes, const std::string& settings_path, std::index_sequence<Is...>) {
114+ return std::make_tuple (std::make_tuple (ppc::core::TaskGetter<Task, InType>,
115+ std::string (GetNamespace<Task>()) + " _" +
116+ ppc::core::GetStringTaskType (Task::GetStaticTypeOfTask (), settings_path),
117+ sizes[Is])...);
118+ }
119+
120+ template <typename Task, typename InType, typename SizesContainer>
121+ auto TaskListGenerator (const SizesContainer& sizes, const std::string& settings_path) {
122+ return GenTaskTuplesImpl<Task, InType>(sizes, settings_path,
123+ std::make_index_sequence<std::tuple_size_v<std::decay_t <SizesContainer>>>{});
124+ }
123125
124- #define ADD_FUNC_TASK (TASK ) TaskListGenerator<TASK>() // std::tuple<>()
126+ template <typename Task, typename InType, typename SizesContainer>
127+ constexpr auto AddFuncTask (const SizesContainer& sizes, const std::string& settings_path) {
128+ return TaskListGenerator<Task, InType>(sizes, settings_path);
129+ }
125130
126131} // namespace ppc::util
0 commit comments