]> git.draconx.ca Git - gob-dx.git/commitdiff
Add missing g_type_init calls to test cases.
authorNick Bowler <nbowler@draconx.ca>
Fri, 25 Feb 2022 04:36:15 +0000 (23:36 -0500)
committerNick Bowler <nbowler@draconx.ca>
Fri, 25 Feb 2022 04:41:26 +0000 (23:41 -0500)
While this is a no-op on modern Glib, older versions require this to
be explicitly called before doing anything with the gobject system.

Failing to do so leads to test case failures.

tests/general.at
tests/interface.at

index e35c578a8032d81193de819bd82ce7efc9ad1b3b..49fd6a2b8ff80303b45e2f66f884c7bb098dd57b 100644 (file)
@@ -27,17 +27,18 @@ AT_DATA([main.c],
 
 int main(void)
 {
-  g_type_init ();
-
-  int the_answer = 42;
+  Str *test_good, *test_bad;
   char *stupid_pointer = "ug";
+  int the_answer = 42;
+
+  g_type_init ();
 
   /* This works fine. */
-  Str *test_good = (Str *) (str_new ("%d", the_answer));
+  test_good = (Str *) (str_new ("%d", the_answer));
   test_good = test_good;
 
   /* This gets a warning thanks to our function attribute. */
-  Str *test_bad = (Str *) (str_new ("%d", stupid_pointer));
+  test_bad = (Str *) (str_new ("%d", stupid_pointer));
   test_bad = test_bad;
 
   return 0;
@@ -63,7 +64,7 @@ exec 3<&-
 AT_CHECK([test x"$total" = x"2"])
 
 TEST_COMPILE_GOBJECT([main.c], [0], [], [stderr])
-AT_CHECK([$AWK -F : '$1 == "main.c" && $2 == "16" { exit 42 }' stderr], [42])
+AT_CHECK([$AWK -F : '$1 == "main.c" && $2 == "17" { exit 42 }' stderr], [42])
 
 AT_CHECK([$CC $CFLAGS $LDFLAGS $LIBGOBJECT_LIBS -o main str.o main.o])
 
@@ -91,6 +92,7 @@ AT_DATA([main.c],
 #include "test.h"
 int main(void)
 {
+  g_type_init();
   test_register_type(NULL);
 }
 ]])
@@ -139,6 +141,8 @@ int main(void)
   guint handler;
   Test *t;
 
+  g_type_init();
+
   /* should fail, suppress internal glib logging...  */
   handler = g_log_set_handler("GLib-GObject", G_LOG_LEVEL_MASK, devnull, 0);
   t = g_object_new(test_get_type(), NULL);
@@ -234,7 +238,10 @@ AT_DATA([main.c], [[#include <config.h>
 
 int main(void)
 {
-  GObject *go = g_object_new(test_get_type(), NULL);
+  GObject *go;
+
+  g_type_init();
+  go = g_object_new(test_get_type(), NULL);
 
   printf("%d\n", test_get_x(go));
   printf("%d\n", (test_set_x(go, 123), test_get_x(go)));
@@ -280,6 +287,7 @@ int main(void)
 {
   GObject *go;
 
+  g_type_init();
   g_type_module_use(g_object_new(test_mod_get_type(), NULL));
   go = g_object_new(test_get_type(), NULL);
 
index 3307c3d2c6400ffa5279b7f33852bded72dd80fa..113c22a60e19ac7b6beb9e3e331f7224bc14eade 100644 (file)
@@ -71,6 +71,7 @@ int main(void)
 {
   int rc;
 
+  g_type_init();
   rc = test_foo(g_object_new(TEST_TYPE_A, NULL));
   printf("%d\n", rc);
   if (rc < 0)
@@ -106,6 +107,7 @@ int main(void)
 {
   int rc;
 
+  g_type_init();
   g_type_module_use(g_object_new(TEST_TYPE_A_MOD, NULL));
 
   rc = test_foo(g_object_new(TEST_TYPE_A, NULL));
@@ -147,6 +149,7 @@ int main(void)
 {
   int rc;
 
+  g_type_init();
   rc = test_foo(g_object_new(TEST_TYPE_A, NULL));
   printf("%d\n", rc);
   if (rc < 0)
@@ -196,6 +199,7 @@ int main(void)
 {
   int rc;
 
+  g_type_init();
   g_type_module_use(g_object_new(TEST_TYPE_B_MOD, NULL));
 
   rc = test_foo(g_object_new(TEST_TYPE_A, NULL));
@@ -249,6 +253,7 @@ int main(void)
 {
   int rc;
 
+  g_type_init();
   g_type_module_use(g_object_new(TEST_TYPE_A_MOD, NULL));
   g_type_module_use(g_object_new(TEST_TYPE_B_MOD, NULL));
 
@@ -302,6 +307,7 @@ int main(void)
 {
   int rc;
 
+  g_type_init();
   rc = test_foo(g_object_new(TEST_TYPE_C, NULL));
   printf("%d\n", rc);
   if (rc < 0)
@@ -350,6 +356,7 @@ int main(void)
 {
   int rc;
 
+  g_type_init();
   g_type_module_use(g_object_new(TEST_TYPE_A_MOD, NULL));
   g_type_module_use(g_object_new(TEST_TYPE_B_MOD, NULL));
   g_type_module_use(g_object_new(TEST_TYPE_C_MOD, NULL));