Skip to content

Commit 5f71424

Browse files
authored
Merge pull request #289 from kkacprzak/jpettask_tests
Add tests for JPetTask class
2 parents f8fb6f3 + 31dceac commit 5f71424

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed

tests/Core/JPetTask/JPetTaskTest.cpp

+38-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @copyright Copyright 2018 The J-PET Framework Authors. All rights reserved.
2+
* @copyright Copyright 2022 The J-PET Framework Authors. All rights reserved.
33
* Licensed under the Apache License, Version 2.0 (the "License");
44
* you may not use this file except in compliance with the License.
55
* You may find a copy of the License in the LICENCE file.
@@ -19,8 +19,44 @@
1919

2020
#include <boost/test/unit_test.hpp>
2121

22+
class TestTask : public JPetTask
23+
{
24+
public:
25+
explicit TestTask(const char* name = "") : JPetTask(name) {}
26+
bool init(const JPetParams&) override { return true; }
27+
bool run(const JPetDataInterface&) override { return true; }
28+
bool terminate(JPetParams&) override { return true; }
29+
};
30+
2231
BOOST_AUTO_TEST_SUITE(JPetTaskTestSuite)
2332

24-
BOOST_AUTO_TEST_CASE(my_test) {}
33+
BOOST_AUTO_TEST_CASE(constructor_test)
34+
{
35+
TestTask task;
36+
BOOST_REQUIRE_EQUAL(task.getName(), "");
37+
BOOST_REQUIRE_EQUAL(task.getSubTasks().size(), 0);
38+
}
39+
40+
BOOST_AUTO_TEST_CASE(task_name_test)
41+
{
42+
TestTask task("the_task");
43+
BOOST_REQUIRE_EQUAL(task.getName(), "the_task");
44+
task.setName("same_task");
45+
BOOST_REQUIRE_EQUAL(task.getName(), "same_task");
46+
}
47+
48+
BOOST_AUTO_TEST_CASE(subtask_test)
49+
{
50+
TestTask task("task");
51+
52+
std::unique_ptr<JPetTaskInterface> pTask1;
53+
std::unique_ptr<JPetTaskInterface> pTask2;
54+
std::unique_ptr<JPetTaskInterface> pTask3;
55+
task.addSubTask(std::move(pTask1));
56+
task.addSubTask(std::move(pTask2));
57+
task.addSubTask(std::move(pTask3));
58+
59+
BOOST_REQUIRE_EQUAL(task.getSubTasks().size(), 3);
60+
}
2561

2662
BOOST_AUTO_TEST_SUITE_END()

0 commit comments

Comments
 (0)