[librsvg: 28/30] C API test for the sizes of structs and GType information
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 28/30] C API test for the sizes of structs and GType information
- Date: Wed, 23 Jun 2021 23:05:40 +0000 (UTC)
commit 3ab32523f3cbe25c5174220ac09d501675f140d5
Author: Federico Mena Quintero <federico gnome org>
Date: Mon Jun 21 15:52:30 2021 -0500
C API test for the sizes of structs and GType information
Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/516>
tests/api.c | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
---
diff --git a/tests/api.c b/tests/api.c
index 9c6e65c0..8e73c0c0 100644
--- a/tests/api.c
+++ b/tests/api.c
@@ -26,12 +26,25 @@
*/
static void
-handle_has_gtype (void)
+handle_has_correct_type_info (void)
{
+ GTypeQuery q;
RsvgHandle *handle;
+ g_type_query (RSVG_TYPE_HANDLE, &q);
+ g_assert (q.type == RSVG_TYPE_HANDLE);
+ g_assert (q.type == rsvg_handle_get_type ());
+
+ g_assert_cmpstr (q.type_name, ==, "RsvgHandle");
+
+ /* These test that the sizes of the structs in the header file actually match the
+ * sizes of structs and the glib-subclass machinery in the Rust side.
+ */
+ g_assert (sizeof (RsvgHandleClass) == (gsize) q.class_size);
+ g_assert (sizeof (RsvgHandle) == (gsize) q.instance_size);
+
handle = rsvg_handle_new();
- g_assert (G_OBJECT_TYPE (handle) == rsvg_handle_get_type ());
+ g_assert (G_OBJECT_TYPE (handle) == RSVG_TYPE_HANDLE);
g_object_unref (handle);
}
@@ -1638,7 +1651,7 @@ add_pixbuf_tests (void)
static void
add_api_tests (void)
{
- g_test_add_func ("/api/handle_has_gtype", handle_has_gtype);
+ g_test_add_func ("/api/handle_has_correct_type_info", handle_has_correct_type_info);
g_test_add_func ("/api/flags_registration", flags_registration);
g_test_add_func ("/api/error_registration", error_registration);
g_test_add_func ("/api/noops", noops);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]