|
| 1 | +#include <gtest/gtest.h> |
| 2 | +#include <array> |
| 3 | +#include <tuple> |
| 4 | +#include <vector> |
| 5 | +#include <string> |
| 6 | + |
| 7 | +#include "bruskova_v_image_smoothing/common/include/common.hpp" |
| 8 | +#include "bruskova_v_image_smoothing/mpi/include/ops_mpi.hpp" |
| 9 | +#include "bruskova_v_image_smoothing/seq/include/ops_seq.hpp" |
| 10 | +#include "util/include/func_test_util.hpp" |
| 11 | + |
| 12 | +namespace bruskova_v_image_smoothing { |
| 13 | + |
| 14 | +class BruskovaVImageSmoothingFuncTests : public ppc::util::BaseRunFuncTests<InType, OutType, TestType> { |
| 15 | + public: |
| 16 | + static std::string PrintTestParam(const TestType& test_param) { |
| 17 | + return std::to_string(std::get<0>(test_param)); |
| 18 | + } |
| 19 | + |
| 20 | + protected: |
| 21 | + void SetUp() override { |
| 22 | + auto test_params = std::get<static_cast<std::size_t>(ppc::util::GTestParamIndex::kTestParams)>(GetParam()); |
| 23 | + int size = std::get<0>(test_params); |
| 24 | + input_data_ = std::vector<int>(size, 128); |
| 25 | + expected_output_ = std::vector<int>(size, 128); |
| 26 | + } |
| 27 | + |
| 28 | + bool CheckTestOutputData(OutType &output_data) final { |
| 29 | + return output_data.size() == input_data_.size(); |
| 30 | + } |
| 31 | + |
| 32 | + InType GetTestInputData() final { |
| 33 | + return input_data_; |
| 34 | + } |
| 35 | + |
| 36 | + private: |
| 37 | + InType input_data_; |
| 38 | + OutType expected_output_; |
| 39 | +}; |
| 40 | + |
| 41 | +TEST_P(BruskovaVImageSmoothingFuncTests, SmoothingTest) { |
| 42 | + ExecuteTest(GetParam()); |
| 43 | +} |
| 44 | + |
| 45 | +const std::array<TestType, 2> kTestParam = {std::make_tuple(10), std::make_tuple(50)}; |
| 46 | + |
| 47 | +const auto kTestTasksList = std::tuple_cat( |
| 48 | + ppc::util::AddFuncTask<BruskovaVImageSmoothingMPI, InType>(kTestParam, "bruskova_v_image_smoothing_mpi"), |
| 49 | + ppc::util::AddFuncTask<BruskovaVImageSmoothingSEQ, InType>(kTestParam, "bruskova_v_image_smoothing_seq")); |
| 50 | + |
| 51 | +const auto kGtestValues = ppc::util::ExpandToValues(kTestTasksList); |
| 52 | + |
| 53 | +INSTANTIATE_TEST_SUITE_P(FuncTests, BruskovaVImageSmoothingFuncTests, kGtestValues, |
| 54 | + BruskovaVImageSmoothingFuncTests::PrintFuncTestName<BruskovaVImageSmoothingFuncTests>); |
| 55 | + |
| 56 | +} // namespace bruskova_v_image_smoothing |
0 commit comments