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

Method TestRoundtripAlignment

cpp/src/arrow/util/bpacking_test.cc:111–131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

109class TestUnpack : public ::testing::Test {
110 protected:
111 void TestRoundtripAlignment(UnpackFunc<Int> unpack, const UnpackOptions& opts) {
112 const auto original =
113 GenerateRandomValuesForPacking<Int>(opts.batch_size, opts.bit_width);
114 const auto packed =
115 PackValues(original, opts.batch_size, opts.bit_width, opts.bit_offset);
116 const auto unpacked = UnpackValues(packed.data(), opts, unpack);
117
118 ASSERT_EQ(unpacked.size(), opts.batch_size);
119 const auto [iter_original, iter_unpacked] =
120 std::mismatch(original.cbegin(), original.cend(), unpacked.cbegin());
121 Int val_original = 0;
122 Int val_unpacked = 0;
123 const auto mismatch_idx = static_cast<std::size_t>(iter_original - original.cbegin());
124 if (mismatch_idx < unpacked.size()) {
125 val_original = *iter_original;
126 val_unpacked = *iter_unpacked;
127 }
128 EXPECT_EQ(original, unpacked) << "At position " << mismatch_idx << "/"
129 << unpacked.size() << ", expected original value "
130 << val_original << " but unpacked " << val_unpacked;
131 }
132
133 void TestUnpackZeros(UnpackFunc<Int> unpack, const UnpackOptions& opts) {
134 const auto num_bytes = GetNumBytes(opts.batch_size, opts.bit_width, opts.bit_offset);

Callers

nothing calls this directly

Calls 6

PackValuesFunction · 0.85
UnpackValuesFunction · 0.85
cbeginMethod · 0.80
cendMethod · 0.80
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected