All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes | Friends
o2scl::test_mgr Class Reference

A class to manage testing and record success and failure. More...

Detailed Description

Idea for Future:
test_mgr::success and test_mgr::last_fail should be protected, but that breaks the operator+() function. Can this be fixed?

Definition at line 48 of file test_mgr.h.

#include <test_mgr.h>

Public Member Functions

bool report ()
 Provide a report of all tests so far. More...
 
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 ()
 Return the number of tests performed so far.
 
The testing methods
bool test_rel (double result, double expected, double rel_error, std::string description)
 Test for $|\mathrm{result}-\mathrm{expected}|/ \mathrm{expected}<\mathrm{rel\_error}$.
 
bool test_abs (double result, double expected, double abs_error, std::string description)
 Test for $|\mathrm{result}-\mathrm{expected}|/ <\mathrm{abs\_error}$.
 
bool test_fact (double result, double expected, double factor, std::string description)
 Test for $1/\mathrm{factor} < \mathrm{result/expected} < \mathrm{factor}$.
 
bool test_str (std::string result, std::string expected, std::string description)
 Test for $\mathrm{result}=\mathrm{expected}$.
 
bool test_gen (bool value, std::string description)
 Test for $\mathrm{result}=\mathrm{expected}$.
 
template<class vec_t , class vec2_t >
bool test_rel_arr (int nv, const vec_t &result, const vec2_t &expected, double rel_error, std::string description)
 Test for $|\mathrm{result}-\mathrm{expected}|/ \mathrm{expected}<\mathrm{rel\_error}$ over each element of an array.
 
bool test_rel_arrgslgsl (int nv, gsl_vector *result, gsl_vector *expected, double rel_error, std::string description)
 Test for $|\mathrm{result}-\mathrm{expected}|/ \mathrm{expected}<\mathrm{rel\_error}$ over each element of an array.
 
template<class vec_t >
bool test_rel_arrgsl (int nv, const vec_t &result, gsl_vector *expected, double rel_error, std::string description)
 Test for $|\mathrm{result}-\mathrm{expected}|/ \mathrm{expected}<\mathrm{rel\_error}$ over each element of an array.
 
bool test_rel_matgslgsl (int nr, int nc, gsl_matrix *result, gsl_matrix *expected, double rel_error, std::string description)
 Test for $|\mathrm{result}-\mathrm{expected}|/ \mathrm{expected}<\mathrm{rel\_error}$ over each element of an array.
 
template<class mat_t >
bool test_rel_matgsl (int nr, int nc, const mat_t &result, gsl_matrix *expected, double rel_error, std::string description)
 Test for $|\mathrm{result}-\mathrm{expected}|/ \mathrm{expected}<\mathrm{rel\_error}$ over each element of an array.
 
template<class mat_t >
bool test_abs_matgsl (int nr, int nc, const mat_t &result, gsl_matrix *expected, double rel_error, std::string description)
 Test for $|\mathrm{result}-\mathrm{expected}| <\mathrm{rel\_error}$ over each element of an array.
 
template<class mat_t , class mat2_t >
bool test_rel_mat (int nr, int nc, const mat_t &result, const mat2_t &expected, double rel_error, std::string description)
 Test for $|\mathrm{result}-\mathrm{expected}|/ \mathrm{expected}<\mathrm{rel\_error}$ over each element of an array.
 
template<class vec_t , class vec2_t >
bool test_abs_arr (int nv, const vec_t &result, const vec2_t &expected, double rel_error, std::string description)
 Test for $|\mathrm{result}-\mathrm{expected}|/ <\mathrm{abs\_error}$ over each element of an array.
 
template<class vec_t , class vec2_t >
bool test_fact_arr (int nv, const vec_t &result, const vec2_t &expected, double factor, std::string description)
 Test for $ 1/factor < result/expected < factor $ over each element of an array.
 
template<class vec_t >
bool test_gen_arr (int nv, const vec_t &result, const vec_t &expected, std::string description)
 Test for equality of a generic array.
 

Data Fields

bool success
 True if all tests have passed.
 
std::string last_fail
 The description of the last failed test.
 

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.
 

Friends

const test_mgr operator+ (const test_mgr &left, const test_mgr &right)
 Add two test_mgr objects (if either failed, the sum fails)
 

Member Function Documentation

bool o2scl::test_mgr::report ( )

Returns true if all tests have passed and false if at least one test failed.

void o2scl::test_mgr::set_output_level ( int  l)
inline

Possible values:

  • 0 = No output
  • 1 = Output only tests that fail
  • 2 = Output all tests

Definition at line 90 of file test_mgr.h.


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

Documentation generated with Doxygen. Provided under the GNU Free Documentation License (see License Information).
Hosted at Get Object-oriented Scientific Computing
Lib at SourceForge.net. Fast, secure and Free Open Source software
downloads..