10 #include <gtest/gtest.h> 16 #include <test_mrpt_common.h> 24 const unsigned int random_seed = 123U;
26 mersenne_engine.
seed(random_seed);
30 auto gen = [&mersenne_engine]() {
32 return mersenne_engine() % 4;
39 TEST(CFileGZStreams, readwriteTmpFileCompressed)
41 std::vector<uint8_t> tst_data;
45 for (
int compress_level = 1; compress_level <= 9; compress_level++)
53 const bool open_ok = fil_out.
open(fil, compress_level);
62 const bool open_ok = fil_in.
open(fil);
69 EXPECT_TRUE(std::equal(
75 TEST(CFileGZStreams, compareWithTestGZFiles)
77 std::vector<uint8_t> tst_data;
81 for (
int compress_level = 1; compress_level <= 9; compress_level++)
84 "%s/tests/gz-tests/%i.gz", mrpt::UNITTEST_BASEDIR.c_str(),
89 GTEST_FAIL() <<
"ERROR: test due to missing file: " << fil <<
"\n";
93 const bool open_ok = fil_in.
open(fil);
100 EXPECT_TRUE(std::equal(
102 <<
" compress_level:" << compress_level;
bool open(const std::string &fileName, int compress_level=1, mrpt::optional_ref< std::string > error_msg=std::nullopt)
Open a file for write, choosing the compression level.
void generate_test_data(std::vector< uint8_t > &tst_data)
bool fileExists(const std::string &fileName)
Test if a given file (or directory) exists.
std::string getTempFileName()
Returns the name of a proposed temporary file name.
Portable MT19937 random generator, C++11 UniformRandomBitGenerator compliant.
TEST(CFileGZStreams, readwriteTmpFileCompressed)
GLsizei const GLchar ** string
const_iterator begin() const
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
size_t Write(const void *Buffer, size_t Count) override
Introduces a pure virtual method responsible for writing to the stream.
std::string std::string to_string(T v)
Just like std::to_string(), but with an overloaded version for std::string arguments.
Saves data to a file and transparently compress the data using the given compression level...
void seed(const uint32_t seed)
const size_t tst_data_len