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);
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);
102 <<
" compress_level:" << compress_level;
std::string to_string(T v)
Just like std::to_string(), but with an overloaded version for std::string arguments.
EXPECT_TRUE(mrpt::system::fileExists(ini_fil))
std::string std::string format(std::string_view fmt, ARGS &&... args)
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)
const_iterator end() const
const_iterator begin() const
EXPECT_EQ(out.image_pair_was_used.size(), NUM_IMGS)
size_t Write(const void *Buffer, size_t Count) override
Introduces a pure virtual method responsible for writing to the stream.
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