class CorUnitTest

A tester class

Inheritance:


Public Methods

void checkAssert ()
CorUnitTest ( const CorUnitTest& aRef )
CorUnitTest ()
void expectAssert ( int aNumber )
void failHandler ( const char* aFile, int aLineNumber, const char* aText )
_IO_ostream_withassign& getOstream ()
static CorUnitTest* getTester ()
CorUnitTest& operator= ( const CorUnitTest& aRef )
void print ( const char* aText )
void printBanner ( CorBool aPrintOn )
void printf ( const char* aFormat, ... )
void successHandler ( const char* aFile, int aLineNumber, const char* aText )
void testMessages ( CorBool aMessagesOn )
~CorUnitTest ()

Public


Purpose
Check that all expected assertions were fired

Purpose
Query the current CorUnitTest instance

Purpose
The default c'tor

Purpose
The d'tor

$Id: CorUnitTest

Purpose
Query the stream to be used for C++ << type message output

Private Fields

int mNumExpected
Purpose
Abort the test

Private Methods

static void abortTest ()
void assertHandler ( const char* aFile, int aLineNumber, const char* aText )
static void assertion ( const char* aFile, int aLineNumber, const char* aText )
void reportHandler ( const char* aHeader, const char* aFile, int aLineNumber, const char* aText )

Documentation

A tester class
$Id: CorUnitTest.h,v 1.2 1997/04/11 13:32:05 mwiedmer Exp $

SYNOPSIS

    #include <CorUnitTest.h>
  
    CorUnitTest myObject;
  

DESCRIPTION
This class provides unit testing utility functions. The test program should create an instance of this class and pass it to the unit test function. Each class should have a friend function called
utest_<className>(CorUnitTest&), eg.

  class SubClass {
  private:
    friend void utest_SubClass(CorUnitTest&);
  };
  

The checker maintains an instance count to ensure that only one CorUnitTest can exist at any time. This is because:

  • The CorUnitTest handles the assertions and thus requires a static pointer to the one and only CorUnitTest so it's member functions can be invoked.

  • The COR_UTEST macro needs to invoke a member function for the instance of the CorUnitTest.

  • Finally only one unit test is allowed per invocation of a test harness so why could you possibly want more than one?

The CorUnitTest in the test file should be called 'cortest' as in:

void TestMyClass(CorUnitTest& cortest){ .... }

The CorUnitTest grabs the assertion handler and processes the assertions for the caller.

CAUTIONS
<optional>

EXAMPLES
<optional>

SEE ALSO
COR_ASSERT
COR_DEBUG

CorUnitTest()

Purpose
The default c'tor.

Preconditions

  • Itemize this section if necessary. Remove itemization otherwise.

Exceptions

  • Itemize this section if necessary. Remove itemization otherwise.

CorUnitTest( const CorUnitTest& aRef )

CorUnitTest& operator=( const CorUnitTest& aRef )

~CorUnitTest()

Purpose
The d'tor.

Preconditions

  • Itemize this section if necessary. Remove itemization otherwise.

Exceptions

  • Itemize this section if necessary. Remove itemization otherwise.

void expectAssert( int aNumber )

void checkAssert()

Purpose
Check that all expected assertions were fired.

Preconditions

  • Itemize this section if necessary. Remove itemization otherwise.

Exceptions

  • Itemize this section if necessary. Remove itemization otherwise.

void print( const char* aText )

void printf( const char* aFormat, ... )

void printBanner( CorBool aPrintOn )

void testMessages( CorBool aMessagesOn )

_IO_ostream_withassign& getOstream()

Purpose
Query the stream to be used for C++ << type message output.

Preconditions

  • Itemize this section if necessary. Remove itemization otherwise.

Returns
This function returns the current output stream.

Exceptions

  • Itemize this section if necessary. Remove itemization otherwise.

static CorUnitTest* getTester()

Purpose
Query the current CorUnitTest instance.

Preconditions

  • Itemize this section if necessary. Remove itemization otherwise.

Returns
This function returns the current CorUnitTest instance or 0.

Exceptions

  • Itemize this section if necessary. Remove itemization otherwise.

void failHandler( const char* aFile, int aLineNumber, const char* aText )

void successHandler( const char* aFile, int aLineNumber, const char* aText )

void assertHandler( const char* aFile, int aLineNumber, const char* aText )

void reportHandler( const char* aHeader, const char* aFile, int aLineNumber, const char* aText )

static void assertion( const char* aFile, int aLineNumber, const char* aText )

static void abortTest()

int mNumExpected
Purpose
Abort the test


This class has no child classes.

alphabetic index hierarchy of classes


this page has been generated automatically by doc++

(c)opyright by Malte Zöckler, Roland Wunderling
contact: doc++@zib.de