From 7bac4ad4fed830ca387566122de80f49329f7411 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Thu, 4 Mar 2010 09:32:16 -0500 Subject: [PATCH] [everything] Add some "torture" test functions with baroque signatures We didn't have good coverage of say in arguments after out. https://bugzilla.gnome.org/show_bug.cgi?id=611809 --- gir/Everything-1.0-expected.gir | 145 ++++++++++++++++++++++++++++++++ gir/everything.c | 142 +++++++++++++++++++++++++++++++ gir/everything.h | 40 +++++++++ 3 files changed, 327 insertions(+) diff --git a/gir/Everything-1.0-expected.gir b/gir/Everything-1.0-expected.gir index 9453090..d886979 100644 --- a/gir/Everything-1.0-expected.gir +++ b/gir/Everything-1.0-expected.gir @@ -164,6 +164,59 @@ and/or use gtk-doc annotations. --> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gir/everything.c b/gir/everything.c index 6c394e8..6796088 100644 --- a/gir/everything.c +++ b/gir/everything.c @@ -1,5 +1,6 @@ #include #include "everything.h" +#include /* basic types */ gboolean test_boolean (gboolean in) @@ -1481,6 +1482,63 @@ test_obj_static_method (int x) return x; } +/** + * test_obj_torture_signature_0: + * @obj: A #TestObj + * @x: + * @y: (out): + * @z: (out): + * @foo: + * @q: (out): + * @m: + * + */ +void +test_obj_torture_signature_0 (TestObj *obj, + int x, + double *y, + int *z, + const char *foo, + int *q, + guint m) +{ + *y = x; + *z = x * 2; + *q = g_utf8_strlen (foo, -1) + m; +} + +/** + * test_obj_torture_signature_1: + * @obj: A #TestObj + * @x: + * @y: (out): + * @z: (out): + * @foo: + * @q: (out): + * @m: + * @error: A #GError + * + * This function throws an error if m is odd. + */ +gboolean +test_obj_torture_signature_1 (TestObj *obj, + int x, + double *y, + int *z, + const char *foo, + int *q, + guint m, + GError **error) +{ + *y = x; + *z = x * 2; + *q = g_utf8_strlen (foo, -1) + m; + if (m % 2 == 0) + return TRUE; + g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "m is odd"); + return FALSE; +} + /** * test_obj_do_matrix: * @obj: A #TestObj @@ -1812,3 +1870,87 @@ test_wi_802_1x_static_method (int x) { return 2*x; } + +/** + * test_torture_signature_0: + * @x: + * @y: (out): + * @z: (out): + * @foo: + * @q: (out): + * @m: + * + */ +void +test_torture_signature_0 (int x, + double *y, + int *z, + const char *foo, + int *q, + guint m) +{ + *y = x; + *z = x * 2; + *q = g_utf8_strlen (foo, -1) + m; +} + +/** + * test_torture_signature_1: + * @x: + * @y: (out): + * @z: (out): + * @foo: + * @q: (out): + * @m: + * @error: A #GError + * + * This function throws an error if m is odd. + */ +gboolean +test_torture_signature_1 (int x, + double *y, + int *z, + const char *foo, + int *q, + guint m, + GError **error) +{ + *y = x; + *z = x * 2; + *q = g_utf8_strlen (foo, -1) + m; + if (m % 2 == 0) + return TRUE; + g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "m is odd"); + return FALSE; +} + +/** + * test_torture_signature_2: + * @x: + * @callback: + * @user_data: + * @notify: + * @y: (out): + * @z: (out): + * @foo: + * @q: (out): + * @m: + * + */ +void +test_torture_signature_2 (int x, + TestCallbackUserData callback, + gpointer user_data, + GDestroyNotify notify, + double *y, + int *z, + const char *foo, + int *q, + guint m) +{ + *y = x; + *z = x * 2; + *q = g_utf8_strlen (foo, -1) + m; + notify (user_data); +} + diff --git a/gir/everything.h b/gir/everything.h index 84e2fe2..be4f6c6 100644 --- a/gir/everything.h +++ b/gir/everything.h @@ -257,6 +257,22 @@ void test_obj_set_bare (TestObj *obj, GObject *bare); int test_obj_instance_method (TestObj *obj); double test_obj_static_method (int x); +void test_obj_torture_signature_0 (TestObj *obj, + int x, + double *y, + int *z, + const char *foo, + int *q, + guint m); +gboolean test_obj_torture_signature_1 (TestObj *obj, + int x, + double *y, + int *z, + const char *foo, + int *q, + guint m, + GError **error); + /* virtual */ int test_obj_do_matrix (TestObj *obj, const char *somestr); @@ -340,4 +356,28 @@ gboolean test_wi_802_1x_get_testbool (TestWi8021x *obj); void test_wi_802_1x_set_testbool (TestWi8021x *obj, gboolean v); int test_wi_802_1x_static_method (int x); +/* Function signature torture tests */ +void test_torture_signature_0 (int x, + double *y, + int *z, + const char *foo, + int *q, + guint m); +gboolean test_torture_signature_1 (int x, + double *y, + int *z, + const char *foo, + int *q, + guint m, + GError **error); +void test_torture_signature_2 (int x, + TestCallbackUserData callback, + gpointer user_data, + GDestroyNotify notify, + double *y, + int *z, + const char *foo, + int *q, + guint m); + #endif /* __GITESTTYPES_H__ */ -- 2.39.2