stc
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
stc::testutil::CaptureStream< T, typename > Class Template Reference

#include <CaptureStream.hpp>

Public Member Functions

 CaptureStream (T &stream)
 
 ~CaptureStream ()
 
void restore ()
 
void reset ()
 

Public Attributes

std::stringstream content
 

Detailed Description

template<class T, typename = std::enable_if_t<std::is_base_of_v<std::ios_base, T>>>
class stc::testutil::CaptureStream< T, typename >

Utility class for redirecting streams. This is primarily meant for redirecting std::cout, std::cerr, and std::cin, but should work with any standard stream.

This is very useful if you want to test code that takes standard input that you want to simulate entering, or if you want to test the stdout produced in some test.

This function is in the extra module stc::testutil, and should never be used outside tests. It may still work there, but it's not designed to be robust enough to handle real-world use.

Constructor & Destructor Documentation

◆ CaptureStream()

template<class T , typename = std::enable_if_t<std::is_base_of_v<std::ios_base, T>>>
stc::testutil::CaptureStream< T, typename >::CaptureStream ( T &  stream)
inline

◆ ~CaptureStream()

template<class T , typename = std::enable_if_t<std::is_base_of_v<std::ios_base, T>>>
stc::testutil::CaptureStream< T, typename >::~CaptureStream ( )
inline

Member Function Documentation

◆ reset()

template<class T , typename = std::enable_if_t<std::is_base_of_v<std::ios_base, T>>>
void stc::testutil::CaptureStream< T, typename >::reset ( )
inline

Clears the content buffer. Useful if you ever run into EOL, and then want to add more content afterwards.

◆ restore()

template<class T , typename = std::enable_if_t<std::is_base_of_v<std::ios_base, T>>>
void stc::testutil::CaptureStream< T, typename >::restore ( )
inline

Member Data Documentation

◆ content

template<class T , typename = std::enable_if_t<std::is_base_of_v<std::ios_base, T>>>
std::stringstream stc::testutil::CaptureStream< T, typename >::content

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