Clients can either create a subclass or directly use this class.
IComparisonTestOf tests the following operations of its target class:
- copy constructed stack object - operator= assigned stack object - operator= self-assigned stack object - copy constructed heap object - operator= assigned heap object - operator= self-assigned heap object - Separately constructed unequal object of the unequal target is given
Target class must have operator== defined.
The best was to use the IComparisonTest framework is to use the protocol macros ComparisonTestMacro and ComparisonTestEqualOnlyMacro.
These macros do everything you need in one line. They write the entire header and the entire implementation, including construtors and destructors. Just supply the names of the test class, target class, comparator, the parameter list for the constructor that creates the target, and (optionally) the unequal target. The parameter list may be left blank to indicate that the empty constructor is to be used to create the target or unequal target. If the test is only testing equal targets, then use the "EqualOnly" macros.
Usage:Example: ISample is the target class which we want to test. ISample has a constructor, a copy constructor, an operator=, and an operator== defined:
comparisonTestMacro(ISampleTest, ISample, (1), (2));
Example: Example for a class which creates the target object using the empty constructor:
comparisonTestMacro(ISampleTest, ISample, , (2));
Now you can run ISampleTest with the following command:
runTestImplementationMacro(ISampleTest);
If you do not want to test your target against an unequal object of the same type, do the following:
comparisonTestEqualOnlyMacro(ISampleTest, ISample, (1));
Or you can use this global function which creates and returns an instance of IComparisonTestOf:
createComparisonTest(new ISample(1), new ISample(2));
which can be used with the adoptTest method (see the ITestCollection class).
Class constructors and destructors.
![]() |
public:
virtual ~IComparisonTestOf()
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
public:
IComparisonTestOf(const IComparisonTestOf < AType >& that)
Windows | OS/2 | AIX |
Yes | Yes | Yes |
public:
IComparisonTestOf(AType* target, AType* unequalTarget = 0)
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
public:
IComparisonTestOf < AType >& operator =( const IComparisonTestOf < AType >& that )
Windows | OS/2 | AIX |
Yes | Yes | Yes |
Class member functions used to by the IComparison tests. Some need to be overridden by the user and some should NOT be overridden. See each member function for details.
![]() |
public:
virtual void copyInfo()
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
protected:
virtual const char* targetClassNameAsString() const
You must override this method if you want the target class name reported in the test output.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
protected:
virtual void test()
Note: Do NOT override the method. Do NOT call this method directly. The best was to use the IComparisonTest framework is to use the protocol macros: ComparisonTestMacro and ComparisonTestEqualOnlyMacro.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
virtual ~ITest()
void copyInputs(int& argc, char * *& argv) const
virtual EStage exceptionStage() const
virtual bool lookupInfo(const IString& key, IString& info)
ITest& operator =(const ITest& test)
ITieredTextBuffer& outputTextStream()
virtual void run()
virtual unsigned long runCount() const
void setInputs(const int argc, const char * const* argv)
bool success() const
static const IString & _Import kComponentKey
static const IString& kComponentKey
static const IString & _Import kDescriptionKey
static const IString& kDescriptionKey
static const IString & _Import kInputSyntaxKey
static const IString& kInputSyntaxKey
static const IString& kTargetClassKey
static const IString & _Import kTargetClassKey
static const IString & _Import kTestNameKey
static const IString& kTestNameKey
static const IString& kTestTypeKey
static const IString & _Import kTestTypeKey
static const IString& kTestVersionKey
static const IString & _Import kTestVersionKey
virtual void addInfo(const IString&, const IString&)
virtual void cleanup()
virtual bool isReset() const
virtual bool isSuccessUndecided() const
ITest(const ITest& test)
ITest()
virtual void print(ITieredTextBuffer&)
virtual void reset()
virtual void setStickySuccess(bool success)
virtual void setSuccess(bool success)
virtual void setup()
virtual void test() = 0