Files
comaps/3party/succinct/test_rs_bit_vector.cpp
Konstantin Pastbin e3e4a1985a Organic Maps sources as of 02.04.2025 (fad26bbf22ac3da75e01e62aa01e5c8e11861005)
To expand with full Organic Maps and Maps.ME commits history run:
  git remote add om-historic [om-historic.git repo url]
  git fetch --tags om-historic
  git replace squashed-history historic-commits
2025-05-08 21:10:51 +07:00

60 lines
1.6 KiB
C++

#define BOOST_TEST_MODULE rs_bit_vector
#include "test_common.hpp"
#include "test_rank_select_common.hpp"
#include <cstdlib>
#include <boost/foreach.hpp>
#include "mapper.hpp"
#include "rs_bit_vector.hpp"
BOOST_AUTO_TEST_CASE(rs_bit_vector)
{
srand(42);
// empty vector
std::vector<bool> v;
succinct::rs_bit_vector bitmap;
succinct::rs_bit_vector(v).swap(bitmap);
BOOST_REQUIRE_EQUAL(v.size(), bitmap.size());
succinct::rs_bit_vector(v, true).swap(bitmap);
BOOST_REQUIRE_EQUAL(v.size(), bitmap.size());
// random vector
v = random_bit_vector();
succinct::rs_bit_vector(v).swap(bitmap);
BOOST_REQUIRE_EQUAL(v.size(), bitmap.size());
test_equal_bits(v, bitmap, "RS - Uniform bits");
test_rank_select(v, bitmap, "Uniform bits");
succinct::rs_bit_vector(v, true, true).swap(bitmap);
test_rank_select(v, bitmap, "Uniform bits - with hints");
v.resize(10000);
v[9999] = 1;
v[9000] = 1;
succinct::rs_bit_vector(v).swap(bitmap);
BOOST_REQUIRE_EQUAL(v.size(), bitmap.size());
test_rank_select(v, bitmap, "Long runs of 0");
succinct::rs_bit_vector(v, true, true).swap(bitmap);
test_rank_select(v, bitmap, "Long runs of 0 - with hints");
// corner cases
v.clear();
v.resize(10000);
v[0] = 1;
v[511] = 1;
v[512] = 1;
v[1024] = 1;
v[2112] = 1;
succinct::rs_bit_vector(v).swap(bitmap);
BOOST_REQUIRE_EQUAL(v.size(), bitmap.size());
test_rank_select(v, bitmap, "Corner cases");
succinct::rs_bit_vector(v, true).swap(bitmap);
test_rank_select(v, bitmap, "Corner cases - with hints");
}