diff --git a/test/algorithm_test.cpp b/test/algorithm_test.cpp index 41eb56b..702901a 100644 --- a/test/algorithm_test.cpp +++ b/test/algorithm_test.cpp @@ -43,3 +43,21 @@ TEST_CASE("for_each functions correctly", "[algorithms/for_each.h]") { } }); } + +TEST_CASE("scan functions correctly", "[algorithms/scan.h]") { + malloc_scheduler_memory my_scheduler_memory{8, 2 << 12}; + scheduler my_scheduler{&my_scheduler_memory, 2}; + my_scheduler.perform_work([]() { + constexpr int SIZE = 1000; + std::array input_array{}, result_array{}; + input_array.fill(1); + + pls::scan(input_array.begin(), input_array.end(), result_array.begin(), std::plus(), 0); + + bool all_correct = true; + for (int i = 0; i < SIZE; i++) { + all_correct &= result_array[i] == (i + 1); + } + REQUIRE (all_correct); + }); +}