template class TestGadget<class T> : TestCase

A template that creates test cases by applying a functor to a test fixture object.

This template generates test cases that use an applicable for test execution. That applicable is most likely generated from a member function of the test fixture class. Note that the fixture class does not need to inherit from Test.
The fixture object and the applicable instance are owned by the test gadget. So when the gadget is destroyed, this objects are deleted as well. The template function apply could be used to construct the Applicable-instance for the test action on the fly (see Applicable). Note that there also versions of the apply functions that allow to specify constant parameters for the member function. The test gadget itself could be easily created with the makeTestGadget template functions:

template<class T> inline TestGadget<T>* makeTestGadget (
      const string& name,
      Applicable<T>* testFunc
);

template<class T> inline TestGadget<T>* makeTestGadget (
      const string& name,
      T* object,
      Applicable<T>* testFunc,
      bool releaseFixture = false
);
 
The first version constructs automatically a fixture instance which is owned by the gadget (so it is also deleted when the gadget is destroyed). The second version allows to specify the fixture object. Because such a function is needed when a fixture is used for multiple gadgets, the releaseFixture parameter defaults to false.



Public Members:
    TestGadget ( const string name, T* fixture, Applicable<T>* testFunc, bool releaseFixture ) ;
    Create a test gadget from a fixture instance and an applicable.
    A new test case is created from combining a test fixture object (of type T) with an applicable (which is usable with type T). If releaseFixture is true, the fixture instance will be deleted when the test gadget is destroyed.

    virtual ~TestGadget () ;
    Destroys the test gadget.
    Also the test fixture object and the applicable instance are deleted.

    virtual void test () ;
    Execute the test.
    The test function Applicable instance is applied to the test fixture instance. In practice that means that the member function is applied to the fixture object.




The Scrunitizer C++ Unit Test Framework
by Bernd Linowski

[Scrunitizer]  [Overview]  [Cookbook]  [Download]  [Index]  [Linosphere]

Page generated: 1 Nov 2000
(C) by Bernd Linowski
scrunitizer@linosphere.de