Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
conditional_assertions.hpp File Reference

Go to the source code of this file.

Detailed Description

Macros to help define assertions that are conditionally static depending on the test's type parameter.

Macro Definition Documentation

◆ ARENE_INSTANTIATE_TESTS

#define ARENE_INSTANTIATE_TESTS ( Prefix,
SuiteBaseName,
Types )
Value:
namespace { \
/* NOLINTNEXTLINE(google-build-using-namespace) Google Test puts a lot of names in this namespace */ \
using namespace ::arene::base::testing; \
ARENE_INSTANTIATE_TYPED_TEST_SUITE_P(Prefix, SuiteBaseName, Test, Types); \
ARENE_INSTANTIATE_TYPED_TEST_SUITE_P(Prefix, SuiteBaseName, DeathTest, Types); \
} /* namespace */ \
static_assert(true, "Dummy static assert to absorb the semicolon after invoking the macro")
Definition customization.hpp:36

Instantiate the Arene Base parameterized tests for the given suite with the given types. Always instantiates the general and death tests, and also the constexpr-only tests for compatible types.

Parameters
PrefixThe prefix to use for this instantiation of the tests; passed directly to Google Test
SuiteBaseNameThe name of the suite to instantiate without the Test , DeathTest , etc. at the end
TypesThe name of a Google Test type list containing the types for which SuiteName should be instantiated

◆ ARENE_INSTANTIATE_TYPED_TEST_SUITE_P

#define ARENE_INSTANTIATE_TYPED_TEST_SUITE_P ( Prefix,
SuiteBaseName,
SuiteSuffix,
Types )
Value:
INSTANTIATE_TYPED_TEST_SUITE_P(Prefix, SuiteBaseName##SuiteSuffix, Types, )

Call the Google Test suite instantiation macro with the given arguments This exists to avoid having more than one ## in a single macro, since concatenation is needed for Google Test The extra comma in the Google macro is part of its undocumented name generator API, which we don't use.

Parameters
PrefixThe prefix to use for this instantiation of the tests; passed directly to Google Test
SuiteBaseNameThe name of the suite to instantiate without the Test , DeathTest , etc. at the end
SuiteSuffixThe suffix which is combined with SuiteBaseName to create the Google Test suite name
TypesThe name of a Google Test type list containing the types for which SuiteName should be instantiated

◆ COND_STATIC_ASSERT_BINARY

#define COND_STATIC_ASSERT_BINARY ( left_arg,
right_arg,
assertion_type )
Value:
struct ARENE_CONCATENATE(condition_impl_, __LINE__) { \
constexpr static auto left() -> decltype(auto) { return left_arg; } \
constexpr static auto right() -> decltype(auto) { return right_arg; } \
}; \
static_cast<void>((ARENE_CONDITIONAL_ASSERTER((assertion_type))::do_assert()))
#define ARENE_CONCATENATE(left, right)
Concatenate two tokens together, similar to ## except that arguments are replaced before concatenatio...
Definition concatenate.hpp:33

Call a Google Test binary assertion macro at runtime, and statically if TypeParam is compatible.

Parameters
left_argLeft half of the assertion; should not contain references to non-constexpr variables
right_argRight half of the assertion; should not contain references to non-constexpr variables
assertion_typeThe ::arene::base::testing::gtest_operation value specifying the assertion to use

◆ COND_STATIC_ASSERT_EQ

#define COND_STATIC_ASSERT_EQ ( left_arg,
right_arg )
Value:
COND_STATIC_ASSERT_BINARY(left_arg, right_arg, ::arene::base::testing::gtest_operation::assert_eq)
#define COND_STATIC_ASSERT_BINARY(left_arg, right_arg, assertion_type)
Call a Google Test binary assertion macro at runtime, and statically if TypeParam is compatible.
Definition conditional_assertions.hpp:57

Call Google Test ASSERT_EQ at runtime, and also statically if TypeParam is compatible.

Parameters
left_argLeft half of the assertion; should not contain references to non-constexpr variables
right_argRight half of the assertion; should not contain references to non-constexpr variables

◆ COND_STATIC_ASSERT_FALSE

#define COND_STATIC_ASSERT_FALSE ( ...)
Value:
COND_STATIC_ASSERT_UNARY(::arene::base::testing::gtest_operation::assert_false, __VA_ARGS__)
#define COND_STATIC_ASSERT_UNARY(assertion_type,...)
Call a Google Test unary assertion macro at runtime, and statically if TypeParam is compatible.
Definition conditional_assertions.hpp:37

Call Google Test ASSERT_FALSE at runtime, and also statically if TypeParam is compatible.

Parameters
conditionThe condition to assert as false; should not contain references to non-constexpr variables

◆ COND_STATIC_ASSERT_GE

#define COND_STATIC_ASSERT_GE ( left_arg,
right_arg )
Value:
COND_STATIC_ASSERT_BINARY(left_arg, right_arg, ::arene::base::testing::gtest_operation::assert_ge)

Call Google Test ASSERT_GE at runtime, and also statically if TypeParam is compatible.

Parameters
left_argLeft half of the assertion; should not contain references to non-constexpr variables
right_argRight half of the assertion; should not contain references to non-constexpr variables

◆ COND_STATIC_ASSERT_GT

#define COND_STATIC_ASSERT_GT ( left_arg,
right_arg )
Value:
COND_STATIC_ASSERT_BINARY(left_arg, right_arg, ::arene::base::testing::gtest_operation::assert_gt)

Call Google Test ASSERT_GT at runtime, and also statically if TypeParam is compatible.

Parameters
left_argLeft half of the assertion; should not contain references to non-constexpr variables
right_argRight half of the assertion; should not contain references to non-constexpr variables

◆ COND_STATIC_ASSERT_LE

#define COND_STATIC_ASSERT_LE ( left_arg,
right_arg )
Value:
COND_STATIC_ASSERT_BINARY(left_arg, right_arg, ::arene::base::testing::gtest_operation::assert_le)

Call Google Test ASSERT_LE at runtime, and also statically if TypeParam is compatible.

Parameters
left_argLeft half of the assertion; should not contain references to non-constexpr variables
right_argRight half of the assertion; should not contain references to non-constexpr variables

◆ COND_STATIC_ASSERT_LT

#define COND_STATIC_ASSERT_LT ( left_arg,
right_arg )
Value:
COND_STATIC_ASSERT_BINARY(left_arg, right_arg, ::arene::base::testing::gtest_operation::assert_lt)

Call Google Test ASSERT_LT at runtime, and also statically if TypeParam is compatible.

Parameters
left_argLeft half of the assertion; should not contain references to non-constexpr variables
right_argRight half of the assertion; should not contain references to non-constexpr variables

◆ COND_STATIC_ASSERT_NE

#define COND_STATIC_ASSERT_NE ( left_arg,
right_arg )
Value:
COND_STATIC_ASSERT_BINARY(left_arg, right_arg, ::arene::base::testing::gtest_operation::assert_ne)

Call Google Test ASSERT_NE at runtime, and also statically if TypeParam is compatible.

Parameters
left_argLeft half of the assertion; should not contain references to non-constexpr variables
right_argRight half of the assertion; should not contain references to non-constexpr variables

◆ COND_STATIC_ASSERT_TRUE

#define COND_STATIC_ASSERT_TRUE ( ...)
Value:
COND_STATIC_ASSERT_UNARY(::arene::base::testing::gtest_operation::assert_true, __VA_ARGS__)

Call Google Test ASSERT_TRUE at runtime, and also statically if TypeParam is compatible.

Parameters
conditionThe condition to assert as true; should not contain references to non-constexpr variables

◆ COND_STATIC_ASSERT_UNARY

#define COND_STATIC_ASSERT_UNARY ( assertion_type,
... )
Value:
struct ARENE_CONCATENATE(condition_impl_, __LINE__) { \
constexpr static auto body() -> decltype(auto) { return __VA_ARGS__; } \
}; \
static_cast<void>((ARENE_CONDITIONAL_ASSERTER((assertion_type))::do_assert()))

Call a Google Test unary assertion macro at runtime, and statically if TypeParam is compatible.

Parameters
conditionThe condition to assert; should not contain reference to non-constexpr variables
assertion_typeThe ::arene::base::testing::gtest_operation value specifying the assertion to use