mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-02-03 21:40:40 +01:00
test: add litest_assert_strv_substring
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1226>
This commit is contained in:
parent
a0a2416d11
commit
471912aacf
2 changed files with 36 additions and 0 deletions
|
|
@ -4840,6 +4840,32 @@ litest_logcapture_remove(struct libinput *li, struct litest_logcapture *capture)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
#define litest_with_logcapture(li_, capture_) \
|
||||
for (struct litest_logcapture *capture_ = litest_logcapture_setup(li_); \
|
||||
capture_ != NULL; \
|
||||
capture_ = litest_logcapture_remove(li_, capture_))
|
||||
|
||||
void
|
||||
_litest_assert_strv_substring(char **strv,
|
||||
char *substring,
|
||||
const char *file,
|
||||
const char *func,
|
||||
int line)
|
||||
{
|
||||
if (!strv) {
|
||||
_litest_abort_msg(file, line, func,
|
||||
"Expected substring '%s' but strv is NULL", substring);
|
||||
}
|
||||
|
||||
bool found = strv_find_substring(strv, substring, NULL);
|
||||
if (!found) {
|
||||
_autofree_ char *strv_str = strv_join(strv, "', '");
|
||||
_litest_abort_msg(file, line, func,
|
||||
"Expected substring '%s' not found in strv: ['%s']",
|
||||
substring, strv_str);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
litest_push_event_frame(struct litest_device *dev)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -398,6 +398,16 @@ litest_fail_comparison_str(const char *file,
|
|||
#define litest_assert_double_ge(a_, b_)\
|
||||
litest_assert_double_ge_epsilon((a_), (b_),LITEST_DEFAULT_EPSILON)
|
||||
|
||||
void
|
||||
_litest_assert_strv_substring(char **strv,
|
||||
char *substring,
|
||||
const char *file,
|
||||
const char *func,
|
||||
int line);
|
||||
|
||||
#define litest_assert_strv_substring(strv_, substring_) \
|
||||
_litest_assert_strv_substring(strv_, substring_, __FILE__, __func__, __LINE__)
|
||||
|
||||
void litest_backtrace(const char *func);
|
||||
|
||||
enum litest_device_type {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue