diff options
author | Nao Pross <naopross@thearcway.org> | 2019-01-22 04:31:30 +0100 |
---|---|---|
committer | Nao Pross <naopross@thearcway.org> | 2019-01-22 04:31:30 +0100 |
commit | e584e04c5f8ffb14e50c701c1fd8178457a51743 (patch) | |
tree | 369599a34ae52ade9119d08a19c3fffe2a15b63d /test | |
parent | Update .gitignore, delete test/test (diff) | |
download | flatland-e584e04c5f8ffb14e50c701c1fd8178457a51743.tar.gz flatland-e584e04c5f8ffb14e50c701c1fd8178457a51743.zip |
Add test for task and job, fix bug in job
By being a std::set job did not allow to add duplicate elements,
changing it to a std::multiset fixed the issue.
Diffstat (limited to 'test')
-rw-r--r-- | test/task_test.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/test/task_test.cpp b/test/task_test.cpp new file mode 100644 index 0000000..074eb94 --- /dev/null +++ b/test/task_test.cpp @@ -0,0 +1,39 @@ +#include "task.hpp" + +#include <functional> +#include <iostream> + + +struct hello_class { + const std::string motd = "hello world!"; + + void print_motd() { + std::cout << motd << std::endl; + } +}; + + +void hello() { + std::cout << "hello!" << std::endl; +} + +int main(int argc, char *argv[]) { + + using namespace flat::core; + + job job; + + // test a function + task t_func(hello); + job.add_task(t_func); + + // test a member function + hello_class h; + task t_mem([&](){ h.print_motd(); }); + job.add_task(t_mem); + + // invoke tasks + job.invoke_tasks(); + + return 0; +} |