[glib] gtestutils: add g_assert_nonnull() to go with g_assert_null()
- From: Dan Winship <danw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] gtestutils: add g_assert_nonnull() to go with g_assert_null()
- Date: Sun, 24 Nov 2013 20:14:42 +0000 (UTC)
commit 97fac936708863a52d46cfb0ec3259e1b2c03d29
Author: Dan Winship <danw gnome org>
Date: Sun Nov 10 15:27:26 2013 -0500
gtestutils: add g_assert_nonnull() to go with g_assert_null()
https://bugzilla.gnome.org/show_bug.cgi?id=711800
docs/reference/glib/glib-sections.txt | 1 +
glib/gtestutils.c | 15 +++++++++++++++
glib/gtestutils.h | 6 +++++-
3 files changed, 21 insertions(+), 1 deletions(-)
---
diff --git a/docs/reference/glib/glib-sections.txt b/docs/reference/glib/glib-sections.txt
index 4b25549..6065c15 100644
--- a/docs/reference/glib/glib-sections.txt
+++ b/docs/reference/glib/glib-sections.txt
@@ -2977,6 +2977,7 @@ g_assert_error
g_assert_true
g_assert_false
g_assert_null
+g_assert_nonnull
g_test_set_nonfatal_assertions
GTestCase
diff --git a/glib/gtestutils.c b/glib/gtestutils.c
index 7da2fc0..0a9ba0a 100644
--- a/glib/gtestutils.c
+++ b/glib/gtestutils.c
@@ -392,6 +392,21 @@
*/
/**
+ * g_assert_nonnull:
+ * @expr: the expression to check
+ *
+ * Debugging macro to check an expression is not %NULL.
+ *
+ * If the assertion fails (i.e. the expression is %NULL),
+ * an error message is logged and the application is either
+ * terminated or the testcase marked as failed.
+ *
+ * See g_test_set_nonfatal_assertions().
+ *
+ * Since: 2.40
+ */
+
+/**
* g_assert_cmpstr:
* @s1: a string (may be %NULL)
* @cmp: The comparison operator to use.
diff --git a/glib/gtestutils.h b/glib/gtestutils.h
index 9700f38..0118c50 100644
--- a/glib/gtestutils.h
+++ b/glib/gtestutils.h
@@ -74,7 +74,11 @@ typedef void (*GTestFixtureFunc) (gpointer fixture,
g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__,
G_STRFUNC, \
#expr); \
} while (0)
-#define g_assert_null(expr) do { if G_LIKELY ((expr) == NULL) ; else \
+#define g_assert_null(expr) do { if G_LIKELY ((expr) == NULL) ; else \
+ g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__,
G_STRFUNC, \
+ #expr); \
+ } while (0)
+#define g_assert_nonnull(expr) do { if G_LIKELY ((expr) != NULL) ; else \
g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__,
G_STRFUNC, \
#expr); \
} while (0)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]