[glib] gtestutils: add g_test_add_data_func_full()
- From: Dan Winship <danw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] gtestutils: add g_test_add_data_func_full()
- Date: Mon, 27 Aug 2012 11:41:02 +0000 (UTC)
commit 0c0cdfd9c4a9d57aae0fb50b5e18cab6ba9e1a76
Author: Dan Winship <danw gnome org>
Date: Thu Aug 23 12:29:36 2012 -0400
gtestutils: add g_test_add_data_func_full()
Like g_test_add_data_func(), but includes a GDestroyNotify for the
test data.
https://bugzilla.gnome.org/show_bug.cgi?id=682560
docs/reference/glib/glib-sections.txt | 1 +
glib/glib.symbols | 1 +
glib/gtestutils.c | 28 ++++++++++++++++++++++++++++
glib/gtestutils.h | 7 +++++++
4 files changed, 37 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/glib/glib-sections.txt b/docs/reference/glib/glib-sections.txt
index 029057d..ddede24 100644
--- a/docs/reference/glib/glib-sections.txt
+++ b/docs/reference/glib/glib-sections.txt
@@ -2883,6 +2883,7 @@ GTestFunc
g_test_add_func
GTestDataFunc
g_test_add_data_func
+g_test_add_data_func_full
g_test_add
g_test_fail
diff --git a/glib/glib.symbols b/glib/glib.symbols
index c21bb03..ae2ad73 100644
--- a/glib/glib.symbols
+++ b/glib/glib.symbols
@@ -1184,6 +1184,7 @@ g_assertion_message_expr
g_assertion_message_error
g_strcmp0
g_test_add_data_func
+g_test_add_data_func_full
g_test_add_func
g_test_add_vtable
g_test_assert_expected_messages_internal
diff --git a/glib/gtestutils.c b/glib/gtestutils.c
index 2e3b415..e4b4331 100644
--- a/glib/gtestutils.c
+++ b/glib/gtestutils.c
@@ -1510,10 +1510,38 @@ g_test_add_data_func (const char *testpath,
g_return_if_fail (testpath != NULL);
g_return_if_fail (testpath[0] == '/');
g_return_if_fail (test_func != NULL);
+
g_test_add_vtable (testpath, 0, test_data, NULL, (GTestFixtureFunc) test_func, NULL);
}
/**
+ * g_test_add_data_func_full:
+ * @testpath: /-separated test case path name for the test.
+ * @test_data: Test data argument for the test function.
+ * @test_func: The test function to invoke for this test.
+ * @data_free_func: #GDestroyNotify for @test_data.
+ *
+ * Create a new test case, as with g_test_add_data_func(), but freeing
+ * @test_data after the test run is complete.
+ *
+ * Since: 2.34
+ */
+void
+g_test_add_data_func_full (const char *testpath,
+ gpointer test_data,
+ GTestDataFunc test_func,
+ GDestroyNotify data_free_func)
+{
+ g_return_if_fail (testpath != NULL);
+ g_return_if_fail (testpath[0] == '/');
+ g_return_if_fail (test_func != NULL);
+
+ g_test_add_vtable (testpath, 0, test_data, NULL,
+ (GTestFixtureFunc) test_func,
+ (GTestFixtureFunc) data_free_func);
+}
+
+/**
* g_test_create_suite:
* @suite_name: a name for the suite
*
diff --git a/glib/gtestutils.h b/glib/gtestutils.h
index 90287d3..967fa63 100644
--- a/glib/gtestutils.h
+++ b/glib/gtestutils.h
@@ -108,6 +108,13 @@ void g_test_add_func (const char *testpath,
void g_test_add_data_func (const char *testpath,
gconstpointer test_data,
GTestDataFunc test_func);
+
+GLIB_AVAILABLE_IN_2_34
+void g_test_add_data_func_full (const char *testpath,
+ gpointer test_data,
+ GTestDataFunc test_func,
+ GDestroyNotify data_free_func);
+
/* tell about failure */
void g_test_fail (void);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]