Jon Test
C++ Unit Test Tool. Not for production -- sample code only
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
JonTest::TestFailure Class Reference

Exception thrown when a test fails an assert and should fail (unless wrapped in expectedFailure()). More...

#include <TestFailure.h>

Inheritance diagram for JonTest::TestFailure:
Inheritance graph
Collaboration diagram for JonTest::TestFailure:
Collaboration graph

Public Member Functions

 TestFailure (const char *const file, const int line, const std::string &message)
 Construct Test Failure Exception without excpression or operator information.
 
template<typename Type1 , typename Type2 >
 TestFailure (const char *const file, const int line, const std::string &message, const std::string &firstExpression, const Type1 &firstValue, const std::string &secondExpression, const Type2 &secondValue, const std::string &operatorString)
 Construct Test Failure Exception.
 
virtual ~TestFailure ()
 Required virutal destructor.
 
virtual const charwhat () const noexcept
 Gets formatted message of string.
 

Public Attributes

std::string file
 Filename where failure occurred.
 
int line
 Line number of file where failure occurred.
 
std::string message
 Message provided where failure occurred.
 
std::string firstExpression
 String representation of first expression that failed the test.
 
std::string firstValue
 String representation of evaluation of first expression that failed the test.
 
std::string secondExpression
 String representation of second expression that failed the test.
 
std::string secondValue
 String representation of evaluation of second expression that failed the test.
 
std::string operatorString
 String representation of operator that failed the test.
 
std::string whatString
 Formatted representation of failure.
 

Detailed Description

Exception thrown when a test fails an assert and should fail (unless wrapped in expectedFailure()).

Contains all test data from failure.

Definition at line 15 of file TestFailure.h.

Constructor & Destructor Documentation

◆ TestFailure() [1/2]

JonTest::TestFailure::TestFailure ( const char *const  file,
const int  line,
const std::string &  message 
)
inline

Construct Test Failure Exception without excpression or operator information.

Parameters
fileFilename where failure occurred
lineLine number of file where failure occurred
messageMessage provided where failure occurred

Definition at line 48 of file TestFailure.h.

◆ TestFailure() [2/2]

template<typename Type1 , typename Type2 >
JonTest::TestFailure::TestFailure ( const char *const  file,
const int  line,
const std::string &  message,
const std::string &  firstExpression,
const Type1 firstValue,
const std::string &  secondExpression,
const Type2 secondValue,
const std::string &  operatorString 
)
inline

Construct Test Failure Exception.

Note
Relies on operator<< for Type1 and Type2.
Template Parameters
Type1Type which first expression evaluated to
Type2Type which second expression evaluated to
Parameters
fileFilename where failure occurred
lineLine number of file where failure occurred
messageMessage provided where failure occurred
firstExpressionString representation of first expression that failed the test
firstValueEvaluation of the first expression that failed the test
secondExpressionString representation of evaluation of second expression that failed the test
secondValueEvaluation of the second expression that failed the test
operatorString/// String representation of operator that failed the test

Definition at line 75 of file TestFailure.h.

◆ ~TestFailure()

JonTest::TestFailure::~TestFailure ( )
virtual

Required virutal destructor.

Definition at line 6 of file TestFailure.cpp.

Member Function Documentation

◆ what()

const char * JonTest::TestFailure::what ( ) const
virtualnoexcept

Gets formatted message of string.

Returns
formatted message of string

Definition at line 11 of file TestFailure.cpp.

Member Data Documentation

◆ file

std::string JonTest::TestFailure::file

Filename where failure occurred.

Definition at line 20 of file TestFailure.h.

◆ firstExpression

std::string JonTest::TestFailure::firstExpression

String representation of first expression that failed the test.

Definition at line 29 of file TestFailure.h.

◆ firstValue

std::string JonTest::TestFailure::firstValue

String representation of evaluation of first expression that failed the test.

Definition at line 32 of file TestFailure.h.

◆ line

int JonTest::TestFailure::line

Line number of file where failure occurred.

Definition at line 23 of file TestFailure.h.

◆ message

std::string JonTest::TestFailure::message

Message provided where failure occurred.

Definition at line 26 of file TestFailure.h.

◆ operatorString

std::string JonTest::TestFailure::operatorString

String representation of operator that failed the test.

Definition at line 41 of file TestFailure.h.

◆ secondExpression

std::string JonTest::TestFailure::secondExpression

String representation of second expression that failed the test.

Definition at line 35 of file TestFailure.h.

◆ secondValue

std::string JonTest::TestFailure::secondValue

String representation of evaluation of second expression that failed the test.

Definition at line 38 of file TestFailure.h.

◆ whatString

std::string JonTest::TestFailure::whatString

Formatted representation of failure.

Definition at line 44 of file TestFailure.h.


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