glib-aux/tests: add nmtst_assert_strv() helper macro

This commit is contained in:
Thomas Haller 2022-01-03 08:19:46 +01:00
parent c810fe24fe
commit f924b4382e
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -182,6 +182,23 @@
} \
G_STMT_END
#define nmtst_assert_strv(strv, ...) \
G_STMT_START \
{ \
const char *const *const _strv = (strv); \
const char *const _exp[] = {__VA_ARGS__, NULL}; \
const gsize _n = G_N_ELEMENTS(_exp) - 1; \
gsize _i; \
\
g_assert(_n == NM_NARG(__VA_ARGS__)); \
g_assert(_strv); \
for (_i = 0; _i < _n; _i++) { \
g_assert(_exp[_i]); \
g_assert_cmpstr(_strv[_i], ==, _exp[_i]); \
} \
} \
G_STMT_END
/*****************************************************************************/
/* Our nm-error error numbers use negative values to signal failure.