Value-to-string conversion.
When displaying the data required to understand a test's failures, TTS may need to print out value of various types. as_string provides a centralized way to perform such a task by handling most common types including:
#define TTS_MAIN
#include <tts/tts.hpp>
namespace space
{
struct some_type { int i; };
struct some_other_type { int i; };
std::ostream& operator<<(std::ostream& os, some_other_type const& s)
{
return os << "[[" << s.i << "]]";
}
std::string to_string( some_type
const& s ) {
return "some_type[" +
tts::as_string(s.i) +
"]"; }
}
TTS_CASE(
"Check display of type with specific to_string" )
{
};
#define TTS_CASE(ID)
Introduces a new test scenario and registers it into the current test driver.
Definition: case.hpp:147
std::string as_string(T const &e)
Value-to-string conversion.
Definition: as_string.hpp:61
#define TTS_EQUAL(LHS, RHS,...)
Performs equality comparison between two expressions.
Definition: relation.hpp:90