C++ Utilities  4.15.0
Useful C++ classes and routines such as argument parser, IO and conversion utilities
Namespaces | Classes | Enumerations | Functions
TestUtilities Namespace Reference

Contains classes and functions utilizing creating of test applications. More...

Namespaces

 Literals
 Contains literals to ease asserting with CPPUNIT_ASSERT_EQUAL.
 

Classes

class  AsHexNumber
 The AsHexNumber class allows printing values asserted with cppunit (or similar test framework) using the hex system in the error case. More...
 
class  OutputCheck
 The StandardOutputCheck class asserts whether the (standard) output written in the enclosing code block matches the expected output. More...
 
class  TestApplication
 The TestApplication class simplifies writing test applications that require opening test files. More...
 

Enumerations

enum  WorkingCopyMode { WorkingCopyMode::CreateCopy, WorkingCopyMode::NoCopy }
 The WorkingCopyMode enum specifies additional options to influence behavior of TestApplication::workingCopyPathMode(). More...
 

Functions

CPP_UTILITIES_EXPORT std::string testFilePath (const std::string &name)
 Convenience function which returns the full path of the test file with the specified name. More...
 
template<typename T >
bool operator== (const AsHexNumber< T > &lhs, const AsHexNumber< T > &rhs)
 Provides operator == required by CPPUNIT_ASSERT_EQUAL. More...
 
template<typename T >
std::ostream & operator<< (std::ostream &out, const AsHexNumber< T > &value)
 Provides the actual formatting of the output for AsHexNumber class. More...
 
template<typename T >
AsHexNumber< T > asHexNumber (const T &value)
 Wraps a value to be printed using the hex system in the error case when asserted with cppunit (or similar test framework). More...
 
template<typename T , Traits::EnableIf< std::is_integral< T >> * = nullptr>
AsHexNumber< T > integralsAsHexNumber (const T &value)
 Wraps a value to be printed using the hex system in the error case when asserted with cppunit (or similar test framework). More...
 
template<typename T , Traits::DisableIf< std::is_integral< T >> * = nullptr>
const T & integralsAsHexNumber (const T &value)
 Wraps a value to be printed using the hex system in the error case when asserted with cppunit (or similar test framework). More...
 
template<typename Pair , Traits::EnableIf< Traits::IsSpecializationOf< Pair, std::pair >> * = nullptr>
std::ostream & operator<< (std::ostream &out, const Pair &pair)
 Allows printing pairs so key/values of maps/hashes can be asserted using CPPUNIT_ASSERT_EQUAL. More...
 
template<typename Iteratable , Traits::EnableIf< Traits::IsIteratable< Iteratable >, Traits::Not< Traits::IsString< Iteratable >>> * = nullptr>
std::ostream & operator<< (std::ostream &out, const Iteratable &iteratable)
 Allows printing iteratable objects so those can be asserted using CPPUNIT_ASSERT_EQUAL. More...
 

Detailed Description

Contains classes and functions utilizing creating of test applications.

Enumeration Type Documentation

◆ WorkingCopyMode

The WorkingCopyMode enum specifies additional options to influence behavior of TestApplication::workingCopyPathMode().

Enumerator
CreateCopy 

a working copy of the test file is created

NoCopy 

only the directory for the working copy is created but not the test file itself

Definition at line 17 of file testutils.h.

Function Documentation

◆ asHexNumber()

template<typename T >
AsHexNumber<T> TestUtilities::asHexNumber ( const T &  value)

Wraps a value to be printed using the hex system in the error case when asserted with cppunit (or similar test framework).

Definition at line 179 of file testutils.h.

◆ integralsAsHexNumber() [1/2]

template<typename T , Traits::EnableIf< std::is_integral< T >> * = nullptr>
AsHexNumber<T> TestUtilities::integralsAsHexNumber ( const T &  value)

Wraps a value to be printed using the hex system in the error case when asserted with cppunit (or similar test framework).

Remarks
Only affects integral types. Values of other types are printed as usual.

Definition at line 189 of file testutils.h.

◆ integralsAsHexNumber() [2/2]

template<typename T , Traits::DisableIf< std::is_integral< T >> * = nullptr>
const T& TestUtilities::integralsAsHexNumber ( const T &  value)

Wraps a value to be printed using the hex system in the error case when asserted with cppunit (or similar test framework).

Remarks
Only affects integral types. Values of other types are printed as usual.

Definition at line 199 of file testutils.h.

◆ operator<<() [1/3]

template<typename T >
std::ostream& TestUtilities::operator<< ( std::ostream &  out,
const AsHexNumber< T > &  value 
)

Provides the actual formatting of the output for AsHexNumber class.

Definition at line 170 of file testutils.h.

◆ operator<<() [2/3]

template<typename Pair , Traits::EnableIf< Traits::IsSpecializationOf< Pair, std::pair >> * = nullptr>
std::ostream& TestUtilities::operator<< ( std::ostream &  out,
const Pair &  pair 
)
inline

Allows printing pairs so key/values of maps/hashes can be asserted using CPPUNIT_ASSERT_EQUAL.

Definition at line 228 of file testutils.h.

◆ operator<<() [3/3]

template<typename Iteratable , Traits::EnableIf< Traits::IsIteratable< Iteratable >, Traits::Not< Traits::IsString< Iteratable >>> * = nullptr>
std::ostream& TestUtilities::operator<< ( std::ostream &  out,
const Iteratable &  iteratable 
)
inline

Allows printing iteratable objects so those can be asserted using CPPUNIT_ASSERT_EQUAL.

Definition at line 237 of file testutils.h.

◆ operator==()

template<typename T >
bool TestUtilities::operator== ( const AsHexNumber< T > &  lhs,
const AsHexNumber< T > &  rhs 
)

Provides operator == required by CPPUNIT_ASSERT_EQUAL.

Definition at line 162 of file testutils.h.

◆ testFilePath()

CPP_UTILITIES_EXPORT std::string TestUtilities::testFilePath ( const std::string &  name)
inline

Convenience function which returns the full path of the test file with the specified name.

Remarks
A TestApplication must be present.
See also
TestApplication::testFilePath()

Definition at line 105 of file testutils.h.