From feb71f1d714887715fd9319c91edfe71eddb4a56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 10 Nov 2020 15:33:14 +0100 Subject: 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. --- tests/gtests/testing/testing.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'tests') 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__ -- cgit v1.2.3