Skip to content

Commit 0ae738f

Browse files
authored
Merge pull request #333 from simongog/fix_sd_vector_builder
sd_vector_builder now works for all sd_vector configurations
2 parents 7a7bec4 + 8967714 commit 0ae738f

File tree

3 files changed

+22
-30
lines changed

3 files changed

+22
-30
lines changed

include/sdsl/sd_vector.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,8 @@ class sd_vector
275275
m_wl = builder.m_wl;
276276
m_low.swap(builder.m_low);
277277
util::assign(m_high, builder.m_high);
278-
util::init_support(m_high_1_select, this->m_high);
279-
util::init_support(m_high_0_select, this->m_high);
278+
util::init_support(m_high_1_select, &(this->m_high));
279+
util::init_support(m_high_0_select, &(this->m_high));
280280

281281
builder = sd_vector_builder();
282282
}

test/bit_vector_test.cpp

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -109,27 +109,6 @@ TYPED_TEST(bit_vector_test, swap)
109109
}
110110
}
111111

112-
/*
113-
TEST(SD_VECTOR, IteratorConstructor)
114-
{
115-
std::vector<uint64_t> pos;
116-
bit_vector bv(100000);
117-
std::mt19937_64 rng;
118-
std::uniform_int_distribution<uint64_t> distribution(0, 9);
119-
auto dice = bind(distribution, rng);
120-
for (size_t i=0; i < bv.size(); ++i) {
121-
if (0 == dice()) {
122-
pos.emplace_back(i);
123-
bv[i] = 1;
124-
}
125-
}
126-
sd_vector<> sdv(pos.begin(),pos.end());
127-
for (size_t i=0; i < bv.size(); ++i) {
128-
ASSERT_EQ((bool)sdv[i],(bool)bv[i]);
129-
}
130-
}
131-
*/
132-
133112
}// end namespace
134113

135114
int main(int argc, char* argv[])

test/sd_vector_test.cpp

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "sdsl/sd_vector.hpp"
2+
#include "sdsl/bit_vectors.hpp"
23
#include "gtest/gtest.h"
34

45
using namespace sdsl;
@@ -9,7 +10,19 @@ namespace
910

1011
const size_t BV_SIZE = 1000000;
1112

12-
TEST(sd_vector_test, iterator_constructor)
13+
template<class T>
14+
class sd_vector_test : public ::testing::Test { };
15+
16+
using testing::Types;
17+
18+
typedef Types<
19+
sd_vector<>,
20+
sd_vector<rrr_vector<63>>
21+
> Implementations;
22+
23+
TYPED_TEST_CASE(sd_vector_test, Implementations);
24+
25+
TYPED_TEST(sd_vector_test, iterator_constructor)
1326
{
1427
std::vector<uint64_t> pos;
1528
bit_vector bv(BV_SIZE);
@@ -22,13 +35,13 @@ TEST(sd_vector_test, iterator_constructor)
2235
bv[i] = 1;
2336
}
2437
}
25-
sd_vector<> sdv(pos.begin(),pos.end());
38+
TypeParam sdv(pos.begin(),pos.end());
2639
for (size_t i=0; i < bv.size(); ++i) {
2740
ASSERT_EQ((bool)sdv[i],(bool)bv[i]);
2841
}
2942
}
3043

31-
TEST(sd_vector_test, builder_constructor)
44+
TYPED_TEST(sd_vector_test, builder_constructor)
3245
{
3346
std::vector<uint64_t> pos;
3447
bit_vector bv(BV_SIZE);
@@ -47,18 +60,18 @@ TEST(sd_vector_test, builder_constructor)
4760
for (auto i : pos) {
4861
builder.set(i);
4962
}
50-
sd_vector<> sdv(builder);
63+
TypeParam sdv(builder);
5164
for (size_t i=0; i < bv.size(); ++i) {
5265
ASSERT_EQ((bool)sdv[i],(bool)bv[i]);
5366
}
5467
}
5568

56-
TEST(sd_vector_test, builder_empty_constructor)
69+
TYPED_TEST(sd_vector_test, builder_empty_constructor)
5770
{
5871
sd_vector_builder builder(BV_SIZE, 0UL);
59-
sd_vector<> sdv(builder);
72+
TypeParam sdv(builder);
6073
for (size_t i=0; i < BV_SIZE; ++i) {
61-
ASSERT_EQ(0, sdv[i]);
74+
ASSERT_FALSE((bool)sdv[i]);
6275
}
6376
}
6477

0 commit comments

Comments
 (0)