IStreamTestOf

Tests the streaming of the target object using operator<<= and operator>>=

IStreamTestOf is a subclass of ITest which tests the streaming of the target. Clients should create a subclass of IStreamTestOf or use streamTestMacro (see below).

This test is a good way to leverage testing effort since it allows one to test classes if those classes are expected to adhere to some protocol. This protocol test is implemented using a template class. Target classes MUST have operator= defined to be tested by IStreamTestOf. One macro and one global function are provided for easy use of this class.

The macro streamTestMacro does everything you need in one line. It writes the entire header and the entire implementation. Just supply the name of the test class, target class and the parameter list for the constructor that creates the target. The parameter list may be left blank to indicate that the empty constructor is to be used to create the target. For example, ISample is the target class that we want to test streaming. ISample has operator<<=, operator>>=, and operator== defined.

      streamTestMacro(ISampleTest,ISample,(1));

The following is an example of a class which creates the target object using the empty constructor:

      streamTestMacro(ISampleTest,ISample,);

Now you can run ISampleTest with runTestImplementationMacro:

      runTestImplementationMacro(ISampleTest);

Or you can use this global function which creates and returns an instance of IStreamTestOf, as follows:

             createStreamTest(new ISample(2));

This can be used with the adoptTest method in the ITestCollection class.


IStreamTestOf - Member Functions and Data by Group

Constructors & Destructor

Class constructors and destructors.


[view class]
~IStreamTestOf
public:
virtual ~IStreamTestOf()
Destructs objects of this class.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
IStreamTestOf
Constructs objects of this class.


Overload 1
public:
IStreamTestOf(const IStreamTestOf < AType >&)
Copy constructor.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


Overload 2
public:
IStreamTestOf(AType* target)
Constructor which specifies the target object to perform tests on.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


Assignment Operators

Use this operator to replace the existing object with the assigned, given one.


[view class]
operator =
public:
IStreamTestOf < AType >& operator =( const IStreamTestOf < AType >& )
Standard assignment operator.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


Meta Information

Class member functions used to provide information about the tests.


[view class]
copyInfo
public:
virtual void copyInfo()
Within copyInfo, ISteamTestOf calls the inherited implementation. For example, IDerived::copyInfo should call IBase::copyInfo. Then copyInfo should add key/value pairs to infoMap by calling the addInfo() method.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


Output Methods

Class members used to display information to the user.


[view class]
targetClassNameAsString
protected:
virtual const char* targetClassNameAsString() const
Returns the name of the target class. Be default, it returns null. You can override this method if the target class name is to be reported in the test output.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


Test Methods

Methods used to run the streaming test.


[view class]
test
protected:
virtual void test()
Streams the target object out to and in from the memory stream and compares the streamed-in object with the original.

The test method also verifies that the stream position is consistent after stream-out and stream-in.

Note: Do not override this method. The best way to use the IStreamTestOf framework is to use the protocol StreamTestMacro.

ITest overrides; these methods are called by the framework ITest::run()

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


IStreamTestOf - Inherited Member Functions and Data

Inherited Public Functions

ITest

Inherited Public Data

ITest

Inherited Protected Functions

ITest

Inherited Protected Data