From: Peter Hutterer Date: Mon, 16 Sep 2024 06:30:40 +0000 (+1000) Subject: test: add macros to compare enum values X-Git-Tag: 1.27.0~89 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=151c2feae683c9c208216b43089de7d35dd90ffa;p=platform%2Fupstream%2Flibinput.git test: add macros to compare enum values This requires switching a lot of int_eq/int_ne over to enum_eq/enum_ne because the compiler doesn't infer the right type from a harcoded enum value - it just defaults to int. Part-of: --- diff --git a/test/litest.h b/test/litest.h index 0f192c9d..448faf47 100644 --- a/test/litest.h +++ b/test/litest.h @@ -192,6 +192,22 @@ litest_fail_comparison_str(const char *file, litest_abort_msg("Unexpected errno: %d (%s)", _e, strerror(_e)); \ } while(0); +#define litest_assert_comparison_enum_(a_, op_, b_) \ + do { \ + __typeof__(a_) _a = a_; \ + __typeof__(a_) _b = b_; \ + if (!((_a) op_ (_b))) \ + litest_fail_comparison_int(__FILE__, __LINE__, __func__,\ + #op_, (int)_a, (int)_b, \ + #a_, #b_); \ + } while(0) + +#define litest_assert_enum_eq(a_, b_) \ + litest_assert_comparison_enum_(a_, ==, b_) + +#define litest_assert_enum_ne(a_, b_) \ + litest_assert_comparison_enum_(a_, !=, b_) + #define litest_assert_int_eq(a_, b_) \ litest_assert_comparison_int_(a_, ==, b_)