RepeatedTest

   
RepeatedTest

Description

The class RepeatedTest (see Figure C-11) is a subclass of TestDecorator . It runs a Test for a specified number of repetitions.

RepeatedTest belongs to the namespace CppUnit . It is declared in extensions/RepeatedTest.h and implemented in RepeatedTest.cpp .

Figure C-11. The class RepeatedTest
figs/utf_ac11.gif

Declaration

 class RepeatedTest : public TestDecorator 

Constructors/Destructors


RepeatedTest(Test *test, int timesRepeat)

A constructor taking the Test to run and the number of repetitions.

Public Methods


int countTestCases( ) const

Returns the number of test cases that this RepeatedTest will run, which is the number of test cases the Test contains multiplied by the number of repetitions.


void run(TestResult *result)

A method to run the RepeatedTest .


string toString( ) const

Returns a string representation of the RepeatedTest .

Protected/Private Methods


RepeatedTest(const RepeatedTest &)

A copy constructor declared private to prevent its use.


void operator=(const RepeatedTest &)

A copy operator declared private to prevent its use.

Attributes


const int m_timesRepeat

The number of test repetitions to run ( private ).

   
SourceLine

Description

The class SourceLine (see Figure C-12) represents a location in a source code file. It is used to capture the location of an assertion failure. A SourceLine usually is created using the macro CPPUNIT_SOURCELINE( ) , which uses the preprocessor directives _ _FILE_ _ and __LINE_ _ to obtain the filename and line number of the location where it's invoked:

 #define CPPUNIT_SOURCELINE( ) ::CppUnit::SourceLine( __FILE__, 

__LINE_  _ ) 

SourceLine belongs to the namespace CppUnit . It is declared in SourceLine.h and implemented in SourceLine.cpp .

Figure C-12. The class SourceLine
figs/utf_ac12.gif

Declaration

 class SourceLine 

Constructors/Destructors


SourceLine(string &fileName, int lineNumber)

A constructor taking a filename and line number.


SourceLine( )

A default constructor creating an uninitialized SourceLine .


virtual ~SourceLine( )

A destructor.

Public Methods


bool operator==(const SourceLine &other) const

A comparison operator.


bool operator!=(const SourceLine &other) const

An inequality operator.


string fileName( ) const

Returns the filename.


bool isValid( ) const

Returns TRUE if SourceLine is initialized (the filename is not empty).


int lineNumber( ) const

Returns the line number.

Protected/Private Methods


RepeatedTest(const RepeatedTest &)

A copy constructor declared private to prevent its use.


void operator=(const RepeatedTest &)

A copy operator declared private to prevent its use.

Attributes


string m_fileName

The source filename ( private ).


int m_lineNumber

The source file line number ( private ).

   
SynchronizedObject

Description

The class SynchronizedObject (see Figure C-13) serves as the parent class for synchronized objects. Synchronized objects incorporate a mutex-based lock mechanism, allowing them to be used concurrently by multiple threads.

SynchronizedObject includes the nested classes SynchronizationObject , which is its mutex object, and ExclusiveZone , which locks a SynchronizationObject .

SynchronizedObject belongs to the namespace CppUnit . It is declared in SynchronizedObject.h and implemented in SynchronizedObject.cpp .

Figure C-13. The base class SynchronizedObject
figs/utf_ac13.gif

Declaration

 class SynchronizedObject 

Constructors/Destructors


SynchronizedObject(SynchronizationObject *syncObject = 0)

A constructor taking a SynchronizationObject (mutex.) If syncObject is null , a new SynchronizationObject is created.


virtual ~SynchronizedObject( )

A destructor.

Public Methods

None.

Protected/Private Methods


virtual void setSynchronizationObject(SynchronizationObject *syncObject)

Sets the SynchronizationObject .


SynchronizedObject(const SynchronizedObject &copy)

A copy constructor declared private to prevent its use.


void operator=(const SynchronizedObject &copy)

A copy operator declared private to prevent its use.

Attributes


SynchronizationObject *m_syncObject

A pointer to the SynchronizationObject for this SynchronizedObject ( protected ).