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

Function BOOST_AUTO_TEST_CASE

3party/succinct/test_rs_bit_vector.cpp:11–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9#include "rs_bit_vector.hpp"
10
11BOOST_AUTO_TEST_CASE(rs_bit_vector)
12{
13 srand(42);
14
15 // empty vector
16 std::vector<bool> v;
17 succinct::rs_bit_vector bitmap;
18
19 succinct::rs_bit_vector(v).swap(bitmap);
20 BOOST_REQUIRE_EQUAL(v.size(), bitmap.size());
21 succinct::rs_bit_vector(v, true).swap(bitmap);
22 BOOST_REQUIRE_EQUAL(v.size(), bitmap.size());
23
24 // random vector
25 v = random_bit_vector();
26
27 succinct::rs_bit_vector(v).swap(bitmap);
28 BOOST_REQUIRE_EQUAL(v.size(), bitmap.size());
29 test_equal_bits(v, bitmap, "RS - Uniform bits");
30 test_rank_select(v, bitmap, "Uniform bits");
31
32 succinct::rs_bit_vector(v, true, true).swap(bitmap);
33 test_rank_select(v, bitmap, "Uniform bits - with hints");
34
35 v.resize(10000);
36 v[9999] = 1;
37 v[9000] = 1;
38 succinct::rs_bit_vector(v).swap(bitmap);
39
40 BOOST_REQUIRE_EQUAL(v.size(), bitmap.size());
41 test_rank_select(v, bitmap, "Long runs of 0");
42 succinct::rs_bit_vector(v, true, true).swap(bitmap);
43 test_rank_select(v, bitmap, "Long runs of 0 - with hints");
44
45 // corner cases
46 v.clear();
47 v.resize(10000);
48 v[0] = 1;
49 v[511] = 1;
50 v[512] = 1;
51 v[1024] = 1;
52 v[2112] = 1;
53 succinct::rs_bit_vector(v).swap(bitmap);
54
55 BOOST_REQUIRE_EQUAL(v.size(), bitmap.size());
56 test_rank_select(v, bitmap, "Corner cases");
57 succinct::rs_bit_vector(v, true).swap(bitmap);
58 test_rank_select(v, bitmap, "Corner cases - with hints");
59}

Callers

nothing calls this directly

Calls 8

rs_bit_vectorClass · 0.85
random_bit_vectorFunction · 0.85
test_equal_bitsFunction · 0.85
test_rank_selectFunction · 0.85
swapMethod · 0.45
sizeMethod · 0.45
resizeMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected