CPUnit 0.95 (beta)
The REAL C++ port of JUnit.
cpunit::TestStore Class Reference

This class is where all tests are registered. More...

#include <cpunit_TestStore.hpp>

List of all members.

Public Member Functions

void insert_set_up (Callable *su)
 Inserts a set-up method for the suite named in the passed Callable object.
void insert_tear_down (Callable *td)
 Inserts a tear-down method for the suite named in the passed Callable object.
void insert_test (Callable *test)
 Inserts a test method for the suite named in the passed Callable object.
std::vector< TestUnitget_test_units (const std::string &pattern)
 Returns a selection of tests in terms of TestUnits.
std::vector< RegInfoget_tests (const std::string &pattern)
 Returns a selection of tests in terms of RegInfos.

Static Public Member Functions

static TestStoreget_instance ()
 The singleton get-instance method.
static void dispose ()
 Static class member which deletes the singleton instance.

Private Member Functions

 TestStore ()
 Initiates an empty TestStore.
 ~TestStore ()
 Destructor.
std::vector< std::string > decompose_path (const std::string &path) const
 Decomposes scoped name into a vector of path elements.
TestTreeNodefind_node (const std::string &path, const bool create_nonexisting)
 Locates the TestTreeNode matching the given path, possibly creating the node if it does not already exist.

Private Attributes

std::auto_ptr< TestTreeNoderoot

Static Private Attributes

static TestStoreINSTANCE

Detailed Description

This class is where all tests are registered.

The class is implemented as a singleton, and provides methods for registration of tests and fixtures (set_up and tear_down), as well as query methods for obtaining subsets of the tests.

Definition at line 53 of file cpunit_TestStore.hpp.


Constructor & Destructor Documentation

cpunit::TestStore::TestStore ( ) [private]

Initiates an empty TestStore.

Definition at line 43 of file cpunit_TestStore.cpp.

cpunit::TestStore::~TestStore ( ) [private]

Destructor.

All registered tests are deleted when the tests store dies.

Definition at line 52 of file cpunit_TestStore.cpp.


Member Function Documentation

std::vector< std::string > cpunit::TestStore::decompose_path ( const std::string &  path) const [private]

Decomposes scoped name into a vector of path elements.

E.g., passing "cpunit::info", will cause the resulting vector to contain the elements {"cpunit", "info"}.

Parameters:
pathA scoped path, using "::" as path delimiter.
Returns:
A vector containing the elements of the path.

Definition at line 160 of file cpunit_TestStore.cpp.

void cpunit::TestStore::dispose ( ) [static]

Static class member which deletes the singleton instance.

It is important that the test framework does not leak any memory, as it will make it more difficult to detect memory leaks in the application under test.

Definition at line 63 of file cpunit_TestStore.cpp.

cpunit::TestTreeNode * cpunit::TestStore::find_node ( const std::string &  path,
const bool  createIfNonExisting 
) [private]

Locates the TestTreeNode matching the given path, possibly creating the node if it does not already exist.

Parameters:
pathThe C++ path to the desired TestTreeNode, using "::" as delimiter.
createIfNonExistingIf true, the node will be created if it does not already exist.
Returns:
The specified TestTreeNode, or NULL if it does not exist and createIfNonExisting is false.

Definition at line 189 of file cpunit_TestStore.cpp.

cpunit::TestStore & cpunit::TestStore::get_instance ( ) [static]

The singleton get-instance method.

Returns:
The singleton instance.

Definition at line 74 of file cpunit_TestStore.cpp.

std::vector< cpunit::TestUnit > cpunit::TestStore::get_test_units ( const std::string &  pattern)

Returns a selection of tests in terms of TestUnits.

Parameters:
patternThe glob pattern to match against. Passing "*" will return all registered tests.
Returns:
The matched tests in terms of TestUnits.

Definition at line 129 of file cpunit_TestStore.cpp.

std::vector< cpunit::RegInfo > cpunit::TestStore::get_tests ( const std::string &  pattern)

Returns a selection of tests in terms of RegInfos.

Parameters:
patternThe glob pattern to match against. Passing "*" will return all registered tests.
Returns:
The matched tests in terms of RegInfos.

Definition at line 143 of file cpunit_TestStore.cpp.

void cpunit::TestStore::insert_set_up ( Callable su)

Inserts a set-up method for the suite named in the passed Callable object.

Parameters:
suA Callable pointer to the set-up method to register. The test store takes over control of the Callable object.
Exceptions:
WrongSetupExceptionif a set-up method is already registered for the suite the set-up is to be registered for.

Definition at line 89 of file cpunit_TestStore.cpp.

void cpunit::TestStore::insert_tear_down ( Callable td)

Inserts a tear-down method for the suite named in the passed Callable object.

Parameters:
tdA Callable pointer to the tear-down method to register. The test store takes over control of the Callable object.
Exceptions:
WrongSetupExceptionif a tear-down method is already registered for the suite the tear-down is to be registered for.

Definition at line 103 of file cpunit_TestStore.cpp.

void cpunit::TestStore::insert_test ( Callable test)

Inserts a test method for the suite named in the passed Callable object.

Parameters:
testA Callable pointer to the test method to register. The test store takes over control of the Callable object.
Exceptions:
WrongSetupExceptionif the test is already registered.

Definition at line 116 of file cpunit_TestStore.cpp.


Member Data Documentation

Definition at line 54 of file cpunit_TestStore.hpp.

std::auto_ptr<TestTreeNode> cpunit::TestStore::root [private]

Definition at line 58 of file cpunit_TestStore.hpp.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines