summaryrefslogtreecommitdiff
path: root/glib/gtestutils.h
diff options
context:
space:
mode:
authorPaolo Borelli <pborelli@gnome.org>2015-01-13 13:19:58 +0100
committerPaolo Borelli <pborelli@gnome.org>2015-01-14 16:21:00 +0100
commitbe0c9e507a59aec5655a1c109adb3b0a588e2502 (patch)
tree1a414154e0a7e48503d375fa86b64ede78a2d872 /glib/gtestutils.h
parent70e2630f5aa7045cafda2ede0d25f325adc37152 (diff)
downloadglib-be0c9e507a59aec5655a1c109adb3b0a588e2502.tar.gz
Use G_STMT_START/END in gtestutils
Diffstat (limited to 'glib/gtestutils.h')
-rw-r--r--glib/gtestutils.h72
1 files changed, 45 insertions, 27 deletions
diff --git a/glib/gtestutils.h b/glib/gtestutils.h
index 95e6de18b..6e1d78674 100644
--- a/glib/gtestutils.h
+++ b/glib/gtestutils.h
@@ -38,57 +38,75 @@ typedef void (*GTestFixtureFunc) (gpointer fixture,
gconstpointer user_data);
/* assertion API */
-#define g_assert_cmpstr(s1, cmp, s2) do { const char *__s1 = (s1), *__s2 = (s2); \
+#define g_assert_cmpstr(s1, cmp, s2) G_STMT_START { \
+ const char *__s1 = (s1), *__s2 = (s2); \
if (g_strcmp0 (__s1, __s2) cmp 0) ; else \
g_assertion_message_cmpstr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
- #s1 " " #cmp " " #s2, __s1, #cmp, __s2); } while (0)
-#define g_assert_cmpint(n1, cmp, n2) do { gint64 __n1 = (n1), __n2 = (n2); \
+ #s1 " " #cmp " " #s2, __s1, #cmp, __s2); \
+ } G_STMT_END
+#define g_assert_cmpint(n1, cmp, n2) G_STMT_START { \
+ gint64 __n1 = (n1), __n2 = (n2); \
if (__n1 cmp __n2) ; else \
g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
- #n1 " " #cmp " " #n2, __n1, #cmp, __n2, 'i'); } while (0)
-#define g_assert_cmpuint(n1, cmp, n2) do { guint64 __n1 = (n1), __n2 = (n2); \
+ #n1 " " #cmp " " #n2, __n1, #cmp, __n2, 'i'); \
+ } G_STMT_END
+#define g_assert_cmpuint(n1, cmp, n2) G_STMT_START { \
+ guint64 __n1 = (n1), __n2 = (n2); \
if (__n1 cmp __n2) ; else \
g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
- #n1 " " #cmp " " #n2, __n1, #cmp, __n2, 'i'); } while (0)
-#define g_assert_cmphex(n1, cmp, n2) do { guint64 __n1 = (n1), __n2 = (n2); \
+ #n1 " " #cmp " " #n2, __n1, #cmp, __n2, 'i'); \
+ } G_STMT_END
+#define g_assert_cmphex(n1, cmp, n2) G_STMT_START {\
+ guint64 __n1 = (n1), __n2 = (n2); \
if (__n1 cmp __n2) ; else \
g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
- #n1 " " #cmp " " #n2, __n1, #cmp, __n2, 'x'); } while (0)
-#define g_assert_cmpfloat(n1,cmp,n2) do { long double __n1 = (n1), __n2 = (n2); \
+ #n1 " " #cmp " " #n2, __n1, #cmp, __n2, 'x'); \
+ } G_STMT_END
+#define g_assert_cmpfloat(n1,cmp,n2) G_STMT_START { \
+ long double __n1 = (n1), __n2 = (n2); \
if (__n1 cmp __n2) ; else \
g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
- #n1 " " #cmp " " #n2, __n1, #cmp, __n2, 'f'); } while (0)
-#define g_assert_no_error(err) do { if (err) \
+ #n1 " " #cmp " " #n2, __n1, #cmp, __n2, 'f'); \
+ } G_STMT_END
+#define g_assert_no_error(err) G_STMT_START { \
+ if (err) \
g_assertion_message_error (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
- #err, err, 0, 0); } while (0)
-#define g_assert_error(err, dom, c) do { if (!err || (err)->domain != dom || (err)->code != c) \
+ #err, err, 0, 0); \
+ } G_STMT_END
+#define g_assert_error(err, dom, c) G_STMT_START { \
+ if (!err || (err)->domain != dom || (err)->code != c) \
g_assertion_message_error (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
- #err, err, dom, c); } while (0)
-#define g_assert_true(expr) do { if G_LIKELY (expr) ; else \
+ #err, err, dom, c); \
+ } G_STMT_END
+#define g_assert_true(expr) G_STMT_START { \
+ if G_LIKELY (expr) ; else \
g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
"'" #expr "' should be TRUE"); \
- } while (0)
-#define g_assert_false(expr) do { if G_LIKELY (!(expr)) ; else \
+ } G_STMT_END
+#define g_assert_false(expr) G_STMT_START { \
+ if G_LIKELY (!(expr)) ; else \
g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
"'" #expr "' should be FALSE"); \
- } while (0)
-#define g_assert_null(expr) do { if G_LIKELY ((expr) == NULL) ; else \
+ } G_STMT_END
+#define g_assert_null(expr) G_STMT_START { if G_LIKELY ((expr) == NULL) ; else \
g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
"'" #expr "' should be NULL"); \
- } while (0)
-#define g_assert_nonnull(expr) do { if G_LIKELY ((expr) != NULL) ; else \
+ } G_STMT_END
+#define g_assert_nonnull(expr) G_STMT_START { \
+ if G_LIKELY ((expr) != NULL) ; else \
g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
"'" #expr "' should not be NULL"); \
- } while (0)
+ } G_STMT_END
#ifdef G_DISABLE_ASSERT
-#define g_assert_not_reached() do { (void) 0; } while (0)
-#define g_assert(expr) do { (void) 0; } while (0)
+#define g_assert_not_reached() G_STMT_START { (void) 0; } G_STMT_END
+#define g_assert(expr) G_STMT_START { (void) 0; } G_STMT_END
#else /* !G_DISABLE_ASSERT */
-#define g_assert_not_reached() do { g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, NULL); } while (0)
-#define g_assert(expr) do { if G_LIKELY (expr) ; else \
+#define g_assert_not_reached() G_STMT_START { g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, NULL); } G_STMT_END
+#define g_assert(expr) G_STMT_START { \
+ if G_LIKELY (expr) ; else \
g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
#expr); \
- } while (0)
+ } G_STMT_END
#endif /* !G_DISABLE_ASSERT */
GLIB_AVAILABLE_IN_ALL