KASSERT
0.0.1
Karlsruhe Assertion Library
|
Macros for asserting runtime checks. More...
#include <iostream>
#include <string_view>
#include <type_traits>
#include <utility>
#include <vector>
#include "kassert/internal/assertion_macros.hpp"
#include "kassert/internal/expression_decomposition.hpp"
#include "kassert/internal/logger.hpp"
Go to the source code of this file.
Classes | |
struct | kassert::internal::SourceLocation |
Describes a source code location. More... | |
class | kassert::KassertException |
The default exception type used together with THROWING_KASSERT . Reports the erroneous expression together with a custom error message. More... | |
Namespaces | |
namespace | kassert::assert |
Assertion levels. | |
Macros | |
#define | KASSERT_ASSERTION_LEVEL_KTHROW 10 |
Assertion level for exceptions if exception mode is disabled. | |
#define | KASSERT_ASSERTION_LEVEL_NORMAL 30 |
Default assertion level. This level is used if no assertion level is specified. | |
#define | KASSERT_ASSERTION_LEVEL KASSERT_ASSERTION_LEVEL_NORMAL |
Default assertion level to kassert::assert::normal if not set explicitly. | |
#define | KASSERT(...) |
Assertion macro. Accepts between one and three parameters. More... | |
#define | THROWING_KASSERT(...) |
Macro for throwing exceptions. Accepts between one and three parameters. More... | |
#define | THROWING_KASSERT_SPECIFIED(expression, message, exception_type, ...) KASSERT_KASSERT_HPP_THROWING_KASSERT_CUSTOM_IMPL(expression, exception_type, message, ##__VA_ARGS__) |
Macro for throwing custom exception. More... | |
#define | KASSERT_ENABLED(level) level <= KASSERT_ASSERTION_LEVEL |
Checks if a assertion of the given level is enabled. This is controlled by the CMake option KASSERT_ASSERTION_LEVEL . This is the macro version of assertion_enabled for use in the preprocessor. More... | |
Functions | |
std::string | kassert::internal::build_what (std::string const &expression, SourceLocation const where, std::string const &message) |
Builds the description for an exception. More... | |
constexpr bool | kassert::internal::assertion_enabled (int level) |
Checks if a assertion of the given level is enabled. This is controlled by the CMake option KASSERT_ASSERTION_LEVEL . More... | |
bool | kassert::internal::evaluate_and_print_assertion (char const *type, bool result, SourceLocation const &where, char const *expr_str) |
Evaluates an assertion that could not be decomposed (i.e., expressions that use && or ||). If the assertion fails, prints an error describing the failed assertion. More... | |
bool | kassert::internal::evaluate_and_print_assertion (char const *type, Expression &&expr, SourceLocation const &where, char const *expr_str) |
Evaluates an assertion expression. If the assertion fails, prints an error describing the failed assertion. More... | |
Variables | |
constexpr int | kassert::assert::kthrow = KASSERT_ASSERTION_LEVEL_KTHROW |
Assertion level for exceptions if exception mode is disabled. | |
constexpr int | kassert::assert::normal = KASSERT_ASSERTION_LEVEL_NORMAL |
Default assertion level. This level is used if no assertion level is specified. | |
Macros for asserting runtime checks.
#define KASSERT_ENABLED | ( | level | ) | level <= KASSERT_ASSERTION_LEVEL |
Checks if a assertion of the given level is enabled. This is controlled by the CMake option KASSERT_ASSERTION_LEVEL
. This is the macro version of assertion_enabled for use in the preprocessor.
level | The level of the assertion. |
|
constexpr |
Checks if a assertion of the given level is enabled. This is controlled by the CMake option KASSERT_ASSERTION_LEVEL
.
level | The level of the assertion. |
|
inline |
Builds the description for an exception.
expression | Expression that caused this exception to be thrown. |
where | Source code location where the exception was thrown. |
message | User message describing this exception. |
|
inline |
Evaluates an assertion that could not be decomposed (i.e., expressions that use && or ||). If the assertion fails, prints an error describing the failed assertion.
type | Actual type of this check. In exception mode, this parameter has always value ASSERTION , otherwise it names the type of the exception that would have been thrown. |
result | Assertion expression result to be checked. |
where | Source code location of the assertion. |
expr_str | Stringified assertion expression. |
|
inline |
Evaluates an assertion expression. If the assertion fails, prints an error describing the failed assertion.
type | Actual type of this check. In exception mode, this parameter has always value ASSERTION , otherwise it names the type of the exception that would have been thrown. |
expr | Assertion expression to be checked. |
where | Source code location of the assertion. |
expr_str | Stringified assertion expression. |