MCPcopy Create free account
hub / github.com/comaps/comaps / test_darray

Function test_darray

3party/succinct/test_darray.cpp:11–33  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9#include "darray.hpp"
10
11void test_darray(std::vector<bool> const& v, const char* test_name)
12{
13 succinct::bit_vector bv(v);
14 succinct::darray1 d1(bv);
15 succinct::darray0 d0(bv);
16
17 size_t cur_rank = 0;
18 size_t cur_rank0 = 0;
19 for (size_t i = 0; i < v.size(); ++i) {
20 if (v[i]) {
21 MY_REQUIRE_EQUAL(i, d1.select(bv, cur_rank),
22 "select (" << test_name << "): cur_rank = " << cur_rank << ", i = " << i << ", v[i] = " << v[i]);
23 cur_rank += 1;
24 } else {
25 MY_REQUIRE_EQUAL(i, d0.select(bv, cur_rank0),
26 "select0 (" << test_name << "): cur_rank0 = " << cur_rank0 << ", i = " << i << ", v[i] = " << v[i]);
27 cur_rank0 += 1;
28 }
29 }
30
31 BOOST_REQUIRE_EQUAL(cur_rank, d1.num_positions());
32 BOOST_REQUIRE_EQUAL(cur_rank0, d0.num_positions());
33}
34
35BOOST_AUTO_TEST_CASE(darray)
36{

Callers 1

BOOST_AUTO_TEST_CASEFunction · 0.85

Calls 3

num_positionsMethod · 0.80
sizeMethod · 0.45
selectMethod · 0.45

Tested by

no test coverage detected