TEST_F(ZlibDecompressorImplTest, CallingChecksum) {
  Buffer::OwnedImpl compressor_buffer;
  Buffer::OwnedImpl decompressor_output_buffer;

  Extensions::Compression::Gzip::Compressor::ZlibCompressorImpl compressor;
  ASSERT_EQ(0, compressor.checksum());

  compressor.init(
      Extensions::Compression::Gzip::Compressor::ZlibCompressorImpl::CompressionLevel::Standard,
      Extensions::Compression::Gzip::Compressor::ZlibCompressorImpl::CompressionStrategy::Standard,
      gzip_window_bits, memory_level);
  ASSERT_EQ(0, compressor.checksum());

  TestUtility::feedBufferWithRandomCharacters(compressor_buffer, 4096);
  compressor.compress(compressor_buffer, Envoy::Compression::Compressor::State::Flush);
  ASSERT_TRUE(compressor.checksum() > 0);

  Stats::IsolatedStoreImpl stats_store{};
  ZlibDecompressorImpl decompressor{stats_store, "test."};
  decompressor.init(gzip_window_bits);
  EXPECT_EQ(0, decompressor.checksum());

  decompressor.decompress(compressor_buffer, decompressor_output_buffer);

  drainBuffer(compressor_buffer);
  drainBuffer(decompressor_output_buffer);

  EXPECT_EQ(compressor.checksum(), decompressor.checksum());
  ASSERT_EQ(0, decompressor.decompression_error_);
}
TEST_F(ZlibDecompressorImplTest, CallingChecksum) {
  Buffer::OwnedImpl compressor_buffer;
  Buffer::OwnedImpl decompressor_output_buffer;

  Extensions::Compression::Gzip::Compressor::ZlibCompressorImpl compressor;
  ASSERT_EQ(0, compressor.checksum());

  compressor.init(
      Extensions::Compression::Gzip::Compressor::ZlibCompressorImpl::CompressionLevel::Standard,
      Extensions::Compression::Gzip::Compressor::ZlibCompressorImpl::CompressionStrategy::Standard,
      gzip_window_bits, memory_level);
  ASSERT_EQ(0, compressor.checksum());

  TestUtility::feedBufferWithRandomCharacters(compressor_buffer, 4096);
  compressor.compress(compressor_buffer, Envoy::Compression::Compressor::State::Flush);
  ASSERT_TRUE(compressor.checksum() > 0);

  Stats::IsolatedStoreImpl stats_store{};
  ZlibDecompressorImpl decompressor{stats_store, "test."};
  decompressor.init(gzip_window_bits);
  EXPECT_EQ(0, decompressor.checksum());

  decompressor.decompress(compressor_buffer, decompressor_output_buffer);

  drainBuffer(compressor_buffer);
  drainBuffer(decompressor_output_buffer);

  EXPECT_EQ(compressor.checksum(), decompressor.checksum());
  ASSERT_EQ(0, decompressor.decompression_error_);
}