Skip to content

Commit 1a12d05

Browse files
committed
add test for Task destructor to validate behavior when called with empty input
1 parent 99a8a83 commit 1a12d05

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

modules/core/task/tests/task_tests.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,22 @@ TEST(TaskTest, TaskDestructor_ThrowsIfStageIncomplete) {
158158
} task(in);
159159
task.Validation();
160160
};
161-
EXPECT_DEATH_IF_SUPPORTED(destroy_func(), ".*ORDER OF FUNCTIONS IS NOT RIGHT.*");
161+
EXPECT_DEATH_IF_SUPPORTED({ destroy_func(); }, ".*ORDER OF FUNCTIONS IS NOT RIGHT.*");
162+
}
163+
164+
TEST(TaskTest, TaskDestructor_ThrowsIfEmpty) {
165+
testing::FLAGS_gtest_death_test_style = "threadsafe";
166+
auto destroy_func = [] {
167+
std::vector<int32_t> in(20, 1);
168+
struct LocalTask : ppc::core::Task<std::vector<int32_t>, int32_t> {
169+
explicit LocalTask(const std::vector<int32_t>& in) { this->GetInput() = in; }
170+
bool ValidationImpl() override { return true; }
171+
bool PreProcessingImpl() override { return true; }
172+
bool RunImpl() override { return true; }
173+
bool PostProcessingImpl() override { return true; }
174+
} task(in);
175+
};
176+
EXPECT_DEATH_IF_SUPPORTED({ destroy_func(); }, ".*ORDER OF FUNCTIONS IS NOT RIGHT.*");
162177
}
163178

164179
TEST(TaskTest, InternalTimeTest_ThrowsIfTimeoutExceeded) {

0 commit comments

Comments
 (0)