From f30def0e0013acdf7b91616cf807e8e9ff4b56a0 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 26 Aug 2021 19:09:12 +0200 Subject: [PATCH] tests: add nmtst_connection_assert_setting() helper --- src/libnm-glib-aux/nm-test-utils.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/libnm-glib-aux/nm-test-utils.h b/src/libnm-glib-aux/nm-test-utils.h index 7b19cf12d8..2e01f3e810 100644 --- a/src/libnm-glib-aux/nm-test-utils.h +++ b/src/libnm-glib-aux/nm-test-utils.h @@ -1982,6 +1982,28 @@ nmtst_assert_route_attribute_boolean(NMIPRoute *route, const char *name, gboolea #if (defined(__NM_SIMPLE_CONNECTION_H__) && defined(__NM_SETTING_CONNECTION_H__)) \ || (defined(NM_CONNECTION_H)) +#define nmtst_connection_assert_setting(connection, gtype) \ + ({ \ + const GType _gtype = (gtype); \ + gpointer _ptr; \ + \ + _ptr = nm_connection_get_setting((connection), (_gtype)); \ + g_assert(NM_IS_SETTING(_ptr)); \ + g_assert(G_OBJECT_TYPE(_ptr) == _gtype); \ + _ptr; \ + }) + +#define nmtst_connection_assert_no_setting(connection, gtype) \ + G_STMT_START \ + { \ + const GType _gtype = (gtype); \ + gpointer _ptr; \ + \ + _ptr = nm_connection_get_setting((connection), (_gtype)); \ + g_assert(!_ptr); \ + } \ + G_STMT_END + static inline NMConnection * nmtst_clone_connection(NMConnection *connection) {