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

Method TestRoundtripAlignment

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

Source from the content-addressed store, hash-verified

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