Main MRPT website > C++ reference for MRPT 1.5.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 
20 TEST(Compress, DataBlockGZ)
21 {
22  const size_t N = 20000;
23 
24  // Create a random "input" data vector
25  vector_byte in_data(N);
26  for (size_t i=0;i<N;i++)
27  in_data[i] = static_cast<uint8_t>(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() << " bytes." << endl;
38 
39  vector_byte recovered_data;
41  GTEST_FAIL() << "Error in decompress_gz_data_block\n";
42 
43 // cout << "Decompressed data: " << recovered_data.size() << " bytes." << endl;
44 
45  uint8_t err = mrpt::math::sum( recovered_data - in_data );
46 
47  EXPECT_EQ(0, err ) << "Differences after compressing & decompressing with GZ\n";
48 }
49 
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
Definition: zip.h:16
compress_data(j_compress_ptr cinfo, JSAMPIMAGE input_buf)
Definition: jccoefct.cpp:140
std::vector< uint8_t > vector_byte
Definition: types_simple.h:26
STL namespace.
bool BASE_IMPEXP 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:435
unsigned char uint8_t
Definition: rptypes.h:43
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 BASE_IMPEXP 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:325



Page generated by Doxygen 1.8.14 for MRPT 1.5.9 Git: 690a4699f Wed Apr 15 19:29:53 2020 +0200 at miƩ abr 15 19:30:12 CEST 2020