From 5e5b04802c0bd14be50145af5af4798c7d9d4ca6 Mon Sep 17 00:00:00 2001 From: Simon Gog Date: Wed, 29 Jun 2016 15:09:17 +0200 Subject: [PATCH 1/2] sd_vector_builder now works for all sd_vector configuration sd_vector_builder was just working for sd_vector. This is fix now. Also adjusted tests. --- include/sdsl/sd_vector.hpp | 4 ++-- test/bit_vector_test.cpp | 23 +---------------------- test/sd_vector_test.cpp | 27 ++++++++++++++++++++------- 3 files changed, 23 insertions(+), 31 deletions(-) diff --git a/include/sdsl/sd_vector.hpp b/include/sdsl/sd_vector.hpp index ccd453245..33163db78 100644 --- a/include/sdsl/sd_vector.hpp +++ b/include/sdsl/sd_vector.hpp @@ -275,8 +275,8 @@ class sd_vector m_wl = builder.m_wl; m_low.swap(builder.m_low); util::assign(m_high, builder.m_high); - util::init_support(m_high_1_select, this->m_high); - util::init_support(m_high_0_select, this->m_high); + util::init_support(m_high_1_select, &(this->m_high)); + util::init_support(m_high_0_select, &(this->m_high)); builder = sd_vector_builder(); } diff --git a/test/bit_vector_test.cpp b/test/bit_vector_test.cpp index 0060e69f9..42c86cb0f 100644 --- a/test/bit_vector_test.cpp +++ b/test/bit_vector_test.cpp @@ -29,7 +29,7 @@ rrr_vector<192>, rrr_vector<255>, rrr_vector<15>, rrr_vector<31>, -rrr_vector<63>, +rrr_vector rrr_vector<83>, rrr_vector<127>, rrr_vector<128>, @@ -109,27 +109,6 @@ TYPED_TEST(bit_vector_test, swap) } } -/* -TEST(SD_VECTOR, IteratorConstructor) -{ - std::vector pos; - bit_vector bv(100000); - std::mt19937_64 rng; - std::uniform_int_distribution distribution(0, 9); - auto dice = bind(distribution, rng); - for (size_t i=0; i < bv.size(); ++i) { - if (0 == dice()) { - pos.emplace_back(i); - bv[i] = 1; - } - } - sd_vector<> sdv(pos.begin(),pos.end()); - for (size_t i=0; i < bv.size(); ++i) { - ASSERT_EQ((bool)sdv[i],(bool)bv[i]); - } -} -*/ - }// end namespace int main(int argc, char* argv[]) diff --git a/test/sd_vector_test.cpp b/test/sd_vector_test.cpp index f25154a0b..2df84c529 100644 --- a/test/sd_vector_test.cpp +++ b/test/sd_vector_test.cpp @@ -1,4 +1,5 @@ #include "sdsl/sd_vector.hpp" +#include "sdsl/bit_vectors.hpp" #include "gtest/gtest.h" using namespace sdsl; @@ -9,7 +10,19 @@ namespace const size_t BV_SIZE = 1000000; -TEST(sd_vector_test, iterator_constructor) +template +class sd_vector_test : public ::testing::Test { }; + +using testing::Types; + +typedef Types< +sd_vector<>, + sd_vector> + > Implementations; + +TYPED_TEST_CASE(sd_vector_test, Implementations); + +TYPED_TEST(sd_vector_test, iterator_constructor) { std::vector pos; bit_vector bv(BV_SIZE); @@ -22,13 +35,13 @@ TEST(sd_vector_test, iterator_constructor) bv[i] = 1; } } - sd_vector<> sdv(pos.begin(),pos.end()); + TypeParam sdv(pos.begin(),pos.end()); for (size_t i=0; i < bv.size(); ++i) { ASSERT_EQ((bool)sdv[i],(bool)bv[i]); } } -TEST(sd_vector_test, builder_constructor) +TYPED_TEST(sd_vector_test, builder_constructor) { std::vector pos; bit_vector bv(BV_SIZE); @@ -47,18 +60,18 @@ TEST(sd_vector_test, builder_constructor) for (auto i : pos) { builder.set(i); } - sd_vector<> sdv(builder); + TypeParam sdv(builder); for (size_t i=0; i < bv.size(); ++i) { ASSERT_EQ((bool)sdv[i],(bool)bv[i]); } } -TEST(sd_vector_test, builder_empty_constructor) +TYPED_TEST(sd_vector_test, builder_empty_constructor) { sd_vector_builder builder(BV_SIZE, 0UL); - sd_vector<> sdv(builder); + TypeParam sdv(builder); for (size_t i=0; i < BV_SIZE; ++i) { - ASSERT_EQ(0, sdv[i]); + ASSERT_FALSE((bool)sdv[i]); } } From 89677148d303be0a0ad3ae8b3b19a29ef2cf1333 Mon Sep 17 00:00:00 2001 From: Simon Gog Date: Wed, 29 Jun 2016 15:21:18 +0200 Subject: [PATCH 2/2] Add accidentially deleted tparam list again --- test/bit_vector_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/bit_vector_test.cpp b/test/bit_vector_test.cpp index 42c86cb0f..d9591209b 100644 --- a/test/bit_vector_test.cpp +++ b/test/bit_vector_test.cpp @@ -29,7 +29,7 @@ rrr_vector<192>, rrr_vector<255>, rrr_vector<15>, rrr_vector<31>, -rrr_vector +rrr_vector<63>, rrr_vector<83>, rrr_vector<127>, rrr_vector<128>,