C++ Utilities 5.26.1
Useful C++ classes and routines such as argument parser, IO and conversion utilities
Loading...
Searching...
No Matches
CppUtilities::OutputCheck Class Reference

The StandardOutputCheck class asserts whether the (standard) output written in the enclosing code block matches the expected output. More...

#include <outputcheck.h>

Public Member Functions

 OutputCheck (const std::string &expectedOutput, std::ostream &os=std::cout)
 Redirects standard output to an internal buffer.
 
 OutputCheck (std::string &&expectedOutput, std::string &&alternativeOutput, std::ostream &os=std::cout)
 Redirects standard output to an internal buffer.
 
 OutputCheck (std::function< void(const std::string &output)> &&customCheck, std::ostream &os=std::cout)
 
 ~OutputCheck () noexcept(false)
 Asserts the buffered standard output and restores the regular behaviour of std::cout.
 

Detailed Description

The StandardOutputCheck class asserts whether the (standard) output written in the enclosing code block matches the expected output.

Remarks
Does not work when compiling with GCC for Windows. At least when executing tests with WINE.

Definition at line 20 of file outputcheck.h.

Constructor & Destructor Documentation

◆ OutputCheck() [1/3]

CppUtilities::OutputCheck::OutputCheck ( const std::string & expectedOutput,
std::ostream & os = std::cout )
inline

Redirects standard output to an internal buffer.

Definition at line 39 of file outputcheck.h.

◆ OutputCheck() [2/3]

CppUtilities::OutputCheck::OutputCheck ( std::string && expectedOutput,
std::string && alternativeOutput,
std::ostream & os = std::cout )
inline

Redirects standard output to an internal buffer.

Definition at line 50 of file outputcheck.h.

◆ OutputCheck() [3/3]

CppUtilities::OutputCheck::OutputCheck ( std::function< void(const std::string &output)> && customCheck,
std::ostream & os = std::cout )

◆ ~OutputCheck()

CppUtilities::OutputCheck::~OutputCheck ( )
inline

Asserts the buffered standard output and restores the regular behaviour of std::cout.

Definition at line 73 of file outputcheck.h.


The documentation for this class was generated from the following file: