Then chaining still kinda broken
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
target_sources(Seele_unit_tests
|
||||
PRIVATE
|
||||
../../src/Engine/MinimalEngine.cpp
|
||||
../../src/Engine/ThreadPool.cpp
|
||||
EngineTest.h
|
||||
EngineTest.cpp)
|
||||
EngineTest.cpp
|
||||
ThreadPool.cpp)
|
||||
target_include_directories(Seele_unit_tests PUBLIC ./)
|
||||
add_subdirectory(Containers/)
|
||||
add_subdirectory(Graphics/)
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
#include "EngineTest.h"
|
||||
#include "ThreadPool.h"
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(ThreadPool)
|
||||
|
||||
uint64 basicJobState = 0;
|
||||
|
||||
Job basicThenFirst()
|
||||
{
|
||||
basicJobState = 10;
|
||||
co_return;
|
||||
}
|
||||
Job basicThenSecond()
|
||||
{
|
||||
BOOST_REQUIRE_EQUAL(basicJobState, 10);
|
||||
basicJobState = 20;
|
||||
co_return;
|
||||
}
|
||||
Job basicThenThird()
|
||||
{
|
||||
BOOST_REQUIRE_EQUAL(basicJobState, 20);
|
||||
co_return;
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(basic_then)
|
||||
{
|
||||
basicThenFirst()
|
||||
.then(basicThenSecond())
|
||||
.then(basicThenThird());
|
||||
}
|
||||
|
||||
uint64 basicAllState1 = 0;
|
||||
uint64 basicAllState2 = 0;
|
||||
Job basicAllFirst()
|
||||
{
|
||||
basicAllState1 = 10;
|
||||
co_return;
|
||||
}
|
||||
Job basicAllSecond()
|
||||
{
|
||||
basicAllState2 = 10;
|
||||
co_return;
|
||||
}
|
||||
Job basicAllThen()
|
||||
{
|
||||
BOOST_REQUIRE_EQUAL(basicAllState1, 10);
|
||||
BOOST_REQUIRE_EQUAL(basicAllState2, 10);
|
||||
co_return;
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(basic_all)
|
||||
{
|
||||
Job::all(basicAllFirst(), basicAllSecond()).then(basicAllThen());
|
||||
}
|
||||
|
||||
uint64 basicCallable = 0;
|
||||
|
||||
Job basicCallableFunc()
|
||||
{
|
||||
basicCallable = 10;
|
||||
co_return;
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(basic_callable)
|
||||
{
|
||||
basicCallableFunc()
|
||||
.then([=]() -> Job{
|
||||
BOOST_REQUIRE_EQUAL(basicCallable, 10);
|
||||
co_return;
|
||||
});
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
Reference in New Issue
Block a user