5#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_TESTING_GTEST_WITH_GTEST_CONSTEXPR_TEST_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_TESTING_GTEST_WITH_GTEST_CONSTEXPR_TEST_HPP_
11#include <gtest/gtest.h>
14#include "arene/base/compiler_support/preprocessor.hpp"
15#include "arene/base/stdlib_choice/integral_constant.hpp"
31template <
class TestTag>
40 static_assert((test_impl(TestTag{}),
true),
"test body not invocable in a constant expression");
49template <
class TestTag,
bool RunInConstexpr>
54
55 test_impl<
void>(TestTag{});
56 static_cast<
void>(std::integral_constant<
bool, (test_impl<
void>(TestTag{}),
true)>{});
62template <
class TestTag>
89#define TESTCASE_TYPE_NAME(testsuite, testcase) testsuite##_##testcase
95#define TESTCASE_TAG_NAME(testsuite, testcase) testsuite##_##testcase##_tag
120#define CONSTEXPR_TEST(testsuite, testcase)
124 static ::testing::TestInfo const* const test_info_;
128 ::testing::TestInfo const* const TESTCASE_TAG_NAME(testsuite, testcase)::test_info_ = ::testing::RegisterTest(
129 ARENE_STRINGIZE(testsuite),
130 ARENE_STRINGIZE(testcase),
136 return static_cast<::testing::Test*>(
137 new ::arene::base::testing::internal::constexpr_test<TESTCASE_TAG_NAME(testsuite, testcase)>{}
175#define CONDITIONALLY_CONSTEXPR_TEST(testsuite, testcase, ...)
179 static ::testing::TestInfo const* const test_info_;
183 ::testing::TestInfo const* const TESTCASE_TAG_NAME(testsuite, testcase)::test_info_ = ::testing::RegisterTest(
184 ARENE_STRINGIZE(testsuite),
185 ARENE_STRINGIZE(testcase),
191 return static_cast<::testing::Test*>(
192 new ::arene::base::testing::internal::
193 conditionally_constexpr_test<TESTCASE_TAG_NAME(testsuite, testcase), (__VA_ARGS__)>{}
199
200
228#define CONSTEXPR_TYPED_TEST(testsuite, testcase)
233 TYPED_TEST(testsuite, testcase) {
234 using ::arene::base::testing::internal::test_impl;
236 static_assert((test_impl<TypeParam>(tag_type{}), true), "test body not invocable in a constant expression");
237 test_impl<TypeParam>(tag_type{});
240 template <class TypeParam>
278#define CONDITIONALLY_CONSTEXPR_TYPED_TEST(testsuite, testcase, ...)
283 template <class TypeParam>
285 maybe_do_test_in_constexpr(TESTCASE_TAG_NAME(testsuite, testcase) tag, std::integral_constant<bool, true>) {
286 using ::arene::base::testing::internal::test_impl;
288 static_cast<void>(std::integral_constant<bool, (test_impl<TypeParam>(tag), true)>{});
291 template <class TypeParam>
293 maybe_do_test_in_constexpr(TESTCASE_TAG_NAME(testsuite, testcase), std::integral_constant<bool, false>) {}
295 TYPED_TEST(testsuite, testcase) {
296 using ::arene::base::testing::internal::test_impl;
299
300 test_impl<TypeParam>(tag_type{});
301 maybe_do_test_in_constexpr<TypeParam>(tag_type{}, std::integral_constant<bool, (__VA_ARGS__)>{});
304 template <class TypeParam>
333#define CONDITIONAL_CONSTEXPR_TYPED_TEST(testsuite, testcase, ...)
338 template <class TypeParam>
339 constexpr void maybe_do_test(TESTCASE_TAG_NAME(testsuite, testcase) tag, std::integral_constant<bool, true>) {
340 using ::arene::base::testing::internal::test_impl;
343 static_cast<void>(std::integral_constant<bool, (test_impl<TypeParam>(tag), true)>{});
344 test_impl<TypeParam>(tag);
347 template <class TypeParam>
348 constexpr void maybe_do_test(TESTCASE_TAG_NAME(testsuite, testcase), std::integral_constant<bool, false>) {
349 GTEST_SKIP() << "Disabled by condition: " << ARENE_STRINGIZE(__VA_ARGS__);
352 TYPED_TEST(testsuite, testcase) {
354 maybe_do_test<TypeParam>(tag_type{}, std::integral_constant<bool, (__VA_ARGS__)>{});
357 template <class TypeParam>
373#define CONSTEXPR_ASSERT(...)
374 if (not(__VA_ARGS__)) {
auto TestBody() -> void override
Definition constexpr_test.hpp:65
GoogleTest test type used to conditionally invoke tests at compile-time.
Definition constexpr_test.hpp:50
auto TestBody() -> void override
Definition constexpr_test.hpp:52
GoogleTest test type used invoke tests at compile-time.
Definition constexpr_test.hpp:32
auto TestBody() -> void override
test implementation function
Definition constexpr_test.hpp:39
Definition constexpr_test.hpp:21
void test_impl()=delete
dummy function declaration to allow unqualified lookup
Definition customization.hpp:36
Definition array_exceptions_disabled.cpp:11
Copyright 2026, Toyota Motor Corporation.
Definition array_exceptions_disabled.cpp:10
#define TESTCASE_TAG_NAME(testsuite, testcase)
defines the name of a tag associated with a testcase
Definition constexpr_test.hpp:95
#define TESTCASE_TYPE_NAME(testsuite, testcase)
defines the name of a type associated with a testcase
Definition constexpr_test.hpp:89
#define CONSTEXPR_ASSERT(...)
asserts that the argument is true
Definition constexpr_test.hpp:370