[network-manager-openvpn] properties/tests: make _check_item() and _check_secret() macros



commit 77e722f9400fd2bb27709bfb1b5020a3f76d91ef
Author: Thomas Haller <thaller redhat com>
Date:   Fri May 13 16:52:26 2016 +0200

    properties/tests: make _check_item() and _check_secret() macros
    
    These helpers assert for expected settings, but when implemented as functions,
    an assertion failure does show the proper __FILE__:__LINE__ of where
    the error originally happens.
    
    Reimplement them as macros.

 properties/tests/test-import-export.c |   32 +++++++++++++++-----------------
 1 files changed, 15 insertions(+), 17 deletions(-)
---
diff --git a/properties/tests/test-import-export.c b/properties/tests/test-import-export.c
index 0adf554..99657e3 100644
--- a/properties/tests/test-import-export.c
+++ b/properties/tests/test-import-export.c
@@ -74,23 +74,21 @@ get_basic_connection (NMVpnEditorPlugin *plugin,
        return connection;
 }
 
-static void
-_check_item (NMSettingVpn *s_vpn,
-             const char *item,
-             const char *expected)
-{
-       g_assert (s_vpn);
-       g_assert_cmpstr (nm_setting_vpn_get_data_item (s_vpn, item), ==, expected);
-}
-
-static void
-_check_secret (NMSettingVpn *s_vpn,
-               const char *item,
-               const char *expected)
-{
-       g_assert (s_vpn);
-       g_assert_cmpstr (nm_setting_vpn_get_secret (s_vpn, item), ==, expected);
-}
+#define _check_item(s_vpn, item, expected) \
+       G_STMT_START { \
+               NMSettingVpn *_s_vpn = (s_vpn); \
+               \
+               g_assert (_s_vpn); \
+               g_assert_cmpstr (nm_setting_vpn_get_data_item (_s_vpn, (item)), ==, (expected)); \
+       } G_STMT_END
+
+#define _check_secret(s_vpn, item, expected) \
+       G_STMT_START { \
+               NMSettingVpn *_s_vpn = (s_vpn); \
+               \
+               g_assert (_s_vpn); \
+               g_assert_cmpstr (nm_setting_vpn_get_secret (_s_vpn, (item)), ==, (expected)); \
+       } G_STMT_END
 
 /*****************************************************************************/
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]