class TestMain

A helper class for test programs. More...

Definition#include <test_main.hh>
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods


Detailed Description

A helper class for test programs.

This class is used to parse the command line arguments, enable the xlog_ framework and return the exit status from the test functions/methods. An example of how to use this class can be found in test_test_main.cc.

 TestMain (int argc, char **argv)

TestMain

Start the parsing of command line arguments and enable xlog_*.

string  get_optional_args (const string &short_form, const string &long_form, const string &description)

get_optional_args

Get an optional argument from the command line.

Parameters:
short_formThe short form of the argument e.g. "-t".
long_formThe long form of the argument e.g. "--testing".
descriptionThe description of this argument that will be used in the usage message.

Returns: the argument or "" if not found or an error occured in previous parsing of the arguments.

bool  get_optional_flag (const string &short_form, const string &long_form, const string &description)

get_optional_flag

Get an optional flag from the command line.

Parameters:
short_formThe short form of the argument e.g. "-t".
long_formThe long form of the argument e.g. "--testing".
descriptionThe description of this argument that will be used in the usage message.

Returns: true if the flag is present or false found or an error occured in previous parsing of the arguments.

void  complete_args_parsing ()

complete_args_parsing

Complete parsing the arguments.

Process generic arguments and verify that there are no arguments left unprocessed.

void  run (string test_name, XorpCallback1<bool, TestInfo&>::RefPtr cb)

run

Run a test function/method. The test function/method is passed a TestInfo. The test function/method should return true for success and "false for failure.

To run a function call "test": run("test", callback(test));

Parameters:
test_nameThe name of the test.
cbCallback object.

const string  usage ()

usage

Returns: The usage string.

void  failed (string error)

failed

Mark the tests as having failed. Used for setting an error condition from outside a test.

Parameters:
errorError string.

int  exit ()

exit

Must be called at the end of the tests.

Returns: The status of the tests. Should be passed to exit().


Generated by: pavlin on possum.icir.org on Thu Aug 28 12:51:57 2003, using kdoc 2.0a54+XORP.