mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-05-05 01:48:03 +02:00
test: add litest_assert_strv_no_substring
To verify a strv does *not* include a given substring Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1284>
This commit is contained in:
parent
ce85ee7d35
commit
6dfd72dc03
2 changed files with 35 additions and 0 deletions
|
|
@ -4889,6 +4889,31 @@ _litest_assert_strv_substring(char **strv,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_litest_assert_strv_no_substring(char **strv,
|
||||||
|
char *substring,
|
||||||
|
const char *file,
|
||||||
|
const char *func,
|
||||||
|
int line)
|
||||||
|
{
|
||||||
|
if (!strv)
|
||||||
|
return;
|
||||||
|
|
||||||
|
size_t index;
|
||||||
|
bool found = strv_find_substring(strv, substring, &index);
|
||||||
|
if (found) {
|
||||||
|
_autofree_ char *strv_str = strv_join(strv, "', '");
|
||||||
|
_litest_abort_msg(
|
||||||
|
file,
|
||||||
|
line,
|
||||||
|
func,
|
||||||
|
"Unexpected substring '%s' present at index %zd in strv: ['%s']",
|
||||||
|
substring,
|
||||||
|
index,
|
||||||
|
strv_str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
litest_push_event_frame(struct litest_device *dev)
|
litest_push_event_frame(struct litest_device *dev)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -408,6 +408,16 @@ _litest_assert_strv_substring(char **strv,
|
||||||
#define litest_assert_strv_substring(strv_, substring_) \
|
#define litest_assert_strv_substring(strv_, substring_) \
|
||||||
_litest_assert_strv_substring(strv_, substring_, __FILE__, __func__, __LINE__)
|
_litest_assert_strv_substring(strv_, substring_, __FILE__, __func__, __LINE__)
|
||||||
|
|
||||||
|
void
|
||||||
|
_litest_assert_strv_no_substring(char **strv,
|
||||||
|
char *substring,
|
||||||
|
const char *file,
|
||||||
|
const char *func,
|
||||||
|
int line);
|
||||||
|
|
||||||
|
#define litest_assert_strv_no_substring(strv_, substring_) \
|
||||||
|
_litest_assert_strv_no_substring(strv_, substring_, __FILE__, __func__, __LINE__)
|
||||||
|
|
||||||
void
|
void
|
||||||
litest_backtrace(const char *func);
|
litest_backtrace(const char *func);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue