[glib/task-strdup-avoidance] gio: Tweak the task tests



commit 4d1abc1ad5e9182927758190b61938920177dd5d
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Sep 21 18:12:00 2022 -0400

    gio: Tweak the task tests
    
    Tweak the g_task_set_name test to use a non-literal string,
    so we don't test g_task_set_static_name twice.

 gio/tests/task.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/gio/tests/task.c b/gio/tests/task.c
index d214a97e60..3c7c6bdf84 100644
--- a/gio/tests/task.c
+++ b/gio/tests/task.c
@@ -625,18 +625,20 @@ static void
 test_name (void)
 {
   GTask *t1 = NULL;
+  char *orig = g_strdup ("some task");
   gchar *name1 = NULL;
 
   t1 = g_task_new (NULL, NULL, name_callback, &name1);
-  g_task_set_name (t1, "some task");
+  g_task_set_name (t1, orig);
   g_task_return_boolean (t1, TRUE);
   g_object_unref (t1);
 
   g_main_loop_run (loop);
 
-  g_assert_cmpstr (name1, ==, "some task");
+  g_assert_cmpstr (name1, ==, orig);
 
   g_free (name1);
+  g_free (orig);
 }
 
 static void
@@ -664,8 +666,8 @@ static void
 test_static_name (void)
 {
   GTask *t1 = NULL;
-  char *name1 = NULL;
   char *orig = "some task";
+  char *name1 = NULL;
 
   t1 = g_task_new (NULL, NULL, static_name_callback, &name1);
   g_task_set_static_name (t1, orig);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]