| 22 | #include "platforms/coroutine_runtime.h" // for is_shutdown_requested() |
| 23 | |
| 24 | FL_TEST_FILE(FL_FILEPATH) { |
| 25 | |
| 26 | using namespace fl; |
| 27 | using fl::task::Executor; |
| 28 | using fl::task::Runner; |
| 29 | using fl::task::Scheduler; |
| 30 | using fl::task::run; |
| 31 | using fl::task::active_tasks; |
| 32 | using fl::task::has_tasks; |
| 33 | using fl::task::CoroutineConfig; |
| 34 | |
| 35 | // Test helper: A simple test async runner |
| 36 | class TestAsyncRunner : public fl::task::Runner { |
| 37 | public: |
| 38 | TestAsyncRunner() : update_count(0), active(false), task_count(0) {} |
| 39 | |
| 40 | void update() override { |
| 41 | update_count++; |
| 42 | } |
| 43 | |
| 44 | bool has_active_tasks() const override { |
| 45 | return active; |
| 46 | } |
| 47 | |
| 48 | size_t active_task_count() const override { |
| 49 | return task_count; |
| 50 | } |
| 51 | |
| 52 | void set_active(bool value) { active = value; } |
| 53 | void set_task_count(size_t count) { task_count = count; } |
| 54 | |
| 55 | int update_count; |
| 56 | |
| 57 | private: |
| 58 | bool active; |
| 59 | size_t task_count; |
| 60 | }; |
| 61 | |
| 62 | FL_TEST_CASE("fl::task::Runner interface") { |
| 63 | FL_SUBCASE("basic implementation") { |
| 64 | TestAsyncRunner runner; |
| 65 | |
| 66 | FL_CHECK_EQ(runner.update_count, 0); |
| 67 | FL_CHECK_EQ(runner.has_active_tasks(), false); |
| 68 | FL_CHECK_EQ(runner.active_task_count(), 0); |
| 69 | |
| 70 | runner.update(); |
| 71 | FL_CHECK_EQ(runner.update_count, 1); |
| 72 | |
| 73 | runner.set_active(true); |
| 74 | runner.set_task_count(5); |
| 75 | FL_CHECK_EQ(runner.has_active_tasks(), true); |
| 76 | FL_CHECK_EQ(runner.active_task_count(), 5); |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | FL_TEST_CASE("fl::task::Executor") { |
| 81 | FL_SUBCASE("singleton instance") { |
nothing calls this directly
no test coverage detected