MCPcopy Create free account
hub / github.com/apache/kudu / TestBitArrayValues

Function TestBitArrayValues

src/kudu/util/rle-test.cc:110–130  ·  view source on GitHub ↗

Writes 'num_vals' values with width 'bit_width' and reads them back.

Source from the content-addressed store, hash-verified

108
109// Writes 'num_vals' values with width 'bit_width' and reads them back.
110void TestBitArrayValues(int bit_width, int num_vals) {
111 const int kTestLen = BitUtil::Ceil<3>(bit_width * num_vals);
112 const uint64_t mod = bit_width == 64? 1 : 1LL << bit_width;
113
114 faststring buffer(kTestLen);
115 BitWriter writer(&buffer);
116 for (int i = 0; i < num_vals; ++i) {
117 writer.PutValue(i % mod, bit_width);
118 }
119 writer.Flush();
120 EXPECT_EQ(writer.bytes_written(), kTestLen);
121
122 BitReader reader(buffer.data(), kTestLen);
123 for (int i = 0; i < num_vals; ++i) {
124 int64_t val = 0;
125 bool result = reader.GetValue(bit_width, &val);
126 EXPECT_TRUE(result);
127 EXPECT_EQ(val, i % mod);
128 }
129 EXPECT_EQ(reader.bytes_left(), 0);
130}
131
132TEST(BitArray, TestValues) {
133 for (int width = 1; width <= kMaxWidth; ++width) {

Callers 1

TESTFunction · 0.85

Calls 6

PutValueMethod · 0.80
bytes_writtenMethod · 0.80
bytes_leftMethod · 0.80
FlushMethod · 0.45
dataMethod · 0.45
GetValueMethod · 0.45

Tested by

no test coverage detected