|
1 | 1 | /**
|
2 |
| - * @copyright Copyright 2018 The J-PET Framework Authors. All rights reserved. |
| 2 | + * @copyright Copyright 2022 The J-PET Framework Authors. All rights reserved. |
3 | 3 | * Licensed under the Apache License, Version 2.0 (the "License");
|
4 | 4 | * you may not use this file except in compliance with the License.
|
5 | 5 | * You may find a copy of the License in the LICENCE file.
|
|
19 | 19 |
|
20 | 20 | #include <boost/test/unit_test.hpp>
|
21 | 21 |
|
| 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 | + |
22 | 31 | BOOST_AUTO_TEST_SUITE(JPetTaskTestSuite)
|
23 | 32 |
|
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 | +} |
25 | 61 |
|
26 | 62 | BOOST_AUTO_TEST_SUITE_END()
|
0 commit comments