Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ Checks: >
-misc-const-correctness,
-misc-non-private-member-variables-in-classes,
-modernize-avoid-c-arrays,
-misc-override-with-different-visibility,
-misc-use-internal-linkage,
-modernize-use-trailing-return-type,
-portability-avoid-pragma-once,
Expand Down
1 change: 1 addition & 0 deletions modules/performance/tests/.clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Checks: >
-modernize-loop-convert,
-cppcoreguidelines-avoid-goto,
-cppcoreguidelines-avoid-non-const-global-variables,
-misc-override-with-different-visibility,
-misc-use-anonymous-namespace,
-modernize-use-std-print,
-modernize-type-traits
Expand Down
1 change: 1 addition & 0 deletions modules/task/tests/.clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Checks: >
-modernize-loop-convert,
-cppcoreguidelines-avoid-goto,
-cppcoreguidelines-avoid-non-const-global-variables,
-misc-override-with-different-visibility,
-misc-use-anonymous-namespace,
-modernize-use-std-print,
-modernize-type-traits
Expand Down
13 changes: 13 additions & 0 deletions modules/task/tests/task_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class TestTask : public ppc::task::Task<InType, OutType> {
this->GetInput() = in;
}

protected:
bool ValidationImpl() override {
return !this->GetInput().empty();
}
Expand All @@ -71,6 +72,7 @@ class FakeSlowTask : public TestTask<InType, OutType> {
public:
explicit FakeSlowTask(const InType &in) : TestTask<InType, OutType>(in) {}

protected:
bool RunImpl() override {
std::this_thread::sleep_for(std::chrono::seconds(2));
return TestTask<InType, OutType>::RunImpl();
Expand Down Expand Up @@ -233,9 +235,12 @@ TEST(TaskTest, TaskDestructorThrowsIfStageIncomplete) {
{
std::vector<int32_t> in(20, 1);
struct LocalTask : Task<std::vector<int32_t>, int32_t> {
public:
explicit LocalTask(const std::vector<int32_t> &in) {
this->GetInput() = in;
}

protected:
bool ValidationImpl() override {
return true;
}
Expand All @@ -259,9 +264,12 @@ TEST(TaskTest, TaskDestructorThrowsIfEmpty) {
{
std::vector<int32_t> in(20, 1);
struct LocalTask : Task<std::vector<int32_t>, int32_t> {
public:
explicit LocalTask(const std::vector<int32_t> &in) {
this->GetInput() = in;
}

protected:
bool ValidationImpl() override {
return true;
}
Expand All @@ -285,9 +293,12 @@ TEST(TaskTest, InternalTimeTestThrowsIfTimeoutExceeded) {
GTEST_SKIP() << "Skipped on macOS due to time fluctuations.";
#endif
struct SlowTask : Task<std::vector<int32_t>, int32_t> {
public:
explicit SlowTask(const std::vector<int32_t> &in) {
this->GetInput() = in;
}

protected:
bool ValidationImpl() override {
return true;
}
Expand Down Expand Up @@ -315,6 +326,8 @@ TEST(TaskTest, InternalTimeTestThrowsIfTimeoutExceeded) {
class DummyTask : public Task<int, int> {
public:
using Task::Task;

protected:
bool ValidationImpl() override {
return true;
}
Expand Down
24 changes: 17 additions & 7 deletions modules/util/include/func_test_util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ template <typename InType, typename OutType, typename TestType = void>
/// @tparam TestType Type of the test case or parameter.
class BaseRunFuncTests : public ::testing::TestWithParam<FuncTestParam<InType, OutType, TestType>> {
public:
virtual bool CheckTestOutputData(OutType &output_data) = 0;
/// @brief Provides input data for the task.
/// @return Initialized input data.
virtual InType GetTestInputData() = 0;

template <typename Derived>
static void RequireStaticInterface() {
static_assert(HasPrintTestParam<Derived, TestType>,
Expand All @@ -56,6 +51,11 @@ class BaseRunFuncTests : public ::testing::TestWithParam<FuncTestParam<InType, O
}

protected:
virtual bool CheckTestOutputData(OutType &output_data) = 0;
/// @brief Provides input data for the task.
/// @return Initialized input data.
virtual InType GetTestInputData() = 0;

void ExecuteTest(FuncTestParam<InType, OutType, TestType> test_param) {
const std::string &test_name = std::get<static_cast<std::size_t>(GTestParamIndex::kNameTest)>(test_param);

Expand Down Expand Up @@ -95,13 +95,23 @@ class BaseRunFuncTests : public ::testing::TestWithParam<FuncTestParam<InType, O
ExecuteTaskPipeline();
}

/// @brief Executes the full task pipeline with validation.
// NOLINTNEXTLINE(readability-function-cognitive-complexity)
void ExecuteTaskPipeline() {
ValidateTask();
RunTask();
CheckTaskOutput();
}

void ValidateTask() {
EXPECT_TRUE(task_->Validation());
EXPECT_TRUE(task_->PreProcessing());
}

void RunTask() {
EXPECT_TRUE(task_->Run());
EXPECT_TRUE(task_->PostProcessing());
}

void CheckTaskOutput() {
EXPECT_TRUE(CheckTestOutputData(task_->GetOutput()));
}

Expand Down
14 changes: 14 additions & 0 deletions tasks/example_processes/tests/.clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
InheritParentConfig: true

Checks: >
-modernize-loop-convert,
-cppcoreguidelines-avoid-goto,
-cppcoreguidelines-avoid-non-const-global-variables,
-misc-override-with-different-visibility,
-misc-use-anonymous-namespace,
-modernize-use-std-print,
-modernize-type-traits

CheckOptions:
- key: readability-function-cognitive-complexity.Threshold
value: 50 # Relaxed for tests
14 changes: 14 additions & 0 deletions tasks/example_processes_2/tests/.clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
InheritParentConfig: true

Checks: >
-modernize-loop-convert,
-cppcoreguidelines-avoid-goto,
-cppcoreguidelines-avoid-non-const-global-variables,
-misc-override-with-different-visibility,
-misc-use-anonymous-namespace,
-modernize-use-std-print,
-modernize-type-traits

CheckOptions:
- key: readability-function-cognitive-complexity.Threshold
value: 50 # Relaxed for tests
1 change: 1 addition & 0 deletions tasks/example_processes_3/tests/.clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Checks: >
-modernize-loop-convert,
-cppcoreguidelines-avoid-goto,
-cppcoreguidelines-avoid-non-const-global-variables,
-misc-override-with-different-visibility,
-misc-use-anonymous-namespace,
-modernize-use-std-print,
-modernize-type-traits
Expand Down
14 changes: 14 additions & 0 deletions tasks/example_threads/tests/.clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
InheritParentConfig: true

Checks: >
-modernize-loop-convert,
-cppcoreguidelines-avoid-goto,
-cppcoreguidelines-avoid-non-const-global-variables,
-misc-override-with-different-visibility,
-misc-use-anonymous-namespace,
-modernize-use-std-print,
-modernize-type-traits

CheckOptions:
- key: readability-function-cognitive-complexity.Threshold
value: 50 # Relaxed for tests
Loading