diff --git a/tap.cpp b/tap.cpp index b138f3a9..905eea1a 100644 --- a/tap.cpp +++ b/tap.cpp @@ -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 { diff --git a/tap.hpp b/tap.hpp index 7cb3fe94..4ef921f0 100644 --- a/tap.hpp +++ b/tap.hpp @@ -37,7 +37,8 @@ namespace util { namespace TAP { ~logger (); //--------------------------------------------------------------------- - void expect (bool, const std::string &msg); + template + void expect (bool, const std::string &fmt, Args&&...); template void expect (std::function, Args&&..., const std::string& msg); diff --git a/tap.ipp b/tap.ipp index 5ca1a675..7cce5cbd 100644 --- a/tap.ipp +++ b/tap.ipp @@ -27,6 +27,20 @@ #include "format.hpp" +/////////////////////////////////////////////////////////////////////////////// +template +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)...) << '\n'; + + if (!test) + m_status = EXIT_FAILURE; +} + + //----------------------------------------------------------------------------- template void