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

Function TEST

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

Source from the content-addressed store, hash-verified

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