test: add litest_assert_str_in/not_in() helpers

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1204>
This commit is contained in:
Peter Hutterer 2025-05-07 15:55:23 +10:00 committed by Marge Bot
parent 14c4667980
commit ea50e1a92c
2 changed files with 23 additions and 4 deletions

View file

@ -285,6 +285,28 @@ litest_fail_comparison_str(const char *file,
_a, _b); \
} while(0)
#define litest_assert_str_in(needle_, haystack_) \
do { \
const char *_needle = needle_; \
const char *_haystack = haystack_; \
if (!strstr(_haystack, _needle)) \
litest_fail_comparison_str(__FILE__, __LINE__, __func__,\
"'" #needle_ "' in: '" #haystack_ "'", \
"in", \
_needle, _haystack); \
} while(0)
#define litest_needlessert_str_not_in(needle_, haystack_) \
do { \
const char *_needle = needle_; \
const char *_haystack = haystack_; \
if (!strstr(_haystack, _needle)) \
litest_fail_comparison_str(__FILE__, __LINE__, __func__,\
"'" #needle_ "' not in: '" #haystack_ "'", \
"not in", \
_needle, _haystack); \
} while(0)
#define LITEST_DEFAULT_EPSILON 0.001
#define litest_assert_double_eq_epsilon(a_, b_, epsilon_)\

View file

@ -142,13 +142,10 @@ axisrange_warning_log_handler(struct libinput *libinput,
const char *format,
va_list args)
{
const char *substr;
axisrange_log_handler_called++;
litest_assert_notnull(format);
substr = strstr(format, "is outside expected range");
litest_assert_notnull(substr);
litest_assert_str_in("is outside expected range", format);
}
START_TEST(log_axisrange_warning)