Testing object protocols

Protocol tests allow you to test an entire tree of classes where those classes adhere to some protocol. The Test framework contains five ready-made protocol tests.

TCopyTestOf tests copying of the target class using the global Copy function.

TStreamTestOf tests streaming of the target object. You can disable checking hash values when comparing objects by using the -h option when you perform the test. You can disable stream-in version checking by using the -v option.

TFlattenResurrectTestOf tests the flattening and resurrecting of the target object using the global Flatten and Resurrect functions. You can disable checking hash values when comparing objects by using the -h option when you perform the test.

TPrimitiveComparisonTestOf tests the constructor, destructor, copy constructor, and assignment operator for concrete classes only. You can disable checking hash values when comparing objects by using the -h option when you perform the test.

TWellBehavedObjectTestOf creates and performs the TCopyTestOf, TStreamTestOf, TFlattenResurrectTestOf, and TPrimitiveComparisonTestOf. You can override SetCheckPrimitiveComparison and set it to False to avoid running the TPrimitiveComparisonTestOf test. You can disable checking hash values when comparing objects by using the -h option when you perform the test. You can disable stream-in version checking by using the -v option.

Each of the five tests has corresponding macros that declare and define a derived class of the appropriate base test class to test your object. These macros write the entire header and implementation, including constructors and destructors.

In addition, quick test macros let you write entire protocol tests with a single line if your object uses the default comparator and default streamer.

You can use the macros whenever you can create the target with a single parameter list. You cannot use the macros if you need to create or reference other objects in order to create your target. If you are dealing with other objects, you must derive your protocol test class from the appropriate template class.


[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