tap: move base expect method to ipp file

allows use of format strings for simple boolean expressions
This commit is contained in:
Danny Robson 2015-09-21 15:25:56 +10:00
parent 3af04b7982
commit 37526a5df3
3 changed files with 19 additions and 14 deletions

16
tap.cpp
View File

@ -22,7 +22,8 @@
using util::TAP::logger;
//-----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
logger::logger ():
m_status (EXIT_SUCCESS),
m_size (0)
@ -36,17 +37,6 @@ logger::~logger ()
}
////////////0//////////////////////////////////////////////////////////////////
void
util::TAP::logger::expect (bool test, const std::string &msg)
{
std::cout << (test ? "ok " : "not ok ") << ++m_size << " - " << msg << '\n';
if (!test)
m_status = EXIT_FAILURE;
}
///////////////////////////////////////////////////////////////////////////////
void
logger::skip (const std::string &msg)
@ -71,7 +61,7 @@ logger::noop (void)
}
//-----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
int
logger::status (void) const
{

View File

@ -37,7 +37,8 @@ namespace util { namespace TAP {
~logger ();
//---------------------------------------------------------------------
void expect (bool, const std::string &msg);
template <typename ...Args>
void expect (bool, const std::string &fmt, Args&&...);
template <typename ...Args>
void expect (std::function<bool(Args...)>, Args&&..., const std::string& msg);

14
tap.ipp
View File

@ -27,6 +27,20 @@
#include "format.hpp"
///////////////////////////////////////////////////////////////////////////////
template <typename ...Args>
void
util::TAP::logger::expect (bool test, const std::string &fmt, Args&&... args)
{
std::cout << (test ? "ok " : "not ok ") << ++m_size
<< " - "
<< util::format::render (fmt, std::forward<Args> (args)...) << '\n';
if (!test)
m_status = EXIT_FAILURE;
}
//-----------------------------------------------------------------------------
template <typename... Args>
void