Class: TBaseComparisonTest

Declaration: BaseComparisonTest.h

Taxonomy Categories:

Member Functions:


Interface Category:

Developer Tool Programmer Interface.

Inherits From:

TTest

Inherited By:

TBaseStreamTest TBaseWellBehavedObjectTest TBaseCopyTest TBaseFlattenResurrectTest TBasePrimitiveComparisonTest

Purpose:

An abstract base class derived from TTest that defines a protocol for classes of tests that compares two objects using a comparator (TAbstractComparator).

Instantiation:

Allocate on the heap or the stack.

Deriving Classes:

TBaseComparisonTest cannot be used directly. Use one of its concrete derived classes instead.

Concurrency:

Not multithread safe.

Resource Use:

No special requirements.

Member Function: TBaseComparisonTest::~TBaseComparisonTest

virtual ~ TBaseComparisonTest ()

Interface Category:

Developer Tool Programmer Interface.

Purpose:

Destructor.

Calling Context:

Called to destroy an object.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TBaseComparisonTest::operator<<=

virtual TStream & operator <<= (TStream & source)

Interface Category:

Developer Tool Programmer Interface.

Purpose:

Stream-in operator.

Calling Context:

Called to stream in data.

Parameters:

Return Value:

Returns a reference to the stream the object streams itself in from.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TBaseComparisonTest::operator>>=

virtual TStream & operator >>=(TStream & destination) const

Interface Category:

Developer Tool Programmer Interface.

Purpose:

Stream-out operator.

Calling Context:

Called to stream out data.

Parameters:

Return Value:

Returns a reference to the stream the object streams itself out to.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TBaseComparisonTest::AdoptComparator

void AdoptComparator (TAbstractComparator * comparator)

Interface Category:

Developer Tool Programmer Interface.

Purpose:

Sets the comparator to be used for the test.

Calling Context:

Called by Test framework and directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TBaseComparisonTest::OrphanComparator

TAbstractComparator * OrphanComparator ()

Interface Category:

Developer Tool Programmer Interface.

Purpose:

Returns a pointer to the comparator previously set by AdoptComparator, or zero if no comparator has been set.

Calling Context:

Called by Test framework and directly.

Parameters:

Return Value:

Returns a pointer to the comparator previously set by AdoptComparator, or zero if no comparator has been set.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TBaseComparisonTest::GetComparator

TAbstractComparator * GetComparator ()

Interface Category:

Developer Tool Programmer Interface.

Purpose:

Returns a pointer to the comparator previously set by AdoptComparator, or zero if no comparator has been set.

Calling Context:

Called by Test framework and directly.

Parameters:

Return Value:

Returns a pointer to the comparator previously set by AdoptComparator, or zero if no comparator has been set.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TBaseComparisonTest::SetCheckHash

virtual void SetCheckHash (bool check)

Interface Category:

Developer Tool Programmer Interface.

Purpose:

Sets a Boolean that controls whether the hash values are checked when comparing two the objects. If true, the Compare member function checks that the hash values are equal if the objects suppose to be equal.

Calling Context:

Called by Test framework and directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TBaseComparisonTest::GetCheckHash

virtual bool GetCheckHash () const

Interface Category:

Developer Tool Programmer Interface.

Purpose:

Gets a Boolean that controls whether the hash values are checked when comparing two the objects. If true, the Compare member function checks that the hash values are equal if the objects suppose to be equal.

Calling Context:

Called by Test framework and directly.

Parameters:

Return Value:

Returns true if the hash values are checked when comparing two objects in the Compare function.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TBaseComparisonTest::TBaseComparisonTest

  1. TBaseComparisonTest ()
  2. TBaseComparisonTest (const TBaseComparisonTest & copyIn)

Interface Category:

Developer Tool Programmer Interface.

Purpose:

  1. Default constructor.
  2. Copy constructor.

Calling Context:

  1. Called by the stream-in operators and directly.
  2. Called to copy an object.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TBaseComparisonTest::operator=

TBaseComparisonTest & operator =(const TBaseComparisonTest & copyIn)

Interface Category:

Developer Tool Programmer Interface.

Purpose:

Assignment operator.

Calling Context:

Called when an object is assigned to another compatible object.

Parameters:

Return Value:

A non-const reference to the left-hand side object.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TBaseComparisonTest::Setup

virtual void Setup ()

Interface Category:

Developer Tool Programmer Interface.

Purpose:

Sets the target to the object returned from CreateNewTarget if the target is not set. It then calls SetupComparator to set the comparator if the comparator is not set.

Calling Context:

Called by Test framework. Do not call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TBaseComparisonTest::SetupComparator

virtual void SetupComparator ()

Interface Category:

Developer Tool Programmer Interface.

Purpose:

Sets up the comparator to be used for the test. Derived classes should overload SetupComparator to instantiate the comparator and call AdoptComparator for the comparator.

Calling Context:

Called by Test framework. Do not call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TBaseComparisonTest::GetTargetClassNameAsString

virtual const char * GetTargetClassNameAsString () const

Interface Category:

Developer Tool Programmer Interface.

Purpose:

Returns the name of the target class.

Calling Context:

Called by Test framework. Do not call this function directly.

Parameters:

Return Value:

Returns the name of the target class.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

Derived classes must override this function to return the name of the target class.

Member Function: TBaseComparisonTest::CreateNewTarget

virtual void * CreateNewTarget () const

Interface Category:

Developer Tool Programmer Interface.

Purpose:

Creates target on the heap and returns the object.

Calling Context:

Called by Test framework. Do not call this function directly.

Parameters:

Return Value:

Returns a new target object that has been allocated on the heap.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

Derived classes must override this function to create a new target object on the heap.

Member Function: TBaseComparisonTest::DeleteTarget

virtual void DeleteTarget (void *) const

Interface Category:

Developer Tool Programmer Interface.

Purpose:

Deletes the given target object after casting it to the target class to invoke the correct destructor.

Calling Context:

Called by Test framework. Do not call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

Derived classes must override this function to delete the given target object.

Member Function: TBaseComparisonTest::Compare

virtual void Compare (void * obj, void * target, bool shouldBeEqual, bool canBeSame)

Interface Category:

Developer Tool Programmer Interface.

Purpose:

Compares the object's original and copy and verifies that they are equal or unequal using the comparator. Objects are considered equal if their hash values are equal and if TypeSafeCompare returns kEqual. If the comparator is not set, pointer comparison is done to compare the objects, and the hash values are not checked. If canBeSame is false, Compare also checks to see that the pointer values for the original and the copy are not equal.

Calling Context:

Called by Test framework.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.