tap: check the status variable is read

This commit is contained in:
Danny Robson 2018-03-20 14:50:32 +11:00
parent 0cf530c2de
commit 197160daba
2 changed files with 13 additions and 1 deletions

10
tap.cpp
View File

@ -11,10 +11,11 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
* *
* Copyright 2015-2017 Danny Robson <danny@nerdcruft.net> * Copyright 2015-2018 Danny Robson <danny@nerdcruft.net>
*/ */
#include "tap.hpp" #include "tap.hpp"
#include "debug.hpp"
#include <iostream> #include <iostream>
@ -26,6 +27,8 @@ logger::logger ():
logger (std::cout) logger (std::cout)
{ ; } { ; }
//-----------------------------------------------------------------------------
logger::logger (std::ostream &_output): logger::logger (std::ostream &_output):
m_output (_output), m_output (_output),
m_status (EXIT_SUCCESS), m_status (EXIT_SUCCESS),
@ -36,6 +39,7 @@ logger::logger (std::ostream &_output):
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
logger::~logger () logger::~logger ()
{ {
CHECK_EQ (m_reported, m_status);
std::cout << "1.." << m_size << '\n'; std::cout << "1.." << m_size << '\n';
} }
@ -68,5 +72,9 @@ logger::noop (void)
int int
logger::status (void) const logger::status (void) const
{ {
#if !defined(NDEBUG)
m_reported = m_status;
#endif
return m_status; return m_status;
} }

View File

@ -194,6 +194,10 @@ namespace util::TAP {
private: private:
#if !defined(NDEBUG)
mutable int m_reported = -1;
#endif
std::ostream &m_output; std::ostream &m_output;
int m_status; int m_status;
size_t m_size; size_t m_size;