MCPcopy Create free account
hub / github.com/cp-algorithms/cp-algorithms / test_generic_sparsetable

Function test_generic_sparsetable

test/test_sparsetable.cpp:11–28  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9const std::vector<int> array = {19, 16, 2, 15, 2, 12, 13, 13, 18, 14, 0, 4, 17, 17, 4};
10
11void test_generic_sparsetable() {
12 auto f = [&](int x, int y=0) { return x + y; };
13
14 #include "sparsetable_definition.h"
15 #include "sparsetable_generation.h"
16
17 auto sum_query = [&](int L, int R) {
18 #include "sparsetable_sum_query.h"
19 return sum;
20 };
21
22 for (int L = 0; L < N; L++) {
23 for (int R = L; R < N; R++) {
24 int sum = std::accumulate(array.begin() + L, array.begin() + R + 1, 0);
25 assert(sum == sum_query(L, R));
26 }
27 }
28}
29
30void test_range_sum_sparsetable() {
31 #include "sparsetable_sum_generation.h"

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected