A class to manage testing and record success and failure. More...
#include <test_mgr.h>
Definition at line 50 of file test_mgr.h.
Public Member Functions | |
test_mgr (bool success_l=true, std::string last_fail_l="", int ntests_l=0, int output_level_l=1) | |
Create a test_mgr object. | |
bool | report () const |
Provide a report of all tests so far. More... | |
Individual get and set methods | |
bool | get_success () const |
Return true if all tests have succeeded. | |
std::string | get_last_fail () const |
Return the last failure description. | |
int | get_output_level () const |
Return the output level. | |
std::string | get_last_fail () |
Returns the description of the last test that failed. | |
void | set_output_level (int l) |
Set the output level. More... | |
int | get_ntests () const |
Return the number of tests performed so far. | |
Main testing methods | |
template<class data_t = double> | |
bool | test_abs (data_t result, data_t expected, data_t abs_error, std::string description) |
Test for ![]() | |
template<class data_t = double> | |
bool | test_rel (data_t result, data_t expected, data_t rel_error, std::string description) |
Test for ![]() | |
template<class data_t = double> | |
bool | test_abs_boost (data_t result, data_t expected, data_t abs_error, std::string description) |
Testing functions for boost::multiprecision numbers. More... | |
template<class data_t = double> | |
bool | test_rel_boost (data_t result, data_t expected, data_t rel_error, std::string description) |
Testing functions for boost::multiprecision numbers. More... | |
template<class data_t > | |
bool | test_fact (data_t result, data_t expected, data_t factor, std::string description) |
Test for ![]() | |
bool | test_str (std::string result, std::string expected, std::string description) |
Test for ![]() | |
bool | test_gen (bool value, std::string description) |
Test for ![]() | |
Vector testing methods | |
template<class vec_t , class vec2_t , class data_t > | |
bool | test_rel_vec (int nv, const vec_t &result, const vec2_t &expected, data_t rel_error, std::string description) |
Test for ![]() | |
template<class vec_t , class vec2_t , class data_t > | |
bool | test_abs_vec (int nv, const vec_t &result, const vec2_t &expected, data_t abs_error, std::string description) |
Test for ![]() | |
template<class vec_t , class vec2_t , class data_t > | |
bool | test_fact_vec (int nv, const vec_t &result, const vec2_t &expected, data_t factor, std::string description) |
Test for ![]() | |
template<class vec_t > | |
bool | test_gen_vec (int nv, const vec_t &result, const vec_t &expected, std::string description) |
Test for equality of a generic array. | |
Protected Member Functions | |
void | process_test (bool ret, std::string d2, std::string description) |
A helper function for processing tests. | |
Protected Attributes | |
int | ntests |
The number of tests performed. | |
int | output_level |
The output level. | |
bool | success |
True if all tests have passed. | |
std::string | last_fail |
The description of the last failed test. | |
Matrix testing methods | |
template<class mat_t , class mat2_t , class data_t > | |
bool | test_rel_mat (int nr, int nc, const mat_t &result, const mat2_t &expected, data_t rel_error, std::string description) |
Test for ![]() | |
template<class mat_t , class mat2_t , class data_t > | |
bool | test_rel_nonzero_mat (int nr, int nc, const mat_t &result, const mat2_t &expected, data_t error, data_t zero_tol, std::string description) |
Test for ![]() | |
template<class mat_t , class mat2_t , class data_t > | |
bool | test_abs_mat (int nr, int nc, const mat_t &result, const mat2_t &expected, data_t abs_error, std::string description) |
Test for ![]() | |
template<class vec_t , class data_t > | |
bool | test_rel_nonzero_table (const table_units< vec_t > &result, const table_units< vec_t > &expected, data_t error, data_t zero_tol, std::string description) |
Compare entries in expected to see if they match those in table result . More... | |
const friend test_mgr | operator+ (const test_mgr &left, const test_mgr &right) |
Add two test_mgr objects (if either failed, the sum fails) More... | |
bool o2scl::test_mgr::report | ( | ) | const |
This function reports on whether or not all tests have passed according to the current output level. It returns true if all tests have passed and false if at least one test failed.
|
inline |
Possible values:
Definition at line 119 of file test_mgr.h.
|
inline |
This function is similar to test_abs(), but replaces isnan
and related functions with boost versions from boost::multiprecision::number
.
Definition at line 209 of file test_mgr.h.
|
inline |
This function is similar to test_abs(), but replaces isnan
and related functions with boost versions from boost::multiprecision::number
.
Definition at line 251 of file test_mgr.h.
|
inline |
If the numbers in the expected
table have an absolute value less than zero_tol
, then the absolute value of the difference is used for the comparison. Otherwise, the absolute value of the relative difference is used to make the comparison.
Definition at line 578 of file test_mgr.h.
The output level is set to the maximum value of left and right operand and the number of tests is set equal to the sum. The last failure descriptions of both operands are appended with a operator+()
prefix, or blank if there were no failures from either.
Documentation generated with Doxygen. Provided under the
GNU Free Documentation License (see License Information).