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.
This commit is contained in:
Sybren A. Stüvel
2020-11-10 15:33:14 +01:00
parent 75a2db5d97
commit feb71f1d71
4 changed files with 45 additions and 10 deletions

View File

@@ -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__