1 #ifndef SIPLASPLAS_UTILITY_ASSERT_HPP 2 #define SIPLASPLAS_UTILITY_ASSERT_HPP 6 #include "preprocessor.hpp" 7 #include "exception.hpp" 8 #include <siplasplas/utility/export.hpp> 29 using std::logic_error::logic_error;
56 const std::string& message,
57 const std::string& file,
114 template<
typename String,
typename... Args>
117 _detail = ::fmt::format(std::forward<String>(messageBody), std::forward<Args>(messageArgs)...);
124 template<
typename String,
typename... Args>
127 return detail(std::forward<String>(messageBody), std::forward<Args>(args)...);
131 std::string _message;
135 std::function<void()> _onFailureCallback;
136 bool _assertionFailed;
158 template<
typename Function>
173 template<
typename String,
typename... Args>
182 template<
typename String,
typename... Args>
191 #if !defined(NDEBUG) || defined(SIPLASPLAS_ENABLE_ASSERTS) 192 #define SIPLASPLAS_ASSERTS_ENABLED 193 #define SIPLASPLAS_ASSERT_IMPL(MESSAGE, ...) ::cpp::AssertExpression((__VA_ARGS__), MESSAGE, __FILE__, __LINE__) 195 #define SIPLASPLAS_ASSERT_IMPL(MESSAGE, ...) ::cpp::DummyAssertExpression() 212 #define SIPLASPLAS_ASSERT(...) SIPLASPLAS_ASSERT_IMPL(SIPLASPLAS_PP_STR((__VA_ARGS__)), __VA_ARGS__) 252 #define SIPLASPLAS_ASSERT_COMP_IMPL(a, b, op, wording) SIPLASPLAS_ASSERT_IMPL(::fmt::format( \ 253 "Expected '{}' ({}) {} '{}' ({})", \ 254 SIPLASPLAS_PP_STR(a), \ 257 SIPLASPLAS_PP_STR(b), \ 279 #define SIPLASPLAS_ASSERT_EQ(a, b) SIPLASPLAS_ASSERT_COMP_IMPL(a, b, ==, "equal to") 300 #define SIPLASPLAS_ASSERT_NE(a, b) SIPLASPLAS_ASSERT_COMP_IMPL(a, b, !=, "not equal to") 321 #define SIPLASPLAS_ASSERT_BT(a, b) SIPLASPLAS_ASSERT_COMP_IMPL(a, b, > , "bigger than") 342 #define SIPLASPLAS_ASSERT_LT(a, b) SIPLASPLAS_ASSERT_COMP_IMPL(a, b, < , "less than") 363 #define SIPLASPLAS_ASSERT_BE(a, b) SIPLASPLAS_ASSERT_COMP_IMPL(a, b, >=, "bigger or equal to") 384 #define SIPLASPLAS_ASSERT_LE(a, b) SIPLASPLAS_ASSERT_COMP_IMPL(a, b, <=, "less or equal to") 398 #define SIPLASPLAS_ASSERT_TRUE(...) SIPLASPLAS_ASSERT_IMPL(::fmt::format( \ 399 "Expected '{}' to be true. Got false instead", \ 400 SIPLASPLAS_PP_STR((__VA_ARGS__)) \ 415 #define SIPLASPLAS_ASSERT_FALSE(...) SIPLASPLAS_ASSERT_IMPL(::fmt::format( \ 416 "Expected '{}' to be false. Got true instead", \ 417 SIPLASPLAS_PP_STR((__VA_ARGS__)) \ 421 #endif // SIPLASPLAS_UTILITY_ASSERT_HPP DummyAssertExpression & onFailure(Function)
Does nothing.
Definition: assert.hpp:159
Definition: canary_allocator.hpp:7
Represents an assertion error.
Definition: assert.hpp:26
Represents an assert expression when SIPLASPLAS_ASSERT() macros are disabled.
Definition: assert.hpp:146
DummyAssertExpression & operator()(String &&, Args &&...)
Does nothing. Equivalent to detail().
Definition: assert.hpp:183
Implements a siplasplas assertion.
Definition: assert.hpp:43
AssertExpression & detail(String &&messageBody, Args &&...messageArgs)
Adds detailed information to the assertion report.
Definition: assert.hpp:115
DummyAssertExpression & detail(String &&, Args &&...)
Does nothing.
Definition: assert.hpp:174
AssertExpression & operator()(String &&messageBody, Args &&...args)
Adds detailed information to the assertion report. Equivalent to detail().
Definition: assert.hpp:125