summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorancarola <raffaele.ancarola@epfl.ch>2019-01-23 16:47:53 +0100
committerancarola <raffaele.ancarola@epfl.ch>2019-01-23 16:47:53 +0100
commitf5cd19114ef036dd73bd6166235efa1d3c0f657d (patch)
treed794685175c9c69fc975e4c9f85bd98d6bf10abe /test
parentMerge remote-tracking branch 'nao/raii-task' (diff)
downloadflatland-f5cd19114ef036dd73bd6166235efa1d3c0f657d.tar.gz
flatland-f5cd19114ef036dd73bd6166235efa1d3c0f657d.zip
Task debugging
Diffstat (limited to 'test')
-rw-r--r--test/task_test.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/test/task_test.cpp b/test/task_test.cpp
index 199d510..e578bfd 100644
--- a/test/task_test.cpp
+++ b/test/task_test.cpp
@@ -3,9 +3,21 @@
#include <functional>
#include <iostream>
+using namespace flat::core;
// test class
struct message {
+
+ message(job& m_job, bool date)
+ {
+ if (date)
+ mytask = m_job.make_task(std::bind(&message::print_date, *this));
+ else
+ mytask = m_job.make_task(std::bind(&message::print_motd, *this));
+ }
+
+ std::shared_ptr<task> mytask;
+
std::string motd = "today we have no motd!";
std::string date = "1 Jan 1970";
@@ -30,8 +42,6 @@ void ciao() {
int main(int argc, char *argv[]) {
- using namespace flat::core;
-
std::cout << "Testing functions" << std::endl;
std::cout << "should print once: hello!" << std::endl;
@@ -54,13 +64,11 @@ int main(int argc, char *argv[]) {
job m_job;
// test a method
- message m;
- m_job.make_task(std::bind(&message::print_motd, m));
+ message m(m_job, false);
// test a method of an object that goes out of scope
{
- message out;
- m_job.make_task(std::bind(&message::print_date, out));
+ message out(m_job, true);
}
// invoke tasks