#include "barretenberg/common/throw_or_abort.hpp"
#include <sstream>
#include "barretenberg/common/log.hpp"
#include <cassert>
#include <cstdlib>
#include <iostream>
#include <string>
Go to the source code of this file.
|
#define | DONT_EVALUATE(expression) |
|
#define | ASSERT_DEBUG(expression, ...) ASSERT(expression, __VA_ARGS__) |
|
#define | ASSERT_IN_CONSTEXPR(expression, ...) |
|
#define | ASSERT(expression, ...) |
|
#define | BB_ASSERT_EQ(actual, expected, ...) |
|
#define | BB_ASSERT_NEQ(actual, expected, ...) |
|
#define | BB_ASSERT_GT(left, right, ...) |
|
#define | BB_ASSERT_GTE(left, right, ...) |
|
#define | BB_ASSERT_LT(left, right, ...) |
|
#define | BB_ASSERT_LTE(left, right, ...) |
|
#define | ASSERT_THROW_OR_ABORT(statement, matcher) ASSERT_THROW(statement, std::runtime_error) |
|
#define | EXPECT_THROW_OR_ABORT(statement, matcher) EXPECT_THROW(statement, std::runtime_error) |
|
◆ ASSERT
#define ASSERT |
( |
|
expression, |
|
|
|
... |
|
) |
| |
Value: do { \
if (!(expression)) { \
std::ostringstream oss; \
oss << "Assertion failed: (" #expression ")"; \
__VA_OPT__(oss << " | Reason: " << __VA_ARGS__;) \
} \
} while (0)
void throw_or_abort(std::string const &err)
Definition at line 49 of file assert.hpp.
◆ ASSERT_DEBUG
#define ASSERT_DEBUG |
( |
|
expression, |
|
|
|
... |
|
) |
| ASSERT(expression, __VA_ARGS__) |
◆ ASSERT_IN_CONSTEXPR
#define ASSERT_IN_CONSTEXPR |
( |
|
expression, |
|
|
|
... |
|
) |
| |
Value: do { \
if (!(expression)) { \
info("Assertion failed: (" #expression ")"); \
__VA_OPT__(
info(
"Reason : ", __VA_ARGS__);) \
} \
} while (0)
Definition at line 40 of file assert.hpp.
◆ ASSERT_THROW_OR_ABORT
#define ASSERT_THROW_OR_ABORT |
( |
|
statement, |
|
|
|
matcher |
|
) |
| ASSERT_THROW(statement, std::runtime_error) |
◆ BB_ASSERT_EQ
#define BB_ASSERT_EQ |
( |
|
actual, |
|
|
|
expected, |
|
|
|
... |
|
) |
| |
Value: do { \
auto _actual = (actual); \
auto _expected = (expected); \
if (!(_actual == _expected)) { \
std::ostringstream oss; \
oss << "Assertion failed: (" #actual " == " #expected ")\n"; \
oss << " Actual : " << _actual << "\n"; \
oss << " Expected: " << _expected; \
__VA_OPT__(oss << "\n Reason : " << __VA_ARGS__;) \
} \
} while (0)
- Examples
- /opt/build/repo/barretenberg/cpp/src/barretenberg/common/zip_view.hpp.
Definition at line 59 of file assert.hpp.
◆ BB_ASSERT_GT
#define BB_ASSERT_GT |
( |
|
left, |
|
|
|
right, |
|
|
|
... |
|
) |
| |
Value: do { \
auto _left = (left); \
auto _right = (right); \
if (!(_left > _right)) { \
std::ostringstream oss; \
oss << "Assertion failed: (" #left " > " #right ")\n"; \
oss << " Left : " << _left << "\n"; \
oss << " Right : " << _right; \
__VA_OPT__(oss << "\n Reason : " << __VA_ARGS__;) \
} \
} while (0)
Definition at line 87 of file assert.hpp.
◆ BB_ASSERT_GTE
#define BB_ASSERT_GTE |
( |
|
left, |
|
|
|
right, |
|
|
|
... |
|
) |
| |
Value: do { \
auto _left = (left); \
auto _right = (right); \
if (!(_left >= _right)) { \
std::ostringstream oss; \
oss << "Assertion failed: (" #left " >= " #right ")\n"; \
oss << " Left : " << _left << "\n"; \
oss << " Right : " << _right; \
__VA_OPT__(oss << "\n Reason : " << __VA_ARGS__;) \
} \
} while (0)
Definition at line 101 of file assert.hpp.
◆ BB_ASSERT_LT
#define BB_ASSERT_LT |
( |
|
left, |
|
|
|
right, |
|
|
|
... |
|
) |
| |
Value: do { \
auto _left = (left); \
auto _right = (right); \
if (!(_left < _right)) { \
std::ostringstream oss; \
oss << "Assertion failed: (" #left " < " #right ")\n"; \
oss << " Left : " << _left << "\n"; \
oss << " Right : " << _right; \
__VA_OPT__(oss << "\n Reason : " << __VA_ARGS__;) \
} \
} while (0)
Definition at line 115 of file assert.hpp.
◆ BB_ASSERT_LTE
#define BB_ASSERT_LTE |
( |
|
left, |
|
|
|
right, |
|
|
|
... |
|
) |
| |
Value: do { \
auto _left = (left); \
auto _right = (right); \
if (!(_left <= _right)) { \
std::ostringstream oss; \
oss << "Assertion failed: (" #left " <= " #right ")\n"; \
oss << " Left : " << _left << "\n"; \
oss << " Right : " << _right; \
__VA_OPT__(oss << "\n Reason : " << __VA_ARGS__;) \
} \
} while (0)
Definition at line 129 of file assert.hpp.
◆ BB_ASSERT_NEQ
#define BB_ASSERT_NEQ |
( |
|
actual, |
|
|
|
expected, |
|
|
|
... |
|
) |
| |
Value: do { \
auto _actual = (actual); \
auto _expected = (expected); \
if (!(_actual != _expected)) { \
std::ostringstream oss; \
oss << "Assertion failed: (" #actual " != " #expected ")\n"; \
oss << " Actual : " << _actual << "\n"; \
oss << " Not expected: " << _expected; \
__VA_OPT__(oss << "\n Reason : " << __VA_ARGS__;) \
} \
} while (0)
Definition at line 73 of file assert.hpp.
◆ DONT_EVALUATE
#define DONT_EVALUATE |
( |
|
expression | ) |
|
Value: { \
true ? static_cast<void>(0) : static_cast<void>((expression)); \
}
Definition at line 8 of file assert.hpp.
◆ EXPECT_THROW_OR_ABORT
#define EXPECT_THROW_OR_ABORT |
( |
|
statement, |
|
|
|
matcher |
|
) |
| EXPECT_THROW(statement, std::runtime_error) |