Commit 449a89ef by FritzFlorian

Add test for invoke.

parent ee8414cf
Pipeline #1267 failed with stages
in 37 seconds
......@@ -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);
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment