adding unit test

This commit is contained in:
Ian Roddis
2021-06-16 13:55:27 -03:00
parent 5e3098c5f9
commit 1003e88303

24
tests/unit_threadpool.cpp Normal file
View 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);
}