Testing a class that uses the default comparator and streamer

The simplest way to create a test that does not use specialized constructors or streamers is to use the protocol quick test macros. These macros are available for these template classes:

These macros write the entire header and definition for a test subclass in one line and use the TOperatorComparator and TMonomorphicStreamer for the test.

You must specify the following items when you use the QuickWellBehavedObjectTestMacro.

  1. The test class name.
  2. The target class name.
  3. The list of parameters for the constructor of the target class, including parentheses. Leave the argument blank if you use the empty constructor to create the target.
  4. A second set of parameters with different values from the first set of parameters. The test uses the second set of parameters to create an object unequal to the object created with the first set of parameters.
The following line shows a sample of how to use the macro:

    QuickWell.BehavedObjectTestMacro(TWellbehavedObjectTest, TSampleObject, (1), (2));
The following example shows the command for a class that creates the target object using the empty constructor:

    QuickWellBehavedObjectTestMacro(TWellBehavedObjectTest, TSampleObject, , (2));
The following
table lists the protocol quick test macros syntax and shows an example.

Protocol quick test macro Description
QuickCopyTest Tests copying of the target class using the global Copy function. Uses TOperatorComparator for the test.
QuickCopyTestMacro(testClass, targetClass, parameterList)
Example:
    QuickCopyTestMacro(TSampleObjectCopyTest, TSampleObject, (1));
Example for a class that creates the target object using the empty constructor:
    QuickCopyTestMacro(TSampleObjectCopyTest, TSampleObject,);
QuickFlattenResurrectTest Tests the flattening and resurrecting of the target object using the global Flatten and Resurrect functions. Uses TOperatorComparator for the test.
QuickFlattenRessurectTestMacro(testClass, targetClass, parameterList)
Example:
    QuickFlattenResurrectTestMacro(TSampleObjectFlattenResurrectTest, TSampleObject, (1));
Example for a class that creates the target object using the empty constructor:
    QuickFlattenResurrectTestMacro(TSampleObjectFlattenResurrectTest, TSampleObject, );
QuickStreamTest Tests streaming of the target object. Uses the TOperatorComparator and TMonomorphicStreamer for the test.
QuickStreamTestMacro(testClass, targetClass, parameterList)
Example:
    QuickStreamTestMacro(TSampleObjectStreamTest, TSampleObject, (1));
Example for a class that creates the target object using the empty constructor:
    QuickStreamTestMacro(TSampleObjectStreamTest, TSampleObject,);
QuickPrimitiveComparisonTest
Tests the constructor, destructor, copy constructor, and assignment operator for a concrete class only. Uses TOperatorComparator for the test.
TPrimitiveComparisonTestOfInterfaceMacro(testClass, targetClass)
Example:
    QuickPrimitiveComparisonTestMacro(TSampleObject PrimiitiveComparisonTest, TSampleObject, (1), (2));
Example for a class that creates the target object using the empty constructor:
    QuickPrimitiveComparisonTestMacro(TSampleObject PrimiitiveComparisonTest, TSampleObject, ,(2));
QuickWellBehavedObjectTest
Creates and performs the TCopyTestOf, TStreamTestOf, TFlattenResurrectTestOf, and TPrimitiveComparisonTestOf. Turn off the TPrimitiveComparisonTestOf by specifying -p after the -o option when you use RunTest. Uses TOperatorComparator and TMonomorphicStreamer for the test.
QuickWellBehavedObjectTestOfInterfaceMacro(testClass, targetClass, parameterList, unequalParameterList)
Example:
    QuickWellBehavedObjectTestMacro(TSampleObjectWellBehavedObjectTest, TSampleObject, (1), (2));
Example for a class that creates the target object using the empty constructor:
    QuickWellBehavedObjectTestMacro(TSampleObjectWellBehavedObjectTest, TSampleObject, , (2));


[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker