diff options
author | Martin Pitt <martinpitt@gnome.org> | 2013-02-27 12:14:16 +0100 |
---|---|---|
committer | Martin Pitt <martinpitt@gnome.org> | 2013-02-27 14:49:12 +0100 |
commit | 2af5386d6cc1deba21f03c398c6368a9de6ed4ba (patch) | |
tree | b4a3125e059de2473c7dbdeeb3589798050a350c /tests/repository | |
parent | de6946c8a4ced56f7a24078b0d1aeacdb77e7f14 (diff) | |
download | gobject-introspection-2af5386d6cc1deba21f03c398c6368a9de6ed4ba.tar.gz |
Add test case for signal with a C array and length argument
By-product of https://bugzilla.gnome.org/show_bug.cgi?id=662241.
Diffstat (limited to 'tests/repository')
-rw-r--r-- | tests/repository/gitypelibtest.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/repository/gitypelibtest.c b/tests/repository/gitypelibtest.c index 54fe5234..e078699a 100644 --- a/tests/repository/gitypelibtest.c +++ b/tests/repository/gitypelibtest.c @@ -232,6 +232,48 @@ test_char_types (GIRepository *repo) g_base_info_unref (prop_obj); } +static void +test_signal_array_len (GIRepository *repo) +{ + GIObjectInfo *testobj_info; + GISignalInfo *sig_info; + GIArgInfo arg_info; + GITypeInfo type_info; + int i; + + g_assert (g_irepository_require (repo, "Regress", NULL, 0, NULL)); + testobj_info = g_irepository_find_by_name (repo, "Regress", "TestObj"); + g_assert (testobj_info != NULL); + + /* find sig-with-array-len-prop signal */ + for (i = g_object_info_get_n_signals (testobj_info) - 1; i >= 0; --i) { + sig_info = g_object_info_get_signal (testobj_info, i); + g_assert (sig_info != NULL); + if (strcmp (g_base_info_get_name (sig_info), "sig-with-array-len-prop") == 0) + break; + g_base_info_unref (sig_info); + } + g_assert (i >= 0); + + g_assert_cmpint (g_callable_info_get_n_args (sig_info), ==, 2); + + /* verify array argument */ + g_callable_info_load_arg (sig_info, 0, &arg_info); + g_assert_cmpstr (g_base_info_get_name (&arg_info), ==, "arr"); + g_arg_info_load_type (&arg_info, &type_info); + g_assert_cmpint (g_type_info_get_tag (&type_info), ==, GI_TYPE_TAG_ARRAY); + g_assert_cmpint (g_type_info_get_array_type (&type_info), ==, GI_ARRAY_TYPE_C); + g_assert (!g_type_info_is_zero_terminated (&type_info)); + g_assert_cmpint (g_type_info_get_array_length (&type_info), ==, 1); + + /* verify array length argument */ + g_callable_info_load_arg (sig_info, 1, &arg_info); + g_assert_cmpstr (g_base_info_get_name (&arg_info), ==, "len"); + + g_base_info_unref (sig_info); + g_base_info_unref (testobj_info); +} + int main(int argc, char **argv) { @@ -247,6 +289,7 @@ main(int argc, char **argv) test_fundamental_get_ref_function_pointer (repo); test_hash_with_cairo_typelib (repo); test_char_types (repo); + test_signal_array_len (repo); exit(0); } |