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

Go to the source code of this file.

Detailed Description

Macros to help define test cases that are run or not depending on a generic condition.

Macro Definition Documentation

◆ CONDITIONAL_TYPED_TEST

#define CONDITIONAL_TYPED_TEST ( testsuite,
testcase,
... )
Value:
template <typename TypeParam_Internal_> \
class GTEST_TEST_CLASS_NAME_(testsuite, testcase) \
: public testsuite<TypeParam_Internal_> { \
private: \
using TestFixture = testsuite<TypeParam_Internal_>; \
using TypeParam = TypeParam_Internal_; \
\
void TestBody() override { do_conditional_test(std::integral_constant<bool, (__VA_ARGS__)>{}); } \
\
void do_conditional_test(std::false_type) { \
GTEST_SKIP() << "Disabled by condition: " << ARENE_STRINGIZE(__VA_ARGS__); \
} \
\
void do_conditional_test(std::true_type); \
}; \
/* NOLINTNEXTLINE(fuchsia-statically-constructed-objects) */ \
static const bool gtest_##testsuite##_##testcase##_registered_ = ::testing::internal::TypeParameterizedTest< \
testsuite, \
::testing::internal::TemplateSel<GTEST_TEST_CLASS_NAME_(testsuite, testcase)>, \
GTEST_TYPE_PARAMS_(testsuite)>:: \
Register( \
"", \
::testing::internal::CodeLocation(__FILE__, __LINE__), \
GTEST_STRINGIFY_(testsuite), \
GTEST_STRINGIFY_(testcase), \
0, \
::testing::internal::GenerateNames<GTEST_NAME_GENERATOR_(testsuite), GTEST_TYPE_PARAMS_(testsuite)>() \
); \
template <typename TypeParam_Internal_> \
void GTEST_TEST_CLASS_NAME_(testsuite, testcase)<TypeParam_Internal_>::do_conditional_test(std::true_type)
A helper class to represent a compile-time constant with the specified type and value....
Definition integral_constant.hpp:23
bool_constant< false > false_type
An alias for bool_constant<false>
Definition integral_constant.hpp:79
bool_constant< true > true_type
An alias for bool_constant<true>
Definition integral_constant.hpp:76
#define ARENE_STRINGIZE(...)
Definition stringize.hpp:31

Adds a type-parameterized test to a Google Test suite which is conditionally run based on the third parameter.

Parameters
SuiteNameThe name of a Google Test suite previously defined with TYPED_TEST_SUITE
TestNameThe name of this test
ConditionA condition convertible to bool which depends on TypeParam

◆ CONDITIONAL_TYPED_TEST_P

#define CONDITIONAL_TYPED_TEST_P ( SuiteName,
TestName,
... )
Value:
namespace GTEST_SUITE_NAMESPACE_(SuiteName) { \
template <typename TypeParam, bool CondOk> \
class ARENE_CONCATENATE(TestName, _Impl) \
: public SuiteName<TypeParam> { \
private: \
void TestBody() override {} \
}; \
template <typename TypeParam_> \
class ARENE_CONCATENATE(TestName, _Impl)<TypeParam_, true> : public SuiteName<TypeParam_> { \
private: \
using TestFixture = SuiteName<TypeParam_>; \
using TypeParam = TypeParam_; \
void TestBody() override; \
}; \
template <typename TypeParam> \
class TestName : public ARENE_CONCATENATE(TestName, _Impl)<TypeParam, (__VA_ARGS__)> {}; \
ARENE_MAYBE_UNUSED static bool const gtest_##TestName##_defined_ = \
GTEST_TYPED_TEST_SUITE_P_STATE_(SuiteName) \
.AddTestName(__FILE__, __LINE__, GTEST_STRINGIFY_(SuiteName), GTEST_STRINGIFY_(TestName)); \
} /* namespace GTEST_SUITE_NAMESPACE_(SuiteName) */ \
template <typename TypeParam_Internal_> \
void GTEST_SUITE_NAMESPACE_(SuiteName)::ARENE_CONCATENATE(TestName, _Impl)<TypeParam_Internal_, true>::TestBody()
#define ARENE_CONCATENATE(left, right)
Concatenate two tokens together, similar to ## except that arguments are replaced before concatenatio...
Definition concatenate.hpp:33
#define ARENE_MAYBE_UNUSED
An alias for [[maybe_unused]] , or a no-op if the attribute is not supported.
Definition maybe_unused.hpp:24

Adds a type-parameterized test to a Google Test suite which is conditionally run based on the third parameter.

Parameters
SuiteNameThe name of a Google Test suite previously defined with TYPED_TEST_SUITE_P
TestNameThe name of this test; needs to be registered later with REGISTER_TYPED_TEST_SUITE_P
ConditionA condition convertible to bool which depends on TypeParam