adding unit test
This commit is contained in:
24
tests/unit_threadpool.cpp
Normal file
24
tests/unit_threadpool.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
#include <iostream>
|
||||
#include <future>
|
||||
|
||||
#include "daggy/ThreadPool.hpp"
|
||||
|
||||
#include "catch.hpp"
|
||||
|
||||
using namespace daggy;
|
||||
|
||||
TEST_CASE("Threadpool Construction", "[threadpool]") {
|
||||
std::atomic<uint32_t> cnt(0);
|
||||
ThreadPool tp(10);
|
||||
|
||||
std::vector<std::future<void>> 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);
|
||||
}
|
||||
Reference in New Issue
Block a user