proxygen
folly::io::test::CompressionVarintTest Class Reference
Inheritance diagram for folly::io::test::CompressionVarintTest:

Protected Member Functions

void SetUp () override
 
void runSimpleTest (const DataHolder &dh)
 

Protected Attributes

uint64_t uncompressedLength_
 
std::unique_ptr< Codeccodec_
 

Detailed Description

Definition at line 310 of file CompressionTest.cpp.

Member Function Documentation

void folly::io::test::CompressionVarintTest::runSimpleTest ( const DataHolder dh)
protected

Definition at line 332 of file CompressionTest.cpp.

References codec_, folly::IOBuf::copyBuffer(), folly::io::test::DataHolder::data(), EXPECT_EQ, folly::io::test::DataHolder::hash(), folly::io::test::hashIOBuf(), max, min, folly::gen::move, folly::io::test::oneBasedMsbPos(), folly::Random::rand64(), uint64_t, and folly::IOBuf::wrapBuffer().

332  {
333  auto original = IOBuf::wrapBuffer(dh.data(uncompressedLength_));
334  auto compressed = codec_->compress(original.get());
335  auto breakPoint =
336  1UL +
339  auto tinyBuf = IOBuf::copyBuffer(
340  compressed->data(), std::min(compressed->length(), breakPoint));
341  compressed->trimStart(breakPoint);
342  tinyBuf->prependChain(std::move(compressed));
343  compressed = std::move(tinyBuf);
344 
345  auto uncompressed = codec_->uncompress(compressed.get());
346 
347  EXPECT_EQ(uncompressedLength_, uncompressed->computeChainDataLength());
348  EXPECT_EQ(dh.hash(uncompressedLength_), hashIOBuf(uncompressed.get()));
349 }
LogLevel max
Definition: LogLevel.cpp:31
static std::unique_ptr< IOBuf > wrapBuffer(const void *buf, std::size_t capacity)
Definition: IOBuf.cpp:353
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
LogLevel min
Definition: LogLevel.cpp:30
uint64_t hashIOBuf(const IOBuf *buf)
static uint64_t rand64()
Definition: Random.h:263
static std::unique_ptr< IOBuf > copyBuffer(const void *buf, std::size_t size, std::size_t headroom=0, std::size_t minTailroom=0)
Definition: IOBuf.h:1587
uint64_t oneBasedMsbPos(uint64_t number)
void folly::io::test::CompressionVarintTest::SetUp ( )
inlineoverrideprotected

Definition at line 313 of file CompressionTest.cpp.

References codec_, folly::io::getCodec(), and uint64_t.

313  {
314  auto tup = GetParam();
315  uncompressedLength_ = uint64_t(1) << std::get<0>(tup);
316  codec_ = getCodec(std::get<1>(tup));
317  }
std::unique_ptr< Codec > getCodec(CodecType type, int level)

Member Data Documentation

std::unique_ptr<Codec> folly::io::test::CompressionVarintTest::codec_
protected

Definition at line 322 of file CompressionTest.cpp.

uint64_t folly::io::test::CompressionVarintTest::uncompressedLength_
protected

Definition at line 321 of file CompressionTest.cpp.


The documentation for this class was generated from the following file: