Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
property_assertions.hpp
Go to the documentation of this file.
1
// Copyright 2026, Toyota Motor Corporation
2
//
3
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4
5
#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_TESTING_PROPERTY_ASSERTIONS_HPP_
6
#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_TESTING_PROPERTY_ASSERTIONS_HPP_
7
8
// IWYU pragma: begin_keep
9
#include "arene/base/testing/detail/property_context.hpp"
// IWYU pragma: export
10
#include "
arene/base/testing/property_error.hpp
"
// IWYU pragma: export
11
// IWYU pragma: end_keep
12
13
/// @brief Macro to assert that a property is @c true
14
/// If the supplied property is @c false, returns a @c property_outcome with <c>status == failure</c>.
15
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
16
#define ARENE_PROP_ASSERT(...) \
17
do {
/* NOLINT(cppcoreguidelines-avoid-do-while) */
\
18
if (!static_cast<bool>(__VA_ARGS__) && !::arene::base::testing::detail::property_context().has_value()) { \
19
::arene::base::testing::detail::property_context().emplace(::arene::base::testing::property_error{ \
20
::arene::base::testing::property_error::error_code::failure, \
21
{__FILE__, __LINE__}, \
22
{#__VA_ARGS__} \
23
}); \
24
return; \
25
} \
26
} while (false)
27
28
/// @brief Macro to assert that a property is @c true
29
/// If the supplied property is @c false, returns a @c property_outcome with <c>status == failure</c>.
30
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
31
#define ARENE_PROP_ASSERT_TRUE(...) ARENE_PROP_ASSERT(__VA_ARGS__)
32
33
/// @brief Macro to assert that a property is @c false
34
/// If the supplied property is @c true, returns a @c property_outcome with <c>status == failure</c>.
35
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
36
#define ARENE_PROP_ASSERT_FALSE(...) ARENE_PROP_ASSERT(!(__VA_ARGS__))
37
38
/// @brief Macro to discard a specific run
39
/// If the supplied property 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_
property_error.hpp
arene
base
testing
property_assertions.hpp
Generated by
1.13.2