Skip to content

Commit a7329e5

Browse files
committed
add unit tests for Task status strings, type handling, and invalid pipeline order
1 parent e0b2a65 commit a7329e5

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

modules/core/task/tests/task_tests.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,41 @@ TEST(task_tests, premature_postprocessing_after_preprocessing) {
172172
EXPECT_DEATH_IF_SUPPORTED(destroy_function(), ".*ORDER OF FUNCTIONS IS NOT RIGHT.*");
173173
}
174174

175+
// Test for disabled status string
176+
TEST(TaskTest, GetStringTaskStatus_Disabled) {
177+
EXPECT_EQ(GetStringTaskStatus(ppc::core::StatusOfTask::kDisabled), "disabled");
178+
}
179+
180+
// Test for enabled status string
181+
TEST(TaskTest, GetStringTaskStatus_Enabled) {
182+
EXPECT_EQ(GetStringTaskStatus(ppc::core::StatusOfTask::kEnabled), "enabled");
183+
}
184+
185+
// Test for exception thrown when file cannot be opened
186+
TEST(TaskTest, GetStringTaskType_InvalidFileThrows) {
187+
EXPECT_THROW({ GetStringTaskType(ppc::core::TypeOfTask::kALL, "non_existing_file.json"); }, std::runtime_error);
188+
}
189+
190+
// Test unknown type case
191+
TEST(TaskTest, GetStringTaskType_UnknownType) {
192+
std::string path = "settings.json"; // Provide valid settings file
193+
EXPECT_NO_THROW({ GetStringTaskType(ppc::core::TypeOfTask::kUnknown, path); });
194+
}
195+
196+
// Death test for destructor when pipeline order is invalid
197+
TEST(TaskTest, Destructor_InvalidPipelineOrderTerminates) {
198+
testing::FLAGS_gtest_death_test_style = "threadsafe";
199+
auto test_func = [&] {
200+
struct BadTask : ppc::core::Task<int, int> {
201+
bool ValidationImpl() override { return true; }
202+
bool PreProcessingImpl() override { return true; }
203+
bool RunImpl() override { return true; }
204+
bool PostProcessingImpl() override { return true; }
205+
} task;
206+
};
207+
ASSERT_DEATH_IF_SUPPORTED({ test_func(); }, "");
208+
}
209+
175210
int main(int argc, char **argv) {
176211
testing::InitGoogleTest(&argc, argv);
177212
return RUN_ALL_TESTS();

0 commit comments

Comments
 (0)