class TestException

Base class for unit test exceptions.

This class primarily servers as base class for TestFailure and TestException. It provides the basic mechanism for handling unit test exception. It is implemented with the handle-body-idiom: The actual exception data is stored inside an internal data structure. That allows a very fast implementation of the copy-constructor and the assignment operator. This is essential for all descendants of this class because they might be caught and re-thrown many times.



Public Members:
    virtual ~TestException () ;
    Virtual destructor
    Releases its reference to the internal data structure. Only when this was the last reference, all the data is deleted as well.

    virtual TestException& operator= (const TestException& rhs) ;
    Assignment operator
    Using this operator is cheap because only the exception body is reused.

    virtual string getMessage () const ;
    Get the message.
    Simple reader method.

    virtual string getFileName () const ;
    Return the exception source file name.
    The name of the file that contains the code that has generated the test exception. The real file name is only available if it was specified when the exceptions constructor was called. Otherwise the value UNKNOWN_FILE is returned.

    virtual int getLine () const ;
    Return the line number in the exception source file name.
    The line number of the place in the code that has generated the test exception. The real line number is only available if it was specified when the exceptions constructor was called. Otherwise the value UNKNOWN_LINE is returned.

    virtual bool isError () const ;
    Test if this exception is an error.
    An exception is an error if it was raised because something unforseen has happened. Normal negative test outcomes are represented as failures, not errors!




Protected Members:
    TestException ( const string& message, const string& fileName = UNKNOWN_FILE, int line = UNKNOWN_LINE ) ;
    Initialise the exception with a descriptive message
    The message should describe the exception cause. In addition, the name of the source file in which the test is defined and the line number could be specified. If they are unknown, symbolic default values are used.

    TestException (const TestException& te) ;
    The copy-constructor
    Creates only a reference to the internal, shared data structure.




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