C++ Extensions (cppx) Documentation Internal Version
Main | Namespaces | Classes | NamespaceMembers | ClassMembers | Files

utst::TestCase Class Reference

A test case is a collection of test code which uses the UTST macros to perform self verifying checks. Subclasses of the TestClass interface should provide implementations of the getName(), theTest(), and clone() functions.

Several macros are provided to make it easier to write tests. The UTST_TEST_CASE() macro will create a new subclass of the TestCase interface and allow the user to just provide the test code. A user can also create test cases by directly subclassing the TestCase interface and adding test code to the theTest() member function. An example is below.

 UTST_TEST_CASE( TestAddition )
 {
   UTST_CHECK( 1 + 1 == 2 );
   UTST_CHECK_EQUAL( 1, 1 );
 }

The available test macros are listed below. These macros can only be used with the UTST_TEST_CASE macro or in theTest() member function of classes which are derrived from TestCase.

The UTST_MSG_STREAM is a special macro which is defined to be an ostream for outputting test messages.

Inheritance diagram for utst::TestCase:

Inheritance graph
[legend]
List of all members.

Public Methods

Protected Methods

Related Functions

(Note that these are not member functions.)

Detailed Documentation

Constructor & Destructor Documentation

virtual utst::TestCase::~TestCase   [virtual]
 

Virtual default destructor

Member Function Documentation

std::string utst::TestCase::getName   const
 

Return the name of this test case

virtual TestCase* utst::TestCase::clone   const [pure virtual]
 

Return a dynamically allocated clone of this object

void utst::TestCase::run   const
 

Run the test case and output results to the the TestLog

virtual void utst::TestCase::theTest   const [protected, pure virtual]
 

Actual test code. Users should subclass the test case base class and put test code in this function.

void utst::TestCase::setName const std::string &    name [protected]
 

Friends And Related Function Documentation

UTST_TEST_CASE testCaseName_    [related]
 

Macro to make creating simple test cases easier. Requires a code block (ie wrapped in curly braces) after the macro. One can use the UTST test macros in the code block. The macro creates a new class with the given name and this class can be instantiated with a default constructor.

 UTST_TEST_CASE( TestAddition )
 {
   UTST_CHECK( 1 + 1 == 2 );
   UTST_CHECK_EQUAL( 1, 1 );
 }

UTST_CHECK predicate_    [related]
 

Check whether or not the given predicate is true.

UTST_CHECK_EQUAL exp1_,
exp2_    [related]
 

Check whether or not the given expresssions are equal. The expressions must be able to be inserted into an output stream.

UTST_CHECK_NOT_EQUAL exp1_,
exp2_    [related]
 

Check whether or not the given expresssions are not equal. The expressions must be able to be inserted into an output stream.

UTST_CHECK_THROW excep,
expr    [related]
 

Check if the given expresssion throws the given exception.

UTST_CHECK_CONTAINERS c1,
c2    [related]
 

Check whether or not the given STL containers are equal. To be equal they must have the same number of elements and corresponding elements must be equal. Each container should have begin() and end() member functions and the elements must have insertion operators defined.

UTST_FAIL msg_    [related]
 

Write the given message and force this test case to fail.

UTST_NOTE msg_    [related]
 

Write the given message to the log's message stream.



The documentation for this class was generated from the following file:
Generated on Mon Aug 15 21:43:10 2005 by Doxygen 1.2.13-20020210 written by Dimitri van Heesch © 1997-2002