pianod2
multisource multiuser scriptable networked music player
Public Member Functions | Static Public Member Functions | Private Attributes | Static Private Attributes | List of all members
Test::FailureCounter Class Reference

#include <failurecounter.h>

Public Member Functions

 FailureCounter (const std::string &n)
 Start a new group of tests. More...
 
 ~FailureCounter ()
 On destruction, report summary of test results. More...
 
void subtest (const std::string &n)
 Provide a name for a group of subtests. More...
 
void skip (const std::string &reason)
 Record that a test was skipped. More...
 
void warning (const std::string &reason)
 Record that a test generated a warning. More...
 
bool succeed (const std::string &success)
 Record and report a successful test. More...
 
bool fail (const std::string &failure, const std::string &detail="")
 Record and report a failed test. More...
 
bool result (bool result, const std::string &test, const std::string &detail="")
 
template<typename T >
bool equal (const std::string &test_name, const T &expect, const T &actual)
 
bool equal (const std::string &test_name, const char *expect, const char *actual)
 
bool equal (const std::string &test_name, const char *expect, const std::string &actual)
 
bool equal (const std::string &test_name, long expect, const long actual)
 
bool isTrue (const std::string &test_name, bool actual)
 
bool isFalse (const std::string &test_name, bool actual)
 
bool signEqual (const std::string &test_name, long expect, long actual)
 
template<typename T >
bool equal (const T &expect, const T &actual)
 
bool equal (const char *expect, const char *actual)
 
bool equal (const char *expect, const std::string &actual)
 
bool equal (long expect, const long actual)
 
bool isTrue (bool actual)
 
bool isFalse (bool actual)
 
bool sameException (const std::string &trigger, const std::exception &expect, const std::exception &actual, bool compare_text=false)
 
bool sameExceptionAndText (const std::string &trigger, const std::exception &expect, const std::exception &actual)
 
int errorCount ()
 

Static Public Member Functions

static void initialize_colors ()
 If ncurses is available, initializes terminal color escape sequences. More...
 
static int grandTotalErrors ()
 
static void summary ()
 

Private Attributes

std::string name
 
std::string subtest_name
 
int tests {0}
 
int passes {0}
 
int errors {0}
 
int warnings {0}
 
int skips {0}
 
int check_number {0}
 

Static Private Attributes

static int grand_total_tests
 
static int grand_total_passes
 
static int grand_total_errors
 
static int grand_total_warnings
 
static int grand_total_skips
 
static std::string green
 
static std::string red
 
static std::string yellow
 
static std::string bold
 
static std::string normal
 

Constructor & Destructor Documentation

◆ FailureCounter()

Test::FailureCounter::FailureCounter ( const std::string &  n)
inline

Start a new group of tests.

Parameters
nThe name of the test group

◆ ~FailureCounter()

Test::FailureCounter::~FailureCounter ( )
inline

On destruction, report summary of test results.

Member Function Documentation

◆ equal() [1/8]

bool Test::FailureCounter::equal ( const char *  expect,
const char *  actual 
)
inline
Here is the call graph for this function:

◆ equal() [2/8]

bool Test::FailureCounter::equal ( const char *  expect,
const std::string &  actual 
)
inline
Here is the call graph for this function:

◆ equal() [3/8]

bool Test::FailureCounter::equal ( const std::string &  test_name,
const char *  expect,
const char *  actual 
)
inline
Here is the call graph for this function:

◆ equal() [4/8]

bool Test::FailureCounter::equal ( const std::string &  test_name,
const char *  expect,
const std::string &  actual 
)
inline
Here is the call graph for this function:

◆ equal() [5/8]

template<typename T >
bool Test::FailureCounter::equal ( const std::string &  test_name,
const T &  expect,
const T &  actual 
)
inline
Here is the call graph for this function:
Here is the caller graph for this function:

◆ equal() [6/8]

bool Test::FailureCounter::equal ( const std::string &  test_name,
long  expect,
const long  actual 
)
inline

◆ equal() [7/8]

template<typename T >
bool Test::FailureCounter::equal ( const T &  expect,
const T &  actual 
)
inline
Here is the call graph for this function:

◆ equal() [8/8]

bool Test::FailureCounter::equal ( long  expect,
const long  actual 
)
inline

◆ errorCount()

int Test::FailureCounter::errorCount ( )
inline

◆ fail()

bool Test::FailureCounter::fail ( const std::string &  failure,
const std::string &  detail = "" 
)
inline

Record and report a failed test.

Parameters
failureThe name or reason for the failure.
detailAdditional details about the failure.
Here is the caller graph for this function:

◆ grandTotalErrors()

static int Test::FailureCounter::grandTotalErrors ( )
inlinestatic

◆ initialize_colors()

static void Test::FailureCounter::initialize_colors ( )
inlinestatic

If ncurses is available, initializes terminal color escape sequences.

Warning
Calling ncurses' setupterm function, as done by this function, interferes with GDB breakpoints. Don't enable colors if debugging.

◆ isFalse() [1/2]

bool Test::FailureCounter::isFalse ( bool  actual)
inline
Here is the call graph for this function:

◆ isFalse() [2/2]

bool Test::FailureCounter::isFalse ( const std::string &  test_name,
bool  actual 
)
inline
Here is the call graph for this function:

◆ isTrue() [1/2]

bool Test::FailureCounter::isTrue ( bool  actual)
inline
Here is the call graph for this function:

◆ isTrue() [2/2]

bool Test::FailureCounter::isTrue ( const std::string &  test_name,
bool  actual 
)
inline
Here is the call graph for this function:

◆ result()

bool Test::FailureCounter::result ( bool  result,
const std::string &  test,
const std::string &  detail = "" 
)
inline
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sameException()

bool Test::FailureCounter::sameException ( const std::string &  trigger,
const std::exception &  expect,
const std::exception &  actual,
bool  compare_text = false 
)
inline
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sameExceptionAndText()

bool Test::FailureCounter::sameExceptionAndText ( const std::string &  trigger,
const std::exception &  expect,
const std::exception &  actual 
)
inline
Here is the call graph for this function:

◆ signEqual()

bool Test::FailureCounter::signEqual ( const std::string &  test_name,
long  expect,
long  actual 
)
inline
Here is the call graph for this function:

◆ skip()

void Test::FailureCounter::skip ( const std::string &  reason)
inline

Record that a test was skipped.

Parameters
reasonThe reason for skipping.

◆ subtest()

void Test::FailureCounter::subtest ( const std::string &  n)
inline

Provide a name for a group of subtests.

Parameters
nThe subtest group name.

◆ succeed()

bool Test::FailureCounter::succeed ( const std::string &  success)
inline

Record and report a successful test.

Parameters
successName or details of the success
Here is the caller graph for this function:

◆ summary()

static void Test::FailureCounter::summary ( )
inlinestatic

◆ warning()

void Test::FailureCounter::warning ( const std::string &  reason)
inline

Record that a test generated a warning.

Parameters
reasonThe reason for the warning.

Member Data Documentation

◆ bold

std::string Test::FailureCounter::bold
staticprivate

◆ check_number

int Test::FailureCounter::check_number {0}
private

◆ errors

int Test::FailureCounter::errors {0}
private

◆ grand_total_errors

int Test::FailureCounter::grand_total_errors
staticprivate

◆ grand_total_passes

int Test::FailureCounter::grand_total_passes
staticprivate

◆ grand_total_skips

int Test::FailureCounter::grand_total_skips
staticprivate

◆ grand_total_tests

int Test::FailureCounter::grand_total_tests
staticprivate

◆ grand_total_warnings

int Test::FailureCounter::grand_total_warnings
staticprivate

◆ green

std::string Test::FailureCounter::green
staticprivate

◆ name

std::string Test::FailureCounter::name
private

◆ normal

std::string Test::FailureCounter::normal
staticprivate

◆ passes

int Test::FailureCounter::passes {0}
private

◆ red

std::string Test::FailureCounter::red
staticprivate

◆ skips

int Test::FailureCounter::skips {0}
private

◆ subtest_name

std::string Test::FailureCounter::subtest_name
private

◆ tests

int Test::FailureCounter::tests {0}
private

◆ warnings

int Test::FailureCounter::warnings {0}
private

◆ yellow

std::string Test::FailureCounter::yellow
staticprivate

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