Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
mapleFU committed Oct 18, 2023
1 parent c9e5af9 commit 4218afd
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions cpp/src/parquet/file_deserialize_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -881,10 +881,12 @@ TEST_F(TestPageSerde, DataPageV2CrcCheckNonExistent) {

TEST_F(TestPageSerde, BadCompressedPageSize) {
auto codec_types = GetSupportedCodecTypes();
const int data_page_bytes = 8192;
const int32_t num_rows = 32; // dummy value
data_page_header_.num_values = num_rows;
std::vector<uint8_t> faux_data;
test::random_bytes(1024, 0, &faux_data);
// Resize and make all to 1 to make it well-compressed.
faux_data.resize(data_page_bytes, 1);
for (auto codec_type : codec_types) {
auto codec = GetCodec(codec_type);
std::vector<uint8_t> buffer;
Expand All @@ -897,13 +899,8 @@ TEST_F(TestPageSerde, BadCompressedPageSize) {
int64_t actual_size;
ASSERT_OK_AND_ASSIGN(
actual_size, codec->Compress(data_size, data, max_compressed_size, &buffer[0]));

actual_size += 1; // corrupt the compressed data
if (buffer.size() < static_cast<size_t>(actual_size)) {
buffer.resize(actual_size);
}
ASSERT_NO_FATAL_FAILURE(
WriteDataPageHeader(1024, data_size, static_cast<int32_t>(actual_size)));
WriteDataPageHeader(data_page_bytes, data_size + 1, static_cast<int32_t>(actual_size)));
ASSERT_OK(out_stream_->Write(buffer.data(), actual_size));
InitSerializedPageReader(num_rows, codec_type);
EXPECT_THROW(page_reader_->NextPage(), ParquetException) << codec_type;
Expand Down

0 comments on commit 4218afd

Please sign in to comment.