diff options
author | Philip Chimento <philip.chimento@gmail.com> | 2019-06-20 00:18:13 -0700 |
---|---|---|
committer | Philip Chimento <philip.chimento@gmail.com> | 2019-06-20 11:54:10 -0700 |
commit | e49cfb8d3462d624cad8b76c6560bd76996ed544 (patch) | |
tree | b296172edc26b41f14a005e3008b13a7512f1f61 /tests | |
parent | 5fdc6c8f714bc8c8af8b1ecaa05663923b0a83ba (diff) | |
download | gobject-introspection-e49cfb8d3462d624cad8b76c6560bd76996ed544.tar.gz |
girepository: Return pointer array for interface cache
In g_irepository_get_object_gtype_interfaces(), returning the address of
the first GIBaseInfo* does not work reliably, because the GIBaseInfos
are not necessarily stored contiguously. So the second and subsequent
ones might be garbage.
Instead, return the address of the array of GIBaseInfo pointers.
Add a test that verifies the functionality, as well.
This is unfortunately an API and ABI break.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/repository/gitestrepo.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/repository/gitestrepo.c b/tests/repository/gitestrepo.c index 6c10b076..abe30d98 100644 --- a/tests/repository/gitestrepo.c +++ b/tests/repository/gitestrepo.c @@ -57,6 +57,29 @@ test_type_info_get_name (GIRepository *repo) g_base_info_unref ((GIBaseInfo*)typeinfo); } +static void +test_get_gtype_interfaces (GIRepository *repo) +{ + GIInterfaceInfo **interfaces; + guint n_interfaces, ix; + gboolean found_initable = FALSE, found_async_initable = FALSE; + + g_irepository_get_object_gtype_interfaces (repo, G_TYPE_DBUS_CONNECTION, &n_interfaces, &interfaces); + + g_assert_cmpuint (n_interfaces, ==, 2); + + for (ix = 0; ix < n_interfaces; ix++) + { + const gchar *name = g_base_info_get_name(*(interfaces + ix)); + if (strcmp (name, "Initable") == 0) + found_initable = TRUE; + else if (strcmp (name, "AsyncInitable") == 0) + found_async_initable = TRUE; + } + + g_assert_true (found_initable); + g_assert_true (found_async_initable); +} int main(int argc, char **argv) @@ -161,6 +184,7 @@ main(int argc, char **argv) } test_type_info_get_name (repo); + test_get_gtype_interfaces (repo); /* Error quark tests */ errorinfo = g_irepository_find_by_error_domain (repo, G_RESOLVER_ERROR); |