PSCF v1.1
Public Member Functions | Protected Attributes | List of all members
TestException Class Reference

An exception thrown by a failed unit test. More...

#include <TestException.h>

Public Member Functions

 TestException ()
 Default constructor. More...
 
 TestException (const char *function, const char *message, const char *file, int line)
 Constructor for throwing. More...
 
 TestException (const char *message, const char *file, int line)
 Constructor without function name parameter. More...
 
 ~TestException ()
 Destructor. More...
 
void write (std::ostream &out)
 Write error message to output stream. More...
 
const std::string & message ()
 Return the error message. More...
 

Protected Attributes

std::string message_
 Error message. More...
 

Detailed Description

An exception thrown by a failed unit test.

Definition at line 19 of file TestException.h.

Constructor & Destructor Documentation

◆ TestException() [1/3]

TestException::TestException ( )

Default constructor.

Function Definitions ---------------------------------------—.

Definition at line 87 of file TestException.h.

◆ TestException() [2/3]

TestException::TestException ( const char *  function,
const char *  message,
const char *  file,
int  line 
)

Constructor for throwing.

Constructs error message that includes file and line number. Values of the file and line parameters should be given by the built-in macros FILE and LINE, respectively, in the calling function. A typical call of the constructor is thus of the form:

throw TestException("MyClass::myFunction", "A terrible thing happened!",
__FILE__, __LINE__ );
TestException()
Default constructor.
Definition: TestException.h:87
Parameters
functionname of the function from which the TestException was thrown
messagemessage describing the nature of the error
filename of the file from which the TestException was thrown
lineline number in file

Definition at line 94 of file TestException.h.

References message(), and message_.

◆ TestException() [3/3]

TestException::TestException ( const char *  message,
const char *  file,
int  line 
)

Constructor without function name parameter.

Parameters
messagemessage describing the nature of the error
filename of the file from which the TestException was thrown
lineline number in file

Definition at line 116 of file TestException.h.

References message(), and message_.

◆ ~TestException()

TestException::~TestException ( )

Destructor.

Definition at line 134 of file TestException.h.

Member Function Documentation

◆ write()

void TestException::write ( std::ostream &  out)
inline

Write error message to output stream.

Parameters
outoutput stream

Definition at line 142 of file TestException.h.

References message_.

◆ message()

const std::string & TestException::message ( )
inline

Return the error message.

Definition at line 148 of file TestException.h.

References message_.

Referenced by UnitTestRunner< UnitTestClass >::method(), and TestException().

Member Data Documentation

◆ message_

std::string TestException::message_
protected

Error message.

Definition at line 78 of file TestException.h.

Referenced by message(), TestException(), and write().


The documentation for this class was generated from the following file: