diff options
author | Dan Winship <danw@gnome.org> | 2011-06-02 14:57:58 -0400 |
---|---|---|
committer | Dan Winship <danw@gnome.org> | 2011-06-10 17:37:05 -0400 |
commit | 88e8592c5bb8709c035865f084e104db54564a89 (patch) | |
tree | ecd50a8091024a9ce493a1f05de86cb29d1d52aa | |
parent | 4dfc48069abbbdc59fbb9af93e107d915aa0ec5c (diff) | |
download | gobject-introspection-88e8592c5bb8709c035865f084e104db54564a89.tar.gz |
gimarshallingtests: add a few more array tests
Add some tests with parameters on either side of an out array length
parameter, to ensure that bindings that omit the length parameter
don't mess up any other parameters.
https://bugzilla.gnome.org/show_bug.cgi?id=651558
-rw-r--r-- | tests/gimarshallingtests.c | 66 | ||||
-rw-r--r-- | tests/gimarshallingtests.h | 3 |
2 files changed, 69 insertions, 0 deletions
diff --git a/tests/gimarshallingtests.c b/tests/gimarshallingtests.c index 56df373a..7275f795 100644 --- a/tests/gimarshallingtests.c +++ b/tests/gimarshallingtests.c @@ -1211,6 +1211,26 @@ gi_marshalling_tests_array_return (gint *length) } /** + * gi_marshalling_tests_array_return_etc: + * @first: + * @length: (out): + * @last: + * @sum: (out): + * Returns: (array length=length): + */ +const gint * +gi_marshalling_tests_array_return_etc (gint first, gint *length, gint last, gint *sum) +{ + static gint ints[] = {-1, 0, 1, 2}; + + ints[0] = first; + ints[3] = last; + *sum = first + last; + *length = 4; + return ints; +} + +/** * gi_marshalling_tests_array_in: * @ints: (array length=length): */ @@ -1252,6 +1272,26 @@ gi_marshalling_tests_array_out (gint **ints, gint *length) } /** + * gi_marshalling_tests_array_out_etc: + * @first: + * @ints: (out) (array length=length) (transfer none): + * @length: (out): + * @last: + * @sum: (out): + */ +void +gi_marshalling_tests_array_out_etc (gint first, gint **ints, gint *length, gint last, gint *sum) +{ + static gint values[] = {-1, 0, 1, 2}; + + values[0] = first; + values[3] = last; + *sum = first + last; + *length = 4; + *ints = values; +} + +/** * gi_marshalling_tests_array_inout: * @ints: (inout) (array length=length) (transfer none): * @length: (inout): @@ -1272,6 +1312,32 @@ gi_marshalling_tests_array_inout (gint **ints, gint *length) } /** + * gi_marshalling_tests_array_inout_etc: + * @first: + * @ints: (inout) (array length=length) (transfer none): + * @length: (inout): + * @last: + * @sum: (out): + */ +void +gi_marshalling_tests_array_inout_etc (gint first, gint **ints, gint *length, gint last, gint *sum) +{ + static gint values[] = {-2, -1, 0, 1, 2}; + + g_assert(*length == 4); + g_assert((*ints)[0] == -1); + g_assert((*ints)[1] == 0); + g_assert((*ints)[2] == 1); + g_assert((*ints)[3] == 2); + + values[0] = first; + values[4] = last; + *sum = first + last; + *length = 5; + *ints = values; +} + +/** * gi_marshalling_tests_array_zero_terminated_return: * Returns: (array zero-terminated=1) (transfer none): */ diff --git a/tests/gimarshallingtests.h b/tests/gimarshallingtests.h index f7b59b3b..ef80a4cf 100644 --- a/tests/gimarshallingtests.h +++ b/tests/gimarshallingtests.h @@ -279,14 +279,17 @@ void gi_marshalling_tests_array_fixed_inout (gint **ints); /* Variable-size */ const gint *gi_marshalling_tests_array_return (gint *length); +const gint *gi_marshalling_tests_array_return_etc (gint first, gint *length, gint last, gint *sum); void gi_marshalling_tests_array_in (const gint *ints, gint length); void gi_marshalling_tests_array_uint8_in (const guint8 *chars, gint length); void gi_marshalling_tests_array_out (gint **ints, gint *length); +void gi_marshalling_tests_array_out_etc (gint first, gint **ints, gint *length, gint last, gint *sum); void gi_marshalling_tests_array_inout (gint **ints, gint *length); +void gi_marshalling_tests_array_inout_etc (gint first, gint **ints, gint *length, gint last, gint *sum); /* Zero-terminated */ |