kaycxx-test
C++ unit test framework
Loading...
Searching...
No Matches
Public Member Functions | List of all members
kaycxx::test::failure Class Reference

Failure result passed to reporters when a test case or suite fails. More...

#include <kaycxx/test/failure.hpp>

Public Member Functions

 failure (std::string_view description, kaycxx::assert::assertion_error const &error, std::source_location location)
 Creates a failure from an assertion error.
 
 failure (std::string_view description, std::exception const &error, std::source_location location)
 Creates a failure from a standard exception and explicit source location.
 
 failure (std::string_view description, std::source_location location)
 Creates a failure for a non-standard unknown exception.
 
std::string const & description () const noexcept
 Returns the full test or suite description.
 
std::string const & error_message () const noexcept
 Returns the failure message.
 
std::source_location const & location () const noexcept
 Returns the source location.
 
std::optional< std::string > const & actual () const noexcept
 Returns the actual assertion value when available.
 
std::optional< std::string > const & expected () const noexcept
 Returns the expected assertion value when available.
 

Detailed Description

Failure result passed to reporters when a test case or suite fails.

Constructor & Destructor Documentation

◆ failure() [1/3]

kaycxx::test::failure::failure ( std::string_view  description,
kaycxx::assert::assertion_error const &  error,
std::source_location  location 
)
explicit

Creates a failure from an assertion error.

Parameters
descriptionFull test or suite description.
errorAssertion error thrown by kaycxx::assert.
locationFallback source location to report for the failure when error has no location.

◆ failure() [2/3]

kaycxx::test::failure::failure ( std::string_view  description,
std::exception const &  error,
std::source_location  location 
)
explicit

Creates a failure from a standard exception and explicit source location.

Parameters
descriptionFull test or suite description.
errorException thrown by the test, suite, or hook.
locationSource location to report for the failure.

◆ failure() [3/3]

kaycxx::test::failure::failure ( std::string_view  description,
std::source_location  location 
)
explicit

Creates a failure for a non-standard unknown exception.

Parameters
descriptionFull test or suite description.
locationSource location to report for the failure.

Member Function Documentation

◆ actual()

std::optional< std::string > const & kaycxx::test::failure::actual ( ) const
noexcept

Returns the actual assertion value when available.

Returns
The actual value string, or an empty optional when the failure did not come from a value assertion.

◆ description()

std::string const & kaycxx::test::failure::description ( ) const
noexcept

Returns the full test or suite description.

Returns
The full test or suite description.

◆ error_message()

std::string const & kaycxx::test::failure::error_message ( ) const
noexcept

Returns the failure message.

Returns
The failure message.

◆ expected()

std::optional< std::string > const & kaycxx::test::failure::expected ( ) const
noexcept

Returns the expected assertion value when available.

Returns
The expected value string, or an empty optional when the failure did not come from a value assertion.

◆ location()

std::source_location const & kaycxx::test::failure::location ( ) const
noexcept

Returns the source location.

Returns
The source location.

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