C++ Utilities  4.17.0
Useful C++ classes and routines such as argument parser, IO and conversion utilities
Classes | Macros | Functions
conversiontests.cpp File Reference
#include "../conversion/binaryconversion.h"
#include "../conversion/stringbuilder.h"
#include "../conversion/stringconversion.h"
#include "../tests/testutils.h"
#include <cppunit/TestFixture.h>
#include <cppunit/extensions/HelperMacros.h>
#include <functional>
#include <initializer_list>
#include <random>
#include <sstream>
Include dependency graph for conversiontests.cpp:

Go to the source code of this file.

Classes

class  ConversionTests
 The ConversionTests class tests classes and methods of the ConversionUtilities namespace. More...
 

Macros

#define TEST_TYPE(endianness, function)   decltype(endianness::function(m_buff))
 
#define TEST_CONVERSION(function, endianness)
 
#define TEST_BE_CONVERSION(function)   TEST_CONVERSION(function, BE)
 
#define TEST_LE_CONVERSION(function)   TEST_CONVERSION(function, LE)
 
#define TEST_CUSTOM_CONVERSION(vice, versa, endianness, min, max)
 
#define LE_STR_FOR_ENDIANNESS(name)   name##LE##String
 Selects right string for little-endian checks. More...
 
#define BE_STR_FOR_ENDIANNESS(name)   name##BE##String
 Selects right string for big-endian checks. More...
 

Functions

 CPPUNIT_TEST_SUITE_REGISTRATION (ConversionTests)
 
void assertEqual (const char *message, const byte *expectedValues, size_t expectedSize, const StringData &actualValues)
 Internally used for string encoding tests to check results. More...
 
string functionTakingString (const string &str)
 

Macro Definition Documentation

◆ BE_STR_FOR_ENDIANNESS

#define BE_STR_FOR_ENDIANNESS (   name)    name##BE##String

Selects right string for big-endian checks.

◆ LE_STR_FOR_ENDIANNESS

#define LE_STR_FOR_ENDIANNESS (   name)    name##LE##String

Selects right string for little-endian checks.

◆ TEST_BE_CONVERSION

#define TEST_BE_CONVERSION (   function)    TEST_CONVERSION(function, BE)

Definition at line 126 of file conversiontests.cpp.

◆ TEST_CONVERSION

#define TEST_CONVERSION (   function,
  endianness 
)
Value:
testConversion<TEST_TYPE(endianness, function)>("testing " #function, \
static_cast<void (*)(TEST_TYPE(endianness, function), char *)>(&endianness::getBytes), endianness::function, \
numeric_limits<TEST_TYPE(endianness, function)>::min(), numeric_limits<TEST_TYPE(endianness, function)>::max())
#define TEST_TYPE(endianness, function)
constexpr T max(T first, T second)
Returns the greatest of the given items.
Definition: math.h:29
constexpr T min(T first, T second)
Returns the smallest of the given items.
Definition: math.h:17
CPP_UTILITIES_EXPORT void getBytes(int16 value, char *outputbuffer)
Stores the specified 16-bit signed integer value at a specified position in a char array.

Definition at line 121 of file conversiontests.cpp.

◆ TEST_CUSTOM_CONVERSION

#define TEST_CUSTOM_CONVERSION (   vice,
  versa,
  endianness,
  min,
  max 
)
Value:
testConversion<TEST_TYPE(endianness, versa)>( \
"testing " #versa, static_cast<void (*)(TEST_TYPE(endianness, versa), char *)>(&endianness::vice), endianness::versa, min, max)
#define TEST_TYPE(endianness, function)
constexpr T max(T first, T second)
Returns the greatest of the given items.
Definition: math.h:29
constexpr T min(T first, T second)
Returns the smallest of the given items.
Definition: math.h:17

Definition at line 130 of file conversiontests.cpp.

◆ TEST_LE_CONVERSION

#define TEST_LE_CONVERSION (   function)    TEST_CONVERSION(function, LE)

Definition at line 128 of file conversiontests.cpp.

◆ TEST_TYPE

#define TEST_TYPE (   endianness,
  function 
)    decltype(endianness::function(m_buff))

Definition at line 119 of file conversiontests.cpp.

Function Documentation

◆ assertEqual()

void assertEqual ( const char *  message,
const byte expectedValues,
size_t  expectedSize,
const StringData actualValues 
)

Internally used for string encoding tests to check results.

Definition at line 174 of file conversiontests.cpp.

◆ CPPUNIT_TEST_SUITE_REGISTRATION()

CPPUNIT_TEST_SUITE_REGISTRATION ( ConversionTests  )

◆ functionTakingString()

string functionTakingString ( const string &  str)

Definition at line 369 of file conversiontests.cpp.