kaycxx-test
C++ unit test framework
Loading...
Searching...
No Matches
Namespaces | Functions
assert_throw.hpp File Reference

Defines the assert_throw function. More...

#include <concepts>
#include <exception>
#include <format>
#include <functional>
#include <optional>
#include <regex>
#include <source_location>
#include <string_view>
#include <utility>
#include <kaycxx/test/assertion_error.hpp>
#include <kaycxx/test/detail/exception_type.hpp>
#include <kaycxx/test/detail/exception_type_name.hpp>
#include <kaycxx/test/detail/to_string.hpp>
Include dependency graph for assert_throw.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  kaycxx
 Root namespace for kaycxx libraries.
 
namespace  kaycxx::test
 Unit test framework functions and types.
 

Functions

template<detail::exception_type Exception, std::invocable Function>
void kaycxx::test::assert_throw (Function &&function, std::string_view expected_message, std::string_view reason={}, std::optional< std::source_location > location=std::source_location::current())
 Asserts that the function throws an exception of the expected type with the exact expected message.
 
template<detail::exception_type Exception, std::invocable Function>
void kaycxx::test::assert_throw (Function &&function, std::regex const &expected_message, std::string_view reason={}, std::optional< std::source_location > location=std::source_location::current())
 Asserts that the function throws an exception of the expected type with a message matching the regex.
 

Detailed Description

Defines the assert_throw function.