#include <Reporter.h>
Public Methods | |
Reporter (void) | |
~Reporter (void) | |
bool | report (const bool &with_printout) const |
Report with or without verbose printout. Returns true if all tests passed OK. More... | |
void | setTitle (const std::string &) |
Set the title of the set of tests. More... | |
void | clear (void) |
Discard all currently stored tests and start again. More... | |
void | keep (const std::string &, const bool &ex, const bool &ob) |
Store the name of a test, its expected result and the actual result. More... | |
void | keep (const std::string &, const int &ex, const int &ob) |
Store the name of a test, its expected result and the actual result. More... | |
void | keep (const std::string &, const float &ex, const float &ob) |
Store the name of a test, its expected result and the actual result. More... | |
void | keep (const std::string &, const double &ex, const double &ob) |
Store the name of a test, its expected result and the actual result. More... | |
void | keep (const std::string &, const char *ex, const char *ob) |
Store the name of a test, its expected result and the actual result. More... | |
void | keep (const std::string &, const std::string &ex, const std::string &ob) |
Store the name of a test, its expected result and the actual result. More... | |
Private Types | |
typedef std::map< int, Test >::const_iterator | TestIt |
Private Methods | |
void | print (const std::string &, const std::string &, const std::string &, const int &=-1) const |
bool | veryClose (const float &, const float &) const |
Returns true if two floats are very similar. More... | |
bool | veryClose (const double &, const double &) const |
Returns true if two doubles are very similar. More... | |
std::string | asString (const int &) const |
std::string | asString (const float &) const |
std::string | asString (const double &a) const |
void | reg (const std::string &name, const std::string &ex, const std::string &ob, const bool &res) |
void | printHeader (void) const |
Private Attributes | |
std::string | title |
std::map< int, Test > | testList |
unsigned int | widest_title |
unsigned int | widest_ob |
unsigned int | widest_ex |
int | nt |
Static Private Attributes | |
const float | F_PREC = 1e-5 |
const double | D_PREC = 1e-9 |
const std::string | H_TITLE = "Test description" |
const std::string | H_EXP = "Expected" |
const std::string | H_OBS = "Observed" |
const std::string | H_FLAG = "Pass?" |
Reporter r; r.setTitle("tests of my mathlib"); float pi = 3.14159, e = 2.71828; float tpi = calculatePi(), te = calculateE(); r.keep("a test of calcPi",pi,tpi); r.keep("another test",e,te); ... bool printout = false; bool passed = r.report(printout); if (passed) cout << "all as expected" << endl;
Useful for conducting many tests in the same function.
Author M.Sang (c) CERN, Geneva
Definition at line 40 of file Reporter.h.
|
Definition at line 104 of file Reporter.h. Referenced by report. |
|
Definition at line 64 of file Reporter.cpp. References clear, nt, widest_ex, widest_ob, and widest_title. |
|
Definition at line 76 of file Reporter.cpp. References clear. |
|
Definition at line 235 of file Reporter.cpp. |
|
Definition at line 221 of file Reporter.cpp. |
|
Definition at line 207 of file Reporter.cpp. Referenced by keep. |
|
Definition at line 84 of file Reporter.cpp. References H_EXP, H_OBS, H_TITLE, nt, testList, widest_ex, widest_ob, and widest_title. |
|
Definition at line 170 of file Reporter.cpp. References reg. |
|
Definition at line 148 of file Reporter.cpp. References reg. |
|
Definition at line 159 of file Reporter.cpp. |
|
Definition at line 137 of file Reporter.cpp. |
|
Definition at line 126 of file Reporter.cpp. |
|
Definition at line 179 of file Reporter.cpp. |
|
Definition at line 249 of file Reporter.cpp. References H_FLAG, widest_ex, widest_ob, and widest_title. Referenced by printHeader, and report. |
|
Definition at line 263 of file Reporter.cpp. References print, title, widest_ex, widest_ob, and widest_title. Referenced by report. |
|
Definition at line 279 of file Reporter.cpp. References nt, testList, widest_ex, widest_ob, and widest_title. Referenced by keep. |
|
Definition at line 190 of file Reporter.cpp. References print, printHeader, TestIt, and testList. |
|
Definition at line 96 of file Reporter.cpp. References title. |
|
Definition at line 115 of file Reporter.cpp. References D_PREC. |
|
Definition at line 104 of file Reporter.cpp. References F_PREC. Referenced by keep. |
|
Definition at line 30 of file Reporter.cpp. Referenced by veryClose. |
|
Definition at line 29 of file Reporter.cpp. Referenced by veryClose. |
|
Definition at line 32 of file Reporter.cpp. Referenced by clear. |
|
Definition at line 34 of file Reporter.cpp. Referenced by print. |
|
Definition at line 33 of file Reporter.cpp. Referenced by clear. |
|
Definition at line 31 of file Reporter.cpp. Referenced by clear. |
|
Definition at line 108 of file Reporter.h. |
|
Definition at line 103 of file Reporter.h. |
|
Definition at line 102 of file Reporter.h. Referenced by printHeader, and setTitle. |
|
Definition at line 107 of file Reporter.h. Referenced by clear, print, printHeader, reg, and Reporter. |
|
Definition at line 106 of file Reporter.h. Referenced by clear, print, printHeader, reg, and Reporter. |
|
Definition at line 105 of file Reporter.h. Referenced by clear, print, printHeader, reg, and Reporter. |