Main MRPT website > C++ reference for MRPT 1.9.9
zip_unittest.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include <mrpt/compress.h>
11 #include <mrpt/math/ops_vectors.h>
12 #include <gtest/gtest.h>
13 
14 using namespace mrpt;
15 using namespace mrpt::utils;
16 using namespace mrpt::math;
17 using namespace std;
18 
19 TEST(Compress, DataBlockGZ)
20 {
21  const size_t N = 20000;
22 
23  // Create a random "input" data vector
24  vector_byte in_data(N);
25  for (size_t i = 0; i < N; i++)
26  in_data[i] = static_cast<uint8_t>(
27  i); // We need low entropy for compression to have something to do!
28 
29  // Compress it:
31 
32  // cout << "[test_compress_main] Invoking compress_gz_data_block" << endl;
33 
35  GTEST_FAIL() << "Error in compress_gz_data_block\n";
36 
37  // cout << "Compressed gz-data: " << N << " -> " << compress_data.size() <<
38  //" bytes." << endl;
39 
40  vector_byte recovered_data;
42  compress_data, recovered_data))
43  GTEST_FAIL() << "Error in decompress_gz_data_block\n";
44 
45  // cout << "Decompressed data: " << recovered_data.size() << " bytes." <<
46  // endl;
47 
48  uint8_t err = mrpt::math::sum(recovered_data - in_data);
49 
50  EXPECT_EQ(0, err)
51  << "Differences after compressing & decompressing with GZ\n";
52 }
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
compress_data(j_compress_ptr cinfo, JSAMPIMAGE input_buf)
Definition: jccoefct.cpp:142
std::vector< uint8_t > vector_byte
Definition: types_simple.h:27
STL namespace.
bool decompress_gz_data_block(const vector_byte &in_gz_data, vector_byte &out_data)
Decompress an array of bytes storing a gz-compressed stream of data into a memory buffer...
Definition: zip.cpp:378
unsigned char uint8_t
Definition: rptypes.h:41
This base provides a set of functions for maths stuff.
Definition: CArrayNumeric.h:19
CONTAINER::Scalar sum(const CONTAINER &v)
Computes the sum of all the elements.
TEST(Compress, DataBlockGZ)
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
bool compress_gz_data_block(const vector_byte &in_data, vector_byte &out_gz_data, const int compress_level=9)
Compress a memory buffer in gz-file format and return it as a block a memory.
Definition: zip.cpp:272



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019