From aefea43380025135ac007637a3f27d8d1c2b59f1 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 14 Apr 2014 12:03:19 +0200 Subject: [PATCH] nmtst: add function nmtst_assert_str_has_substr() --- include/nm-test-utils.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/nm-test-utils.h b/include/nm-test-utils.h index a2948b6aa1..144ebfc121 100644 --- a/include/nm-test-utils.h +++ b/include/nm-test-utils.h @@ -634,6 +634,17 @@ __define_nmtst_static(03, 1024) memcpy(&x, __nmtst_swap_temp, sizeof(x)); \ } G_STMT_END +#define nmtst_assert_str_has_substr(str, substr) \ + G_STMT_START { \ + const char *__str = (str); \ + const char *__substr = (substr); \ + \ + g_assert (__str); \ + g_assert (__substr); \ + if (strstr (__str, __substr) == NULL) \ + g_error ("%s:%d: Expects \"%s\" but got \"%s\"", __FILE__, __LINE__, __substr, __str); \ + } G_STMT_END + inline static guint32 nmtst_inet4_from_string (const char *str) {