FreePOOMA  2.4.1
Public Member Functions
Pooma::Tester Class Reference

Tester is used to help make it easier to write simple test programs. More...

#include <Tester.h>

List of all members.

Public Member Functions

 Tester ()
 Tester (int argc, char **argv)
 ~Tester ()
Informout ()
bool ok () const
int returnValue () const
bool check (bool val)
bool check (const char *str, bool val)
template<class T >
bool check (const char *str, const T &val, const T &correct)
template<class T >
bool check (const char *str, const T &val, const T &correct, const T &tol)
void set (bool val)
void setQuiet (bool quiet)
void setVerbose (bool verbose)
bool verbose ()
void setPrefix (char *prefix)
int results (const char *msg=0) const
void exceptionHandler (const char *msg=0)
void exceptionHandler (const Assertion &asrt)

Detailed Description

Tester is used to help make it easier to write simple test programs.

It provides:

You use Tester in this way:

  1. Initialize Pooma as normal.
  2. Create a Tester instance, giving it the argc, argv from main: Pooma::Tester tester(argc, argv);
  3. For each test you want to do, you can print out messages to tester, then call the "check" method with a boolean argument: tester << "This is the first test." << endl; tester.check(testval == true); If the argument to "check" is false, it will clear the flag. Once cleared, it will stay cleared even if further "check" calls are done with an argument of true (so once one test fails, the whole test code will fail).
  4. When you're done, you can print out a result message, like this: int retval = tester.results("Test code description string"); This will print out the message: PASSED ..... message or FAILED ..... message depending on the current value of the OK flag. It returns an exit code value, 1 if the test FAILED, 0 if the test PASSED, that you can use to return from main. For example:

int retval = tester.results("My current test."); Pooma::finalize(); return retval;

The optional command-line arguments that Tester understands are: (these will NOT be stripped from the argc, argv given to Tester in its constructor)


Constructor & Destructor Documentation

Pooma::Tester::Tester ( int  argc,
char **  argv 
)

Member Function Documentation

Inform& Pooma::Tester::out ( ) [inline]

Referenced by check(), setPrefix(), setQuiet(), and setVerbose().

bool Pooma::Tester::ok ( ) const [inline]

Referenced by returnValue().

int Pooma::Tester::returnValue ( ) const [inline]

References ok().

bool Pooma::Tester::check ( bool  val) [inline]

References PInsist.

Referenced by check().

bool Pooma::Tester::check ( const char *  str,
bool  val 
) [inline]

References check(), std::endl(), and out().

template<class T >
bool Pooma::Tester::check ( const char *  str,
const T &  val,
const T &  correct 
) [inline]

References check(), std::endl(), and out().

template<class T >
bool Pooma::Tester::check ( const char *  str,
const T &  val,
const T &  correct,
const T &  tol 
) [inline]

References abs(), check(), std::endl(), and out().

void Pooma::Tester::set ( bool  val) [inline]
void Pooma::Tester::setQuiet ( bool  quiet) [inline]
void Pooma::Tester::setVerbose ( bool  verbose) [inline]
bool Pooma::Tester::verbose ( ) [inline]

Referenced by setVerbose().

void Pooma::Tester::setPrefix ( char *  prefix) [inline]

References out(), and Inform::setPrefix().

int Pooma::Tester::results ( const char *  msg = 0) const
void Pooma::Tester::exceptionHandler ( const char *  msg = 0)

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