11 #include <gtest/gtest.h> 17 TEST(Compress, DataBlockGZ)
19 const size_t N = 20000;
22 std::vector<uint8_t> in_data(N);
23 for (
size_t i = 0; i < N; i++)
24 in_data[i] = static_cast<uint8_t>(
28 std::vector<uint8_t> compress_data;
33 GTEST_FAIL() <<
"Error in compress_gz_data_block\n";
38 std::vector<uint8_t> recovered_data;
40 GTEST_FAIL() <<
"Error in decompress_gz_data_block\n";
45 EXPECT_EQ(in_data.size(), recovered_data.size());
46 if (in_data.size() == recovered_data.size())
49 for (
size_t i = 0; i < in_data.size(); i++)
50 if (in_data[i] != recovered_data[i]) all_eq =
false;
51 EXPECT_TRUE(all_eq) <<
"Mismatch after compressing/decompressing";
TEST(Compress, DataBlockGZ)
bool compress_gz_data_block(const std::vector< uint8_t > &in_data, std::vector< uint8_t > &out_gz_data, const int compress_level=9)
Compress a memory buffer in gz-file format and return it as a block a memory.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
bool decompress_gz_data_block(const std::vector< uint8_t > &in_gz_data, std::vector< uint8_t > &out_data)
Decompress an array of bytes storing a gz-compressed stream of data into a memory buffer...