[glib] Add a test for g_clear_pointer
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Add a test for g_clear_pointer
- Date: Mon, 14 May 2012 21:56:52 +0000 (UTC)
commit 215844b3a64fae95b24e464fe87ab6c3b5cd8daa
Author: Matthias Clasen <mclasen redhat com>
Date: Sun May 13 01:52:37 2012 -0400
Add a test for g_clear_pointer
glib/tests/utils.c | 15 +++++++++++++++
1 files changed, 15 insertions(+), 0 deletions(-)
---
diff --git a/glib/tests/utils.c b/glib/tests/utils.c
index 38620fd..15decdf 100644
--- a/glib/tests/utils.c
+++ b/glib/tests/utils.c
@@ -430,6 +430,20 @@ test_special_dir (void)
g_assert_cmpstr (dir, ==, dir2);
}
+static void
+test_clear_pointer (void)
+{
+ gpointer a;
+
+ a = g_malloc (5);
+ g_clear_pointer (&a, g_free);
+ g_assert (a == NULL);
+
+ a = g_malloc (5);
+ (g_clear_pointer) (&a, g_free);
+ g_assert (a == NULL);
+}
+
int
main (int argc,
char *argv[])
@@ -460,6 +474,7 @@ main (int argc,
g_test_add_func ("/utils/hostname", test_hostname);
g_test_add_func ("/utils/xdgdirs", test_xdg_dirs);
g_test_add_func ("/utils/specialdir", test_special_dir);
+ g_test_add_func ("/utils/clear-pointer", test_clear_pointer);
return g_test_run();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]