mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-23 02:42:39 +01:00
50 lines
956 B
C++
50 lines
956 B
C++
#include <boost/test/unit_test.hpp>
|
|
#include <job/WorkContext.hpp>
|
|
|
|
class TestJob : public WorkJob {
|
|
public:
|
|
bool *_worked, *_completed;
|
|
|
|
TestJob(WorkContext *context, bool *w, bool *c)
|
|
: WorkJob(context), _worked(w), _completed(c) {
|
|
}
|
|
|
|
void work() {
|
|
*_worked = true;
|
|
}
|
|
|
|
void complete() {
|
|
*_completed = true;
|
|
}
|
|
};
|
|
|
|
BOOST_AUTO_TEST_SUITE(WorkTests)
|
|
|
|
BOOST_AUTO_TEST_CASE(test_interface) {
|
|
{
|
|
WorkContext context;
|
|
|
|
bool worked = false, completed = false;
|
|
|
|
TestJob *job = new TestJob(&context, &worked, &completed);
|
|
|
|
BOOST_CHECK(!worked);
|
|
BOOST_CHECK(!completed);
|
|
|
|
context.queueJob(job);
|
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
|
|
|
BOOST_CHECK(worked);
|
|
BOOST_CHECK(!completed);
|
|
|
|
context.update();
|
|
;
|
|
|
|
BOOST_CHECK(worked);
|
|
BOOST_CHECK(completed);
|
|
}
|
|
}
|
|
|
|
BOOST_AUTO_TEST_SUITE_END()
|