MCPcopy Create free account
hub / github.com/apache/arrow / TEST

Function TEST

cpp/src/arrow/util/rle_encoding_test.cc:45–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43const int MAX_WIDTH = 32;
44
45TEST(BitArray, TestBool) {
46 const int len = 8;
47 uint8_t buffer[len];
48
49 bit_util::BitWriter writer(buffer, len);
50
51 // Write alternating 0's and 1's
52 for (int i = 0; i < 8; ++i) {
53 EXPECT_TRUE(writer.PutValue(i % 2, 1));
54 }
55 writer.Flush();
56
57 EXPECT_EQ(buffer[0], 0xAA /* 0b10101010 */);
58
59 // Write 00110011
60 for (int i = 0; i < 8; ++i) {
61 bool result = false;
62 switch (i) {
63 case 0:
64 case 1:
65 case 4:
66 case 5:
67 result = writer.PutValue(false, 1);
68 break;
69 default:
70 result = writer.PutValue(true, 1);
71 break;
72 }
73 EXPECT_TRUE(result);
74 }
75 writer.Flush();
76
77 // Validate the exact bit value
78 EXPECT_EQ(buffer[0], 0xAA /* 0b10101010 */);
79 EXPECT_EQ(buffer[1], 0xCC /* 0b11001100 */);
80
81 // Use the reader and validate
82 bit_util::BitReader reader(buffer, len);
83 for (int i = 0; i < 8; ++i) {
84 bool val = false;
85 bool result = reader.GetValue(1, &val);
86 EXPECT_TRUE(result);
87 EXPECT_EQ(val, (i % 2) != 0);
88 }
89
90 for (int i = 0; i < 8; ++i) {
91 bool val = false;
92 bool result = reader.GetValue(1, &val);
93 EXPECT_TRUE(result);
94 switch (i) {
95 case 0:
96 case 1:
97 case 4:
98 case 5:
99 EXPECT_EQ(val, false);
100 break;
101 default:
102 EXPECT_EQ(val, true);

Callers

nothing calls this directly

Calls 15

TestBitArrayValuesFunction · 0.85
TestPutValueFunction · 0.85
RleRunClass · 0.85
BitPackedRunClass · 0.85
ValidateRleBitPackedFunction · 0.85
CeilDivFunction · 0.85
TestRleValuesFunction · 0.85
GetRandomSeedFunction · 0.85
CheckRoundTripFunction · 0.85
PutValueMethod · 0.80
resizeMethod · 0.80

Tested by

no test coverage detected