src/storage/blobfs/test/unit/seekable-compressor-test.cc
// Tests a contained case of compression and decompression.
//
// size: The size of the input buffer.
// step: The step size of updating the compression buffer.
Tests a contained case of compression and decompression.
size: The size of the input buffer.
step: The step size of updating the compression buffer.
Tests a contained case of compression and decompression . size : The size of the input buffer . step : The step size of updating the compression buffer .
void RunCompressDecompressTest(CompressionAlgorithm algorithm, DataType data_type, size_t size,
                               size_t step) {
  ASSERT_LE(step, size) << "Step size too large";
  unsigned seed = ::testing::UnitTest::GetInstance()->random_seed();
  std::unique_ptr<char[]> input(GenerateInput(data_type, &seed, size));
  std::optional<BlobCompressor> compressor;
  CompressionHelper(algorithm, input.get(), size, step, &compressor);
  ASSERT_TRUE(compressor);
  std::unique_ptr<SeekableDecompressor> decompressor;
  switch (algorithm) {
    case CompressionAlgorithm::CHUNKED: {
      ASSERT_EQ(SeekableChunkedDecompressor::CreateDecompressor(
                    compressor->Data(), compressor->Size(), compressor->Size(), &decompressor),
                ZX_OK);
      break;
    }
    default:
      ASSERT_TRUE(false);
  }
  DecompressionHelper(decompressor.get(), &seed, compressor->Data(), compressor->Size(),
                      input.get(), size);
}
void RunCompressDecompressTest ( CompressionAlgorithm algorithm , DataType data_type , size_t size , size_t step ) { ASSERT_LE ( step , size ) << " " ; unsigned seed = :: testing :: UnitTest :: GetInstance ( ) -> random_seed ( ) ; std :: unique_ptr < char [ ] > input ( GenerateInput ( data_type , & seed , size ) ) ; std :: optional < BlobCompressor > compressor ; CompressionHelper ( algorithm , input . get ( ) , size , step , & compressor ) ; ASSERT_TRUE ( compressor ) ; std :: unique_ptr < SeekableDecompressor > decompressor ; switch ( algorithm ) { case CompressionAlgorithm :: CHUNKED : { ASSERT_EQ ( SeekableChunkedDecompressor :: CreateDecompressor ( compressor -> Data ( ) , compressor -> Size ( ) , compressor -> Size ( ) , & decompressor ) , ZX_OK ) ; break ; } default : ASSERT_TRUE ( false ) ; } DecompressionHelper ( decompressor . get ( ) , & seed , compressor -> Data ( ) , compressor -> Size ( ) , input . get ( ) , size ) ; }
Tests a contained case of compression and decompression.
Tests a contained case of compression and decompression .
// Generate input. // Compress a buffer. // Decompress the buffer.