Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
property_assertions.hpp
Go to the documentation of this file.
1
#
ifndef
INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_TESTING_PROPERTY_ASSERTIONS_HPP_
2
#
define
INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_TESTING_PROPERTY_ASSERTIONS_HPP_
3
4
// IWYU pragma: begin_keep
5
#
include
"arene/base/testing/detail/property_context.hpp"
// IWYU pragma: export
6
#
include
"arene/base/testing/property_error.hpp"
// IWYU pragma: export
7
// IWYU pragma: end_keep
8
9
/// @brief Macro to assert that a property is @c true
10
/// @param expr property to check
11
/// If the property encoded in @c expr is @c false, returns a @c property_outcome with <c>status == failure</c>.
12
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
13
#
define
ARENE_PROP_ASSERT
(
...
)
14
do
{
/* NOLINT(cppcoreguidelines-avoid-do-while) */
15
if
(
!
static_cast
<
bool
>
(
__VA_ARGS__
)
&&
!
::
arene
::
base
::
testing
::
detail
::
property_context
(
)
.
has_value
(
)
)
{
16
::
arene
::
base
::
testing
::
detail
::
property_context
(
)
.
emplace
(
::
arene
::
base
::
testing
::
property_error
{
17
::
arene
::
base
::
testing
::
property_error
::
error_code
::
failure
,
18
{
__FILE__
,
__LINE__
}
,
19
{
#
__VA_ARGS__
}
20
}
)
;
21
return
;
22
}
23
}
while
(
false
)
24
25
/// @brief Macro to assert that a property is @c true
26
/// @param expr property to check
27
/// If the property encoded in @c expr is @c false, returns a @c property_outcome with <c>status == failure</c>.
28
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
29
#
define
ARENE_PROP_ASSERT_TRUE
(
...
)
ARENE_PROP_ASSERT
(
__VA_ARGS__
)
30
31
/// @brief Macro to assert that a property is @c false
32
/// @param expr property to check
33
/// If the property encoded in @c expr is @c true, returns a @c property_outcome with <c>status == failure</c>.
34
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
35
#
define
ARENE_PROP_ASSERT_FALSE
(
...
)
ARENE_PROP_ASSERT
(
!
(
__VA_ARGS__
)
)
36
37
/// @brief Macro to discard a specific run
38
/// @param expr property to check
39
/// If @c expr is @c false, returns a @c property_outcome with <c>status == discard</c>.
40
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
41
#
define
ARENE_PROP_PRE
(
...
)
42
do
{
/* NOLINT(cppcoreguidelines-avoid-do-while) */
43
if
(
!
static_cast
<
bool
>
(
__VA_ARGS__
)
&&
!
::
arene
::
base
::
testing
::
detail
::
property_context
(
)
.
has_value
(
)
)
{
44
::
arene
::
base
::
testing
::
detail
::
property_context
(
)
.
emplace
(
::
arene
::
base
::
testing
::
property_error
{
45
::
arene
::
base
::
testing
::
property_error
::
error_code
::
discard
,
46
{
__FILE__
,
__LINE__
}
,
47
{
#
__VA_ARGS__
}
48
}
)
;
49
return
;
50
}
51
}
while
(
false
)
52
#
endif
// INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_TESTING_PROPERTY_ASSERTIONS_HPP_
ARENE_PROP_ASSERT
#define ARENE_PROP_ASSERT(...)
Macro to assert that a property is true.
Definition
property_assertions.hpp:13
arene
base
testing
property_assertions.hpp
Generated by
1.13.2