shared: add weston_assert_false()

Complement to weston_assert_true(), to avoid having to use !.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This commit is contained in:
Pekka Paalanen 2024-05-02 15:04:46 +03:00 committed by Pekka Paalanen
parent c310516d1d
commit cd622900ee
3 changed files with 10 additions and 1 deletions

View File

@ -7662,7 +7662,7 @@ WL_EXPORT void
weston_output_set_eotf_mode(struct weston_output *output,
enum weston_eotf_mode eotf_mode)
{
assert(!output->enabled);
weston_assert_false(output->compositor, output->enabled);
output->eotf_mode = eotf_mode;
}

View File

@ -85,6 +85,9 @@ do { \
#define weston_assert_true(compositor, a) \
weston_assert_(compositor, a, true, bool, "%d", ==)
#define weston_assert_false(compositor, a) \
weston_assert_(compositor, a, false, bool, "%d", ==)
#define weston_assert_ptr(compositor, a) \
weston_assert_(compositor, a, NULL, const void *, "%p", !=)

View File

@ -86,6 +86,12 @@ TEST(asserts)
ret = weston_assert_true(compositor, true);
abort_if_not(ret);
ret = weston_assert_false(compositor, true);
abort_if_not(ret == false);
ret = weston_assert_false(compositor, false);
abort_if_not(ret);
ret = weston_assert_true(compositor, true && false);
abort_if_not(ret == false);