mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-14 16:26:17 +01:00
Use G_STMT_START/END in gtestutils
This commit is contained in:
parent
70e2630f5a
commit
be0c9e507a
@ -38,57 +38,75 @@ typedef void (*GTestFixtureFunc) (gpointer fixture,
|
|||||||
gconstpointer user_data);
|
gconstpointer user_data);
|
||||||
|
|
||||||
/* assertion API */
|
/* 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 \
|
if (g_strcmp0 (__s1, __s2) cmp 0) ; else \
|
||||||
g_assertion_message_cmpstr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
|
g_assertion_message_cmpstr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
|
||||||
#s1 " " #cmp " " #s2, __s1, #cmp, __s2); } while (0)
|
#s1 " " #cmp " " #s2, __s1, #cmp, __s2); \
|
||||||
#define g_assert_cmpint(n1, cmp, n2) do { gint64 __n1 = (n1), __n2 = (n2); \
|
} G_STMT_END
|
||||||
|
#define g_assert_cmpint(n1, cmp, n2) G_STMT_START { \
|
||||||
|
gint64 __n1 = (n1), __n2 = (n2); \
|
||||||
if (__n1 cmp __n2) ; else \
|
if (__n1 cmp __n2) ; else \
|
||||||
g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
|
g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
|
||||||
#n1 " " #cmp " " #n2, __n1, #cmp, __n2, 'i'); } while (0)
|
#n1 " " #cmp " " #n2, __n1, #cmp, __n2, 'i'); \
|
||||||
#define g_assert_cmpuint(n1, cmp, n2) do { guint64 __n1 = (n1), __n2 = (n2); \
|
} G_STMT_END
|
||||||
|
#define g_assert_cmpuint(n1, cmp, n2) G_STMT_START { \
|
||||||
|
guint64 __n1 = (n1), __n2 = (n2); \
|
||||||
if (__n1 cmp __n2) ; else \
|
if (__n1 cmp __n2) ; else \
|
||||||
g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
|
g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
|
||||||
#n1 " " #cmp " " #n2, __n1, #cmp, __n2, 'i'); } while (0)
|
#n1 " " #cmp " " #n2, __n1, #cmp, __n2, 'i'); \
|
||||||
#define g_assert_cmphex(n1, cmp, n2) do { guint64 __n1 = (n1), __n2 = (n2); \
|
} G_STMT_END
|
||||||
|
#define g_assert_cmphex(n1, cmp, n2) G_STMT_START {\
|
||||||
|
guint64 __n1 = (n1), __n2 = (n2); \
|
||||||
if (__n1 cmp __n2) ; else \
|
if (__n1 cmp __n2) ; else \
|
||||||
g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
|
g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
|
||||||
#n1 " " #cmp " " #n2, __n1, #cmp, __n2, 'x'); } while (0)
|
#n1 " " #cmp " " #n2, __n1, #cmp, __n2, 'x'); \
|
||||||
#define g_assert_cmpfloat(n1,cmp,n2) do { long double __n1 = (n1), __n2 = (n2); \
|
} G_STMT_END
|
||||||
|
#define g_assert_cmpfloat(n1,cmp,n2) G_STMT_START { \
|
||||||
|
long double __n1 = (n1), __n2 = (n2); \
|
||||||
if (__n1 cmp __n2) ; else \
|
if (__n1 cmp __n2) ; else \
|
||||||
g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
|
g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
|
||||||
#n1 " " #cmp " " #n2, __n1, #cmp, __n2, 'f'); } while (0)
|
#n1 " " #cmp " " #n2, __n1, #cmp, __n2, 'f'); \
|
||||||
#define g_assert_no_error(err) do { if (err) \
|
} 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, \
|
g_assertion_message_error (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
|
||||||
#err, err, 0, 0); } while (0)
|
#err, err, 0, 0); \
|
||||||
#define g_assert_error(err, dom, c) do { if (!err || (err)->domain != dom || (err)->code != c) \
|
} 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, \
|
g_assertion_message_error (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
|
||||||
#err, err, dom, c); } while (0)
|
#err, err, dom, c); \
|
||||||
#define g_assert_true(expr) do { if G_LIKELY (expr) ; else \
|
} 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, \
|
g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
|
||||||
"'" #expr "' should be TRUE"); \
|
"'" #expr "' should be TRUE"); \
|
||||||
} while (0)
|
} G_STMT_END
|
||||||
#define g_assert_false(expr) do { if G_LIKELY (!(expr)) ; else \
|
#define g_assert_false(expr) G_STMT_START { \
|
||||||
|
if G_LIKELY (!(expr)) ; else \
|
||||||
g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
|
g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
|
||||||
"'" #expr "' should be FALSE"); \
|
"'" #expr "' should be FALSE"); \
|
||||||
} while (0)
|
} G_STMT_END
|
||||||
#define g_assert_null(expr) do { if G_LIKELY ((expr) == NULL) ; else \
|
#define g_assert_null(expr) G_STMT_START { if G_LIKELY ((expr) == NULL) ; else \
|
||||||
g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
|
g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
|
||||||
"'" #expr "' should be NULL"); \
|
"'" #expr "' should be NULL"); \
|
||||||
} while (0)
|
} G_STMT_END
|
||||||
#define g_assert_nonnull(expr) do { if G_LIKELY ((expr) != NULL) ; else \
|
#define g_assert_nonnull(expr) G_STMT_START { \
|
||||||
|
if G_LIKELY ((expr) != NULL) ; else \
|
||||||
g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
|
g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
|
||||||
"'" #expr "' should not be NULL"); \
|
"'" #expr "' should not be NULL"); \
|
||||||
} while (0)
|
} G_STMT_END
|
||||||
#ifdef G_DISABLE_ASSERT
|
#ifdef G_DISABLE_ASSERT
|
||||||
#define g_assert_not_reached() do { (void) 0; } while (0)
|
#define g_assert_not_reached() G_STMT_START { (void) 0; } G_STMT_END
|
||||||
#define g_assert(expr) do { (void) 0; } while (0)
|
#define g_assert(expr) G_STMT_START { (void) 0; } G_STMT_END
|
||||||
#else /* !G_DISABLE_ASSERT */
|
#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_not_reached() G_STMT_START { g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, NULL); } G_STMT_END
|
||||||
#define g_assert(expr) do { if G_LIKELY (expr) ; else \
|
#define g_assert(expr) G_STMT_START { \
|
||||||
|
if G_LIKELY (expr) ; else \
|
||||||
g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
|
g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
|
||||||
#expr); \
|
#expr); \
|
||||||
} while (0)
|
} G_STMT_END
|
||||||
#endif /* !G_DISABLE_ASSERT */
|
#endif /* !G_DISABLE_ASSERT */
|
||||||
|
|
||||||
GLIB_AVAILABLE_IN_ALL
|
GLIB_AVAILABLE_IN_ALL
|
||||||
|
Loading…
Reference in New Issue
Block a user