tudocomp
– The TU Dortmund Compression Framework
tdc::test Namespace Reference

Contains helpers for the unit tests. More...

Classes

struct  CompressResult
 
class  RoundTrip
 
class  TestInput
 
class  TestOutput
 

Typedefs

using PacketIntegers = std::vector< uint64_t >
 

Functions

template<class T , class U >
void assert_eq_strings (const T &expected_, const U &actual_)
 Error diagnostic optimized for string data. More...
 
template<class T , class U >
void assert_eq_integers (const T &expected_, const U &actual_)
 Error diagnostic optimized for binary data. More...
 
template<class T , class U >
void assert_eq_hybrid_strings (const T &expected, const U &actual)
 Error diagnostic optimized for mixed binary/ascii data. More...
 
template<class T , class U >
void assert_eq_sequence (const T &expected, const U &actual)
 Error diagnostic optimized for arbitrary data. More...
 
template<class Lambda >
std::string ostream_to_string (Lambda f)
 Temporary provides a ostream to write into, and returns it as a string. More...
 
template<class Lambda >
std::vector< uint8_t > ostream_to_bytes (Lambda f)
 Temporary provides a ostream to write into, and returns it as a byte vector. More...
 
template<class F >
void roundtrip_batch (F f)
 Call the given function with a number of different strings testing common corner cases and unicode input. More...
 
template<class F >
void on_string_generators (F func, size_t n)
 
std::string test_file_path (const std::string &filename)
 
bool test_file_exists (const std::string &filename)
 
std::string read_test_file (const std::string &filename)
 
void create_test_directory ()
 
void write_test_file (const std::string &filename, string_ref text)
 
void remove_test_file (const std::string &filename)
 
std::vector< uint8_t > pack_integers (std::vector< uint64_t > ints)
 
std::string format_diff (const std::string &a, const std::string &b)
 
std::string format_diff_bin (const std::string &a, const std::string &b)
 
void assert_eq_binary (string_ref actual, PacketIntegers expected)
 
template<class T >
CompressResult< T > compress (string_ref text, const std::string &options="", const Registry< Compressor > &registry=Registry< Compressor >("compressor"))
 
template<class T >
void roundtrip_ex (string_ref original_text, string_ref expected_compressed_text, const std::string &options="", const Registry< Compressor > &registry=Registry< Compressor >("compressor"))
 
template<class T >
void roundtrip (string_ref original_text)
 
template<class T >
void roundtrip_binary (string_ref original_text, const std::vector< uint64_t > &expected_compressed_text_packed_ints={}, const std::string &options="", const Registry< Compressor > &registry=Registry< Compressor >("compressor"))
 
TestInput compress_input (string_ref text)
 Creates an instance of an tdc::Input to be used with Compressor::compress(). More...
 
TestInput compress_input_file (string_ref path)
 Creates an instance of an tdc::Input to be used with Compressor::compress(). More...
 
TestOutput compress_output ()
 Creates an instance of an tdc::Output to be used with Compressor::compress(). More...
 
TestInput decompress_input (string_ref text)
 Creates an instance of an tdc::Input to be used with Compressor::decompress(). More...
 
TestInput decompress_input_file (string_ref path)
 Creates an instance of an tdc::Input to be used with Compressor::decompress(). More...
 
TestOutput decompress_output ()
 Creates an instance of an tdc::Output to be used with Compressor::decompress(). More...
 
template<typename Coder >
void test_binary_out (string_ref in, std::vector< uint64_t > packed_ints_out, bool interleave=false)
 

Variables

const std::string TEST_FILE_PATH = "test_files"
 

Detailed Description

Contains helpers for the unit tests.

Typedef Documentation

◆ PacketIntegers

using tdc::test::PacketIntegers = typedef std::vector<uint64_t>

Definition at line 319 of file test/test/util.hpp.

Function Documentation

◆ assert_eq_binary()

void tdc::test::assert_eq_binary ( string_ref  actual,
PacketIntegers  expected 
)

Definition at line 320 of file test/test/util.hpp.

◆ assert_eq_hybrid_strings()

template<class T , class U >
void tdc::test::assert_eq_hybrid_strings ( const T &  expected,
const U &  actual 
)

Error diagnostic optimized for mixed binary/ascii data.

Definition at line 55 of file test/test/util.hpp.

◆ assert_eq_integers()

template<class T , class U >
void tdc::test::assert_eq_integers ( const T &  expected_,
const U &  actual_ 
)

Error diagnostic optimized for binary data.

Definition at line 46 of file test/test/util.hpp.

◆ assert_eq_sequence()

template<class T , class U >
void tdc::test::assert_eq_sequence ( const T &  expected,
const U &  actual 
)

Error diagnostic optimized for arbitrary data.

Definition at line 61 of file test/test/util.hpp.

◆ assert_eq_strings()

template<class T , class U >
void tdc::test::assert_eq_strings ( const T &  expected_,
const U &  actual_ 
)

Error diagnostic optimized for string data.

Definition at line 37 of file test/test/util.hpp.

◆ compress()

template<class T >
CompressResult<T> tdc::test::compress ( string_ref  text,
const std::string &  options = "",
const Registry< Compressor > &  registry = Registry<Compressor>("compressor") 
)
inline

Definition at line 467 of file test/test/util.hpp.

◆ compress_input()

TestInput tdc::test::compress_input ( string_ref  text)

Creates an instance of an tdc::Input to be used with Compressor::compress().

It will contain the bytes given by text.

Definition at line 537 of file test/test/util.hpp.

◆ compress_input_file()

TestInput tdc::test::compress_input_file ( string_ref  path)

Creates an instance of an tdc::Input to be used with Compressor::compress().

It will contain the bytes contained in the file at path.

Definition at line 544 of file test/test/util.hpp.

◆ compress_output()

TestOutput tdc::test::compress_output ( )

Creates an instance of an tdc::Output to be used with Compressor::compress().

The bytes output to it are accessible with the .result() accessor.

Definition at line 551 of file test/test/util.hpp.

◆ create_test_directory()

void tdc::test::create_test_directory ( )
inline

Definition at line 243 of file test/test/util.hpp.

◆ decompress_input()

TestInput tdc::test::decompress_input ( string_ref  text)

Creates an instance of an tdc::Input to be used with Compressor::decompress().

It will contain the bytes given by text.

Definition at line 558 of file test/test/util.hpp.

◆ decompress_input_file()

TestInput tdc::test::decompress_input_file ( string_ref  path)

Creates an instance of an tdc::Input to be used with Compressor::decompress().

It will contain the bytes contained in the file at path.

Definition at line 565 of file test/test/util.hpp.

◆ decompress_output()

TestOutput tdc::test::decompress_output ( )

Creates an instance of an tdc::Output to be used with Compressor::decompress().

The bytes output to it are accessible with the .result() accessor.

Definition at line 572 of file test/test/util.hpp.

◆ format_diff()

std::string tdc::test::format_diff ( const std::string &  a,
const std::string &  b 
)

Definition at line 287 of file test/test/util.hpp.

◆ format_diff_bin()

std::string tdc::test::format_diff_bin ( const std::string &  a,
const std::string &  b 
)

Definition at line 301 of file test/test/util.hpp.

◆ on_string_generators()

template<class F >
void tdc::test::on_string_generators ( func,
size_t  n 
)

Definition at line 181 of file test/test/util.hpp.

◆ ostream_to_bytes()

template<class Lambda >
std::vector<uint8_t> tdc::test::ostream_to_bytes ( Lambda  f)

Temporary provides a ostream to write into, and returns it as a byte vector.

This is useful for testing Coder::code() and Coder::decode().

Parameters
fA callable type (like for example a C++ lambda expression) that receives an std::ostream& as an argument so that its body can write into it.

Definition at line 91 of file test/test/util.hpp.

◆ ostream_to_string()

template<class Lambda >
std::string tdc::test::ostream_to_string ( Lambda  f)

Temporary provides a ostream to write into, and returns it as a string.

This is useful for testing Coder::code() and Coder::decode().

Parameters
fA callable type (like for example a C++ lambda expression) that receives an std::ostream& as an argument so that its body can write into it.

Definition at line 75 of file test/test/util.hpp.

◆ pack_integers()

std::vector<uint8_t> tdc::test::pack_integers ( std::vector< uint64_t >  ints)
inline

Definition at line 261 of file test/test/util.hpp.

◆ read_test_file()

std::string tdc::test::read_test_file ( const std::string &  filename)
inline

Definition at line 222 of file test/test/util.hpp.

◆ remove_test_file()

void tdc::test::remove_test_file ( const std::string &  filename)
inline

Definition at line 256 of file test/test/util.hpp.

◆ roundtrip()

template<class T >
void tdc::test::roundtrip ( string_ref  original_text)
inline

Definition at line 489 of file test/test/util.hpp.

◆ roundtrip_batch()

template<class F >
void tdc::test::roundtrip_batch ( f)

Call the given function with a number of different strings testing common corner cases and unicode input.

Definition at line 99 of file test/test/util.hpp.

◆ roundtrip_binary()

template<class T >
void tdc::test::roundtrip_binary ( string_ref  original_text,
const std::vector< uint64_t > &  expected_compressed_text_packed_ints = {},
const std::string &  options = "",
const Registry< Compressor > &  registry = Registry<Compressor>("compressor") 
)
inline

Definition at line 494 of file test/test/util.hpp.

◆ roundtrip_ex()

template<class T >
void tdc::test::roundtrip_ex ( string_ref  original_text,
string_ref  expected_compressed_text,
const std::string &  options = "",
const Registry< Compressor > &  registry = Registry<Compressor>("compressor") 
)
inline

Definition at line 474 of file test/test/util.hpp.

◆ test_binary_out()

template<typename Coder >
void tdc::test::test_binary_out ( string_ref  in,
std::vector< uint64_t >  packed_ints_out,
bool  interleave = false 
)

Definition at line 578 of file test/test/util.hpp.

◆ test_file_exists()

bool tdc::test::test_file_exists ( const std::string &  filename)
inline

Definition at line 215 of file test/test/util.hpp.

◆ test_file_path()

std::string tdc::test::test_file_path ( const std::string &  filename)
inline

Definition at line 211 of file test/test/util.hpp.

◆ write_test_file()

void tdc::test::write_test_file ( const std::string &  filename,
string_ref  text 
)
inline

Definition at line 247 of file test/test/util.hpp.

Variable Documentation

◆ TEST_FILE_PATH

const std::string tdc::test::TEST_FILE_PATH = "test_files"

Definition at line 209 of file test/test/util.hpp.