libDwm-0.9.45
Dwm::Assertions Class Reference

A container to hold all assertions. Note everything is static here. More...

#include <DwmUnitAssert.hh>

Static Public Member Functions

static bool Failed (const std::string &filename, const std::string &function, int lineNumber, const std::string &test)
 Adds a failed assertion.
 
static bool Passed (const std::string &filename, const std::string &function, int lineNumber, const std::string &test)
 Adds a passed assertion.
 
static AssertionCounter Total ()
 Returns the total passed and failed counter.
 
static std::ostream & Print (std::ostream &os, bool onlyFailed=false)
 Prints to an ostream.
 
static int PrintAndReturn ()
 Prints failed tests to cerr and successful test count to cout in a simple form that I use in unit test applications.
 
static std::ostream & PrintJson (std::ostream &os, bool onlyFailed=false)
 Prints to an ostream in JSON format.
 
static std::ostream & PrintXML (std::ostream &os, bool onlyFailed=false)
 Prints to an ostream in XML format.
 

Detailed Description

A container to hold all assertions. Note everything is static here.

Member Function Documentation

◆ Failed()

static bool Dwm::Assertions::Failed ( const std::string & filename,
const std::string & function,
int lineNumber,
const std::string & test )
static

Adds a failed assertion.

Not called directly; UnitAssert() calls this member. Always returns false.

◆ Passed()

static bool Dwm::Assertions::Passed ( const std::string & filename,
const std::string & function,
int lineNumber,
const std::string & test )
static

Adds a passed assertion.

Not called directly; UnitAssert() calls this member. Always returns true.

◆ Print()

static std::ostream & Dwm::Assertions::Print ( std::ostream & os,
bool onlyFailed = false )
static

Prints to an ostream.

If onlyFailed is true, prints only information for failed assertions.

◆ PrintAndReturn()

static int Dwm::Assertions::PrintAndReturn ( )
static

Prints failed tests to cerr and successful test count to cout in a simple form that I use in unit test applications.

Returns 0 if all unit tests passed, else returns 1. The return value can be used as the exit value of a unit test application to signal to the shell as to whether or not all unit tests passed.


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