test_mgr Class Reference

#include <test_mgr.h>


Detailed Description

A class to manage testing and record success and failure.

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 38 of file test_mgr.h.


Public Member Functions

bool report ()
 Provide a report of all tests so far.
std::string get_last_fail ()
 Returns the description of the last test that failed.
void set_output_level (int l)
 Set the output level.
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/factor<result/expected<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, vec_t &result, vec2_t &expected, double rel_error, std::string description)
 Test for $|\mathrm{result}-\mathrm{expected}|/ \mathrm{expected}<\mathrm{rel\_error}$.
template<class mat_t, class mat2_t>
bool test_rel_mat (int nr, int nc, mat_t &result, mat2_t &expected, double rel_error, std::string description)
 Test for $|\mathrm{result}-\mathrm{expected}|/ \mathrm{expected}<\mathrm{rel\_error}$.
template<class vec_t, class vec2_t>
bool test_abs_arr (int nv, vec_t &result, vec2_t &expected, double rel_error, std::string description)
 Test for $|\mathrm{result}-\mathrm{expected}|/ <\mathrm{abs\_error}$.
template<class vec_t, class vec2_t>
bool test_fact_arr (int nv, vec_t &result, vec2_t &expected, double factor, std::string description)
 Test for $1/factor<result/expected<factor$ ??
template<class vec_t>
bool test_gen_arr (int nv, vec_t &result, 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 report (  ) 

Provide a report of all tests so far.

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

void set_output_level ( int  l  )  [inline]

Set the output level.

Possible values:

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

Definition at line 78 of file test_mgr.h.


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

Documentation generated with Doxygen and provided under the GNU Free Documentation License. See License Information for details.

Project hosting provided by SourceForge.net Logo, O2scl Sourceforge Project Page