9#ifndef BOTAN_ASSERTION_CHECKING_H_
10#define BOTAN_ASSERTION_CHECKING_H_
12#include <botan/compiler.h>
21 assertion_failure(const
char* expr_str, const
char* assertion_made, const
char* func, const
char* file,
int line);
29#define BOTAN_ARG_CHECK(expr, msg) \
32 Botan::throw_invalid_argument(msg, __func__, __FILE__); \
41#define BOTAN_STATE_CHECK(expr) \
44 Botan::throw_invalid_state(#expr, __func__, __FILE__); \
50#define BOTAN_ASSERT(expr, assertion_made) \
53 Botan::assertion_failure(#expr, assertion_made, __func__, __FILE__, __LINE__); \
59#define BOTAN_ASSERT_NOMSG(expr) \
62 Botan::assertion_failure(#expr, "", __func__, __FILE__, __LINE__); \
68#define BOTAN_ASSERT_EQUAL(expr1, expr2, assertion_made) \
70 if((expr1) != (expr2)) \
71 Botan::assertion_failure(#expr1 " == " #expr2, assertion_made, __func__, __FILE__, __LINE__); \
77#define BOTAN_ASSERT_IMPLICATION(expr1, expr2, msg) \
79 if((expr1) && !(expr2)) \
80 Botan::assertion_failure(#expr1 " implies " #expr2, msg, __func__, __FILE__, __LINE__); \
86#define BOTAN_ASSERT_NONNULL(ptr) \
88 if((ptr) == nullptr) \
89 Botan::assertion_failure(#ptr " is not null", "", __func__, __FILE__, __LINE__); \
92#if defined(BOTAN_ENABLE_DEBUG_ASSERTS)
94 #define BOTAN_DEBUG_ASSERT(expr) BOTAN_ASSERT_NOMSG(expr)
98 #define BOTAN_DEBUG_ASSERT(expr) \
113template <
typename...
T>
118#define BOTAN_UNUSED Botan::ignore_params
137#define BOTAN_ASSERT_UNREACHABLE() Botan::assert_unreachable(__FILE__, __LINE__)
#define BOTAN_PUBLIC_API(maj, min)
#define BOTAN_UNSTABLE_API
void assert_unreachable(const char *file, int line)
void throw_invalid_state(const char *expr, const char *func, const char *file)
void throw_invalid_argument(const char *message, const char *func, const char *file)
constexpr void ignore_param(T &&)
constexpr void ignore_params(T &&... args)
void assertion_failure(const char *expr_str, const char *assertion_made, const char *func, const char *file, int line)