diff --git a/test/algorithm_test.cpp b/test/algorithm_test.cpp index 702901a..498e169 100644 --- a/test/algorithm_test.cpp +++ b/test/algorithm_test.cpp @@ -61,3 +61,28 @@ TEST_CASE("scan functions correctly", "[algorithms/scan.h]") { REQUIRE (all_correct); }); } + +long fib(long n) { + if (n <= 2) { + return 1; + } + + long a, b; + + pls::invoke( + [&a, n]() { a = fib(n - 1); }, + [&b, n]() { b = fib(n - 2); } + ); + + return a + b; +} + +TEST_CASE("invoke functions correctly", "[algorithms/invoke.h]") { + constexpr long fib_40 = 102334155; + + malloc_scheduler_memory my_scheduler_memory{8, 2 << 12}; + scheduler my_scheduler{&my_scheduler_memory, 2}; + my_scheduler.perform_work([=]() { + REQUIRE(fib(40) == fib_40); + }); +}