| 63 | |
| 64 | template <typename T, typename Sch, typename Check, typename F, typename Proj = std::identity> |
| 65 | void test(Sch &&sch, F bop, Proj proj, Check check) { |
| 66 | |
| 67 | std::vector<std::size_t> ns = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; |
| 68 | |
| 69 | if (!std::same_as<T, std::string>) { |
| 70 | ns.insert(ns.end(), {30, 1'000, 3'000, 10'000, 30'000, 100'000, 300'000, 1'000'000, 3'000'000}); |
| 71 | } |
| 72 | |
| 73 | for (std::size_t n : ns) { // |
| 74 | |
| 75 | std::vector<T> in = random_vec(std::type_identity<T>{}, n); |
| 76 | |
| 77 | std::vector<T> const out_ok = check(in); |
| 78 | |
| 79 | std::vector<int> chunks; |
| 80 | |
| 81 | if (n <= 10) { |
| 82 | for (std::size_t i = 1; i <= n; ++i) { |
| 83 | chunks.emplace_back(i); |
| 84 | } |
| 85 | } else { |
| 86 | |
| 87 | std::size_t ch = 11; |
| 88 | |
| 89 | do { |
| 90 | chunks.emplace_back(ch); |
| 91 | ch *= 11; |
| 92 | } while (ch <= n); |
| 93 | } |
| 94 | |
| 95 | for (int chunk : chunks) { |
| 96 | |
| 97 | if (chunk == 0) { |
| 98 | continue; |
| 99 | } |
| 100 | |
| 101 | if (std::cmp_greater(chunk, n)) { |
| 102 | break; |
| 103 | } |
| 104 | |
| 105 | // Test all eight overloads |
| 106 | |
| 107 | // std::cout << "n: " << n << " chunk: " << chunk << '\n'; |
| 108 | |
| 109 | for (std::size_t ll = 0; ll < (n < 10 ? 10 : 1); ++ll) { |
| 110 | /* [iterator,chunk,output] */ { |
| 111 | std::vector<T> out(in.size()); |
| 112 | lf::sync_wait(sch, lf::scan, in.begin(), in.end(), out.begin(), chunk, bop, proj); |
| 113 | REQUIRE(out == out_ok); |
| 114 | } |
| 115 | /* [iterator,n = 1,output] */ { |
| 116 | if (chunk == 1) { |
| 117 | std::vector<T> out(in.size()); |
| 118 | lf::sync_wait(sch, lf::scan, in.begin(), in.end(), out.begin(), bop, proj); |
| 119 | REQUIRE(out == out_ok); |
| 120 | } |
| 121 | } |
| 122 | /* [iterator,chunk,in_place] */ { |
nothing calls this directly
no test coverage detected