glib-aux: convert nmtst_assert_setting_verifies() to a macro

The macro has the advantage, that it preserves the file and line number
from the caller.
This commit is contained in:
Thomas Haller
2024-01-09 10:18:57 +01:00
parent 9360ed9a7a
commit 81bfce7c47

View File

@@ -2566,20 +2566,21 @@ nmtst_assert_connection_unnormalizable(NMConnection *con,
g_clear_error(&error); g_clear_error(&error);
} }
static inline void #define nmtst_assert_setting_verifies(setting) \
nmtst_assert_setting_verifies(NMSetting *setting) G_STMT_START \
{ { \
/* assert that the setting verifies without an error */ NMSetting *_setting = NM_SETTING(setting); \
GError *_error = NULL; \
GError *error = NULL; gboolean _success; \
gboolean success; \
/* assert that the setting verifies without an error */ \
g_assert(NM_IS_SETTING(setting)); \
g_assert(NM_IS_SETTING(_setting)); \
success = nm_setting_verify(setting, NULL, &error); \
g_assert_no_error(error); _success = nm_setting_verify(_setting, NULL, &_error); \
g_assert(success); nmtst_assert_success(_success, _error); \
} } \
G_STMT_END
#if defined(__NM_SIMPLE_CONNECTION_H__) && NM_CHECK_VERSION(1, 10, 0) \ #if defined(__NM_SIMPLE_CONNECTION_H__) && NM_CHECK_VERSION(1, 10, 0) \
&& (!defined(NM_VERSION_MAX_ALLOWED) || NM_VERSION_MAX_ALLOWED >= NM_VERSION_1_10) && (!defined(NM_VERSION_MAX_ALLOWED) || NM_VERSION_MAX_ALLOWED >= NM_VERSION_1_10)