Skip to content

Commit 893f99b

Browse files
committed
Improve test error message
1 parent 6cf6829 commit 893f99b

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

cpp/src/arrow/util/bpacking_test.cc

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,20 @@ class TestUnpack : public ::testing::TestWithParam<int> {
114114
const auto packed = PackValues(original, num_values, bit_width, bit_offset);
115115
const auto unpacked =
116116
UnpackValues(packed.data(), num_values, bit_width, bit_offset, unpack);
117-
EXPECT_EQ(unpacked.size(), num_values);
118-
EXPECT_EQ(original, unpacked);
117+
118+
ASSERT_EQ(unpacked.size(), num_values);
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;
119131
}
120132

121133
template <typename Int>
@@ -212,10 +224,10 @@ class TestUnpack : public ::testing::TestWithParam<int> {
212224
if (testing::Test::HasFailure()) return;
213225
}
214226

215-
// Similarly, we test all epilogue sizes. That is extra values that could make it
227+
// Similarly, we test all epilog sizes. That is extra values that could make it
216228
// fall outside of an SIMD register
217229
for (int epilogue_size = 0; epilogue_size <= kMaxBitWidth; ++epilogue_size) {
218-
SCOPED_TRACE(::testing::Message() << "Testing epilogue_size=" << epilogue_size);
230+
SCOPED_TRACE(::testing::Message() << "Testing epilog_size=" << epilogue_size);
219231

220232
const int num_values = num_values_base + epilogue_size;
221233

0 commit comments

Comments
 (0)