From c6a2dbac8df3c516895d5d191c7585f5f02a94c2 Mon Sep 17 00:00:00 2001 From: tqcq <99722391+tqcq@users.noreply.github.com> Date: Tue, 2 Jan 2024 17:38:35 +0800 Subject: [PATCH] feat add no args task test --- tests/ulib/system/thread_pool_unittest.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tests/ulib/system/thread_pool_unittest.cpp b/tests/ulib/system/thread_pool_unittest.cpp index 3d29d71..9879915 100644 --- a/tests/ulib/system/thread_pool_unittest.cpp +++ b/tests/ulib/system/thread_pool_unittest.cpp @@ -4,7 +4,10 @@ class ThreadPoolTest : public ::testing::Test { protected: - void SetUp() override { thread_pool_ = std::make_unique(10); } + void SetUp() override + { + thread_pool_ = std::make_unique(10); + } std::unique_ptr thread_pool_; }; @@ -32,3 +35,15 @@ TEST_F(ThreadPoolTest, MultiTask) for (auto &future : futures) { ASSERT_EQ(future.get(), 3); } } + +TEST_F(ThreadPoolTest, NoArgs) +{ + std::vector> futures; + for (int i = 0; i < 1000; ++i) { + futures.emplace_back(thread_pool_->Submit([]() { + ulib::Thread::Sleep(1000); + return 1; + })); + } + for (auto &future : futures) { future.get(); } +}