C/C++ API Reference
Loading...
Searching...
No Matches
Constexpr tests

Oveview

Macros

#define PW_CONSTEXPR_TEST(test_suite, test_name, ...)
 

Macro Definition Documentation

◆ PW_CONSTEXPR_TEST

#define PW_CONSTEXPR_TEST (   test_suite,
  test_name,
  ... 
)
Value:
_PW_IF_CONSTEXPR_TEST(constexpr) \
void PwConstexprTest_##test_suite##_##test_name() __VA_ARGS__ \
\
TEST(test_suite, test_name) { \
PwConstexprTest_##test_suite##_##test_name(); \
} \
\
static_assert([] { \
_PW_IF_CONSTEXPR_TEST(PwConstexprTest_##test_suite##_##test_name();) \
return true; \
}())
#define TEST(test_suite_name, test_name)
Definition: framework_backend.h:58

Defines a test that is executed both at compile time in a static_assert and as a regular GoogleTest-style TEST().

PW_CONSTEXPR_TEST works similarly to the GoogleTest TEST() macro, but has some differences.

  • All tested code must be constexpr.
  • Requires the PW_TEST_* prefixed versions of GoogleTest's EXPECT_* and ASSERT_* macros.
  • The function body is a macro argument. This has two implications:
    • The function body cannot contain preprocessor directives, such as #define. If these are needed, move them to a separate function that is called from the test.
    • The PW_CONSTEXPR_TEST macro must be terminated with ); after the test body argument.
Parameters
test_suiteGoogleTest test suite name
test_nameGoogleTest test name
...test function body surrounded by { }.