From 1003e88303bc26c38df27d2c6e668972add6787b Mon Sep 17 00:00:00 2001 From: Ian Roddis Date: Wed, 16 Jun 2021 13:55:27 -0300 Subject: [PATCH] adding unit test --- tests/unit_threadpool.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 tests/unit_threadpool.cpp diff --git a/tests/unit_threadpool.cpp b/tests/unit_threadpool.cpp new file mode 100644 index 0000000..67bfe2a --- /dev/null +++ b/tests/unit_threadpool.cpp @@ -0,0 +1,24 @@ +#include +#include + +#include "daggy/ThreadPool.hpp" + +#include "catch.hpp" + +using namespace daggy; + +TEST_CASE("Threadpool Construction", "[threadpool]") { + std::atomic cnt(0); + ThreadPool tp(10); + + std::vector> res; + for (size_t i = 0; i < 100; ++i) { + res.push_back(tp.addTask([&cnt]() -> void { cnt++; return; })); + } + + for (auto & r : res) { + r.get(); + } + + REQUIRE(cnt == 100); +}