The class Exception (see Figure C-4) is descended from std::exception . It contains a message describing the assertion failure and a SourceLine giving its location.

Exception contains a nested class named Exception::Type . The Type value represents the named Exception type, allowing runtime Exception type identification. For the base Exception class, the Type is CppUnit::Exception .

Exception belongs to the namespace CppUnit . It is declared in Exception.h and implemented in Exception.cpp .

Figure C-4. The class Exception


 class Exception : public std::exception 


Exception(string message = "", SourceLine sourceLine = SourceLine( ))

A constructor for Exception . The message and sourceLine arguments have default empty values.

Exception(const Exception& other)

A copy constructor.

virtual ~Exception( ) throw( )

A destructor.

Public Methods

Exception& operator=(const Exception& other)

A copy operator.

virtual Exception *clone( ) const

Returns a copy of the Exception .

virtual bool isInstanceOf(const Type& type) const

Returns TRUE if the Exception is of the given Type . Used for runtime Exception type identification.

SourceLine sourceLine( ) const

Returns m_sourceLine .

static Type type( )

Returns CppUnit::Exception .

const char *what( ) const throw( )

Returns m_message as a C-style string.

Protected/Private Methods



string m_message

Assertion failure message ( private ).

SourceLine m_sourceLine

SourceLine giving the location of the assertion failure ( private ).

Unit Test Frameworks
Unit Test Frameworks
ISBN: 0596006896
EAN: 2147483647
Year: 2006
Pages: 146
Authors: Paul Hamill

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net