C++ Utilities 5.26.1
Useful C++ classes and routines such as argument parser, IO and conversion utilities
|
#include "../application/argumentparser.h"
#include "../chrono/format.h"
#include "../misc/traits.h"
#include <iomanip>
#include <optional>
#include <ostream>
#include <string>
Go to the source code of this file.
Classes | |
class | CppUtilities::TestApplication |
The TestApplication class simplifies writing test applications that require opening test files. More... | |
class | CppUtilities::AsHexNumber< T > |
The AsHexNumber class allows printing values asserted with cppunit (or similar test framework) using the hex system in the error case. More... | |
Namespaces | |
namespace | CppUtilities |
Contains all utilities provides by the c++utilities library. | |
namespace | CppUtilities::Literals |
Contains literals to ease asserting with CPPUNIT_ASSERT_EQUAL. | |
Macros | |
#define | TESTUTILS_ASSERT_EXEC(args) |
Asserts successful execution of the application with the specified CLI args. | |
#define | TESTUTILS_ASSERT_EXEC_EXIT_STATUS(args, expectedExitStatus) |
Asserts the execution of the application with the specified CLI args and the specified expectedExitStatus. | |
#define | TESTUTILS_ASSERT_LIKE_FLAGS(message, expectedRegex, regexFlags, actualString) |
Asserts whether the specified string matches the specified regex. | |
#define | TESTUTILS_ASSERT_LIKE(message, expectedRegex, actualString) |
Asserts whether the specified string matches the specified regex. | |
Enumerations | |
enum class | CppUtilities::WorkingCopyMode { CppUtilities::CreateCopy , CppUtilities::NoCopy , CppUtilities::Cleanup } |
The WorkingCopyMode enum specifies additional options to influence behavior of TestApplication::workingCopyPath(). More... | |
Functions | |
CPP_UTILITIES_EXPORT std::string | CppUtilities::testFilePath (const std::string &relativeTestFilePath) |
Convenience function to invoke TestApplication::testFilePath(). | |
CPP_UTILITIES_EXPORT std::string | CppUtilities::testDirPath (const std::string &relativeTestDirPath) |
Convenience function to invoke TestApplication::testDirPath(). | |
CPP_UTILITIES_EXPORT std::string | CppUtilities::workingCopyPath (const std::string &relativeTestFilePath, WorkingCopyMode mode=WorkingCopyMode::CreateCopy) |
Convenience function to invoke TestApplication::workingCopyPath(). | |
CPP_UTILITIES_EXPORT std::string | CppUtilities::workingCopyPathAs (const std::string &relativeTestFilePath, const std::string &relativeWorkingCopyPath, WorkingCopyMode mode=WorkingCopyMode::CreateCopy) |
Convenience function to invoke TestApplication::workingCopyPathAs(). | |
template<typename Optional , Traits::EnableIf< Traits::IsSpecializationOf< Optional, std::optional > > * = nullptr> | |
std::ostream & | CppUtilities::operator<< (std::ostream &out, const Optional &optional) |
Allows printing std::optional objects so those can be asserted using CPPUNIT_ASSERT_EQUAL. | |
template<typename T > | |
bool | CppUtilities::operator== (const AsHexNumber< T > &lhs, const AsHexNumber< T > &rhs) |
Provides operator == required by CPPUNIT_ASSERT_EQUAL. | |
template<typename T > | |
std::ostream & | CppUtilities::operator<< (std::ostream &out, const AsHexNumber< T > &value) |
Provides the actual formatting of the output for AsHexNumber class. | |
template<typename T > | |
AsHexNumber< T > | CppUtilities::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). | |
template<typename T , Traits::EnableIf< std::is_integral< T > > * = nullptr> | |
AsHexNumber< T > | CppUtilities::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). | |
template<typename T , Traits::DisableIf< std::is_integral< T > > * = nullptr> | |
const T & | CppUtilities::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). | |
template<typename Pair , CppUtilities::Traits::EnableIf< CppUtilities::Traits::IsSpecializationOf< Pair, std::pair > > * = nullptr> | |
std::ostream & | CppUtilities::operator<< (std::ostream &out, const Pair &pair) |
Allows printing pairs so key/values of maps/hashes can be asserted using CPPUNIT_ASSERT_EQUAL. | |
template<typename Iteratable , Traits::EnableIf< Traits::IsIteratable< Iteratable >, Traits::Not< Traits::IsString< Iteratable > > > * = nullptr> | |
std::ostream & | CppUtilities::operator<< (std::ostream &out, const Iteratable &iteratable) |
Allows printing iteratable objects so those can be asserted using CPPUNIT_ASSERT_EQUAL. | |
constexpr std::size_t | CppUtilities::Literals::operator""_st (unsigned long long size) |
Literal for std::size_t to ease asserting std::size_t with CPPUNIT_ASSERT_EQUAL. | |
constexpr std::uint64_t | CppUtilities::Literals::operator""_uint64 (unsigned long long size) |
Literal for uint64 to ease asserting uint64 with CPPUNIT_ASSERT_EQUAL. | |
constexpr std::int64_t | CppUtilities::Literals::operator""_int64 (unsigned long long size) |
Literal for int64 to ease asserting int64 with CPPUNIT_ASSERT_EQUAL. | |
#define TESTUTILS_ASSERT_EXEC | ( | args | ) |
Asserts successful execution of the application with the specified CLI args.
The application is executed via TestApplication::execApp(). Output is stored in the std::string variables stdout and stderr.
Definition at line 291 of file testutils.h.
#define TESTUTILS_ASSERT_EXEC_EXIT_STATUS | ( | args, | |
expectedExitStatus ) |
Asserts the execution of the application with the specified CLI args and the specified expectedExitStatus.
The application is executed via TestApplication::execApp(). Output is stored in the std::string variables stdout and stderr.
Definition at line 311 of file testutils.h.
#define TESTUTILS_ASSERT_LIKE | ( | message, | |
expectedRegex, | |||
actualString ) |
Asserts whether the specified string matches the specified regex.
Definition at line 338 of file testutils.h.
#define TESTUTILS_ASSERT_LIKE_FLAGS | ( | message, | |
expectedRegex, | |||
regexFlags, | |||
actualString ) |
Asserts whether the specified string matches the specified regex.
Definition at line 328 of file testutils.h.