![]() |
Arene Base
Fundamental Utilities For Safety Critical C++
|
Arene Base provides a unit testing support library, compatible with gtest, which provides CONSTEXPR_TEST and CONSTEXPR_TYPED_TEST macros which mirror the TEST and TYPED_TEST macros defined by GoogleTest. These macros provide an alternative approach to using STATIC_ASSERT_XXXmacros when compile-time tests. Additionally, this support library provides CONSTEXPR_ASSERT, an assertion macro that replaces ones from GoogleTest.
The constexpr test macros invoke the function body at compile-time. Function bodies are also invoked at runtime to allow generation of coverage.
Here is a simple example of changing a runtime evaluated test using TEST to a compile-time test using CONSTEXPR_TEST.
GoogleTest assertion macros (e.g. ASSERT_EQ) cannot be used within a CONSTEXPR_TEST. Instead, a single CONSTEXPR_ASSERT assertion macro is available.
Use of CONSTEXPR_TYPED_TEST is analogous to CONSTEXPR_TEST.
As the test bodies of CONSTEXPR_TEST and CONSTEXPR_TYPED_TEST must be invocable at compile-time, they cannot refer to non-constexpr values. This includes the this pointer to the test fixture.