diff options
author | Sybren A. Stüvel <sybren@blender.org> | 2020-11-10 17:33:14 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@blender.org> | 2020-11-10 17:36:21 +0300 |
commit | feb71f1d714887715fd9319c91edfe71eddb4a56 (patch) | |
tree | ccd842a60aab63b5aa8c04ae86fd2b130c13318c /tests | |
parent | 75a2db5d9742a46ec4662fe85765f27b6f5e0f95 (diff) |
Animation: Expand unit tests for `BKE_fcurve_active_keyframe_index()`
Expand unit test for `BKE_fcurve_active_keyframe_index()` to test edge
cases better.
This also introduces a new test macro `EXPECT_BLI_ASSERT()`, which can be
used to test that an assertion fails successfully.
No functional changes to actual Blender code.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/gtests/testing/testing.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/gtests/testing/testing.h b/tests/gtests/testing/testing.h index 34928035b7d..8136a93314e 100644 --- a/tests/gtests/testing/testing.h +++ b/tests/gtests/testing/testing.h @@ -137,4 +137,22 @@ inline void EXPECT_EQ_ARRAY_ND(const T *expected, const T *actual, const size_t } } +#ifdef _WIN32 +# define ABORT_PREDICATE ::testing::ExitedWithCode(3) +#else +# define ABORT_PREDICATE ::testing::KilledBySignal(SIGABRT) +#endif + +/* Test macro for when BLI_assert() is expected to fail. + * Note that the EXPECT_BLI_ASSERT macro is a no-op, unless used in a debug build with + * WITH_ASSERT_ABORT=ON. */ +#if defined(WITH_ASSERT_ABORT) && !defined(NDEBUG) +/* EXPECT_EXIT() is used as that's the only exit-expecting function in GTest that allows us to + * check for SIGABRT. */ +# define EXPECT_BLI_ASSERT(function_call, expect_message) \ + EXPECT_EXIT(function_call, ABORT_PREDICATE, expect_message) +#else +# define EXPECT_BLI_ASSERT(function_call, expect_message) function_call +#endif + #endif // __BLENDER_TESTING_H__ |