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



commit 7d65198152a6c43b8ba24459b059f54dde26ab26
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.
    
    (cherry picked from commit 77e722f9400fd2bb27709bfb1b5020a3f76d91ef)

 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 8a3008f..744bfe7 100644
--- a/properties/tests/test-import-export.c
+++ b/properties/tests/test-import-export.c
@@ -73,23 +73,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]