[gobject-introspection] tests: add test functions which return GErrors
- From: Tomeu Vizoso <tomeuv src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection] tests: add test functions which return GErrors
- Date: Tue, 24 Jan 2012 14:51:20 +0000 (UTC)
commit 1ab4040596dfb4b0b38d547711990ec294771f27
Author: Will Thompson <will thompson collabora co uk>
Date: Fri Jan 20 14:48:20 2012 +0000
tests: add test functions which return GErrors
GStreamer has the following method:
void gst_message_parse_error (
GstMessage *message,
GError **error,
gchar **debug_message);
This patch adds a number of test functions with similar signatures which
do not follow the standard "throws GError" pattern.
https://bugzilla.gnome.org/show_bug.cgi?id=666098
tests/gimarshallingtests.c | 57 ++++++++++++++++++++++++++++++++++++++++++++
tests/gimarshallingtests.h | 4 +++
2 files changed, 61 insertions(+), 0 deletions(-)
---
diff --git a/tests/gimarshallingtests.c b/tests/gimarshallingtests.c
index f641c38..712e508 100644
--- a/tests/gimarshallingtests.c
+++ b/tests/gimarshallingtests.c
@@ -3972,6 +3972,63 @@ gi_marshalling_tests_gerror_array_in(gint *in_ints, GError **error)
GI_MARSHALLING_TESTS_CONSTANT_GERROR_MESSAGE);
}
+/**
+ * gi_marshalling_tests_gerror_out:
+ * @error: (out) (allow-none) (transfer full): location for the GError.
+ * @debug: (out) (allow-none) (transfer full): location for the debug message
+ *
+ * Inspired by gst_message_parse_error.
+ */
+void
+gi_marshalling_tests_gerror_out(GError **error, gchar **debug)
+{
+ GQuark quark = g_quark_from_static_string(GI_MARSHALLING_TESTS_CONSTANT_GERROR_DOMAIN);
+ g_set_error_literal(error,
+ quark,
+ GI_MARSHALLING_TESTS_CONSTANT_GERROR_CODE,
+ GI_MARSHALLING_TESTS_CONSTANT_GERROR_MESSAGE);
+
+ if (debug != NULL) {
+ *debug = g_strdup (GI_MARSHALLING_TESTS_CONSTANT_GERROR_DEBUG_MESSAGE);
+ }
+}
+
+/**
+ * gi_marshalling_tests_gerror_out_transfer_none:
+ * @err: (out) (allow-none) (transfer none): location for the GError.
+ * @debug: (out) (allow-none) (transfer none): location for the debug message
+ *
+ * A variant of gi_marshalling_tests_gerror_out() which returns data the caller
+ * must not free.
+ */
+void
+gi_marshalling_tests_gerror_out_transfer_none(GError **err, const gchar **debug)
+{
+ static GError error = { 0,
+ GI_MARSHALLING_TESTS_CONSTANT_GERROR_CODE,
+ GI_MARSHALLING_TESTS_CONSTANT_GERROR_MESSAGE };
+ error.domain = g_quark_from_static_string(GI_MARSHALLING_TESTS_CONSTANT_GERROR_DOMAIN);
+ *err = &error;
+ *debug = GI_MARSHALLING_TESTS_CONSTANT_GERROR_DEBUG_MESSAGE;
+}
+
+/**
+ * gi_marshalling_tests_gerror_return:
+ *
+ * Yet another variant of gi_marshalling_tests_gerror_out().
+ *
+ * Returns: (transfer full): a GError
+ */
+GError *
+gi_marshalling_tests_gerror_return()
+{
+ GQuark quark = g_quark_from_static_string(GI_MARSHALLING_TESTS_CONSTANT_GERROR_DOMAIN);
+
+ return g_error_new(quark,
+ GI_MARSHALLING_TESTS_CONSTANT_GERROR_CODE,
+ GI_MARSHALLING_TESTS_CONSTANT_GERROR_MESSAGE);
+}
+
static GIMarshallingTestsOverridesStruct *
gi_marshalling_tests_overrides_struct_copy (GIMarshallingTestsOverridesStruct *struct_)
{
diff --git a/tests/gimarshallingtests.h b/tests/gimarshallingtests.h
index 5965a82..e80a0e5 100644
--- a/tests/gimarshallingtests.h
+++ b/tests/gimarshallingtests.h
@@ -801,9 +801,13 @@ gint gi_marshalling_tests_int_return_out (gint *int_);
#define GI_MARSHALLING_TESTS_CONSTANT_GERROR_DOMAIN "gi-marshalling-tests-gerror-domain"
#define GI_MARSHALLING_TESTS_CONSTANT_GERROR_CODE 5
#define GI_MARSHALLING_TESTS_CONSTANT_GERROR_MESSAGE "gi-marshalling-tests-gerror-message"
+#define GI_MARSHALLING_TESTS_CONSTANT_GERROR_DEBUG_MESSAGE "we got an error, life is shit"
void gi_marshalling_tests_gerror(GError **error);
void gi_marshalling_tests_gerror_array_in(gint *in_ints, GError **error);
+void gi_marshalling_tests_gerror_out(GError **error, gchar **debug);
+void gi_marshalling_tests_gerror_out_transfer_none(GError **err, const gchar **debug);
+GError *gi_marshalling_tests_gerror_return();
/* Overrides */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]