[libadwaita/msvc: 17/19] tests/: Code styling fixes




commit cb58eda9006539d618385b41b0657ec07d79a7ac
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Tue Jan 18 12:47:34 2022 +0800

    tests/: Code styling fixes

 tests/test-button-content.c |  1 +
 tests/test-tab-view.c       |  3 ++-
 tests/test-toast.c          | 21 ++++++++++++---------
 tests/test-window-title.c   |  6 ++++--
 4 files changed, 19 insertions(+), 12 deletions(-)
---
diff --git a/tests/test-button-content.c b/tests/test-button-content.c
index c4e97c3d..18aba422 100644
--- a/tests/test-button-content.c
+++ b/tests/test-button-content.c
@@ -40,6 +40,7 @@ test_adw_button_content_icon_name (void)
   g_object_set (content, "icon-name", "", NULL);
   g_assert_cmpstr (adw_button_content_get_icon_name (content), ==, "");
   g_assert_cmpint (notified, ==, 2);
+
   g_free (icon_name);
   g_assert_finalize_object (content);
 }
diff --git a/tests/test-tab-view.c b/tests/test-tab-view.c
index 8ced25c2..085595b8 100644
--- a/tests/test-tab-view.c
+++ b/tests/test-tab-view.c
@@ -171,7 +171,6 @@ test_adw_tab_view_default_icon (void)
   icon_str = g_icon_to_string (adw_tab_view_get_default_icon (view));
   g_assert_cmpstr (icon_str, ==, "adw-tab-icon-missing-symbolic");
   g_assert_cmpint (notified, ==, 0);
-  g_free (icon_str);
 
   adw_tab_view_set_default_icon (view, icon1);
   g_assert_true (adw_tab_view_get_default_icon (view) == icon1);
@@ -184,6 +183,8 @@ test_adw_tab_view_default_icon (void)
   g_assert_finalize_object (view);
   g_assert_finalize_object (icon1);
   g_assert_finalize_object (icon2);
+
+  g_free (icon_str);
 }
 
 static void
diff --git a/tests/test-toast.c b/tests/test-toast.c
index a1b18f10..c161ff2e 100644
--- a/tests/test-toast.c
+++ b/tests/test-toast.c
@@ -97,9 +97,7 @@ test_adw_toast_action_target (void)
 {
   AdwToast *toast = adw_toast_new ("Title");
   GVariant *action_target;
-  GVariant *variant1 = g_variant_ref_sink (g_variant_new_int32 (1));
-  GVariant *variant2 = g_variant_ref_sink (g_variant_new_int32 (2));
-  GVariant *variant3 = g_variant_ref_sink (g_variant_new_int32 (3));
+  GVariant *variant = g_variant_ref_sink (g_variant_new_int32 (1));
 
   g_assert_nonnull (toast);
 
@@ -110,21 +108,26 @@ test_adw_toast_action_target (void)
   g_assert_null (action_target);
 
   adw_toast_set_action_target_value (toast, g_variant_new_int32 (1));
-  g_assert_cmpvariant (adw_toast_get_action_target_value (toast), variant1);
+  g_assert_cmpvariant (adw_toast_get_action_target_value (toast), variant);
   g_assert_cmpint (notified, ==, 1);
-  g_variant_unref (variant1);
 
+  g_variant_unref (variant);
+
+  variant = g_variant_ref_sink (g_variant_new_int32 (2));
   g_object_set (toast, "action-target", g_variant_new_int32 (2), NULL);
-  g_assert_cmpvariant (adw_toast_get_action_target_value (toast), variant2);
+  g_assert_cmpvariant (adw_toast_get_action_target_value (toast), variant);
   g_assert_cmpint (notified, ==, 2);
-  g_variant_unref (variant2);
 
+  g_variant_unref (variant);
+
+  variant = g_variant_ref_sink (g_variant_new_int32 (3));
   adw_toast_set_action_target (toast, "i", 3);
-  g_assert_cmpvariant (adw_toast_get_action_target_value (toast), variant3);
+  g_assert_cmpvariant (adw_toast_get_action_target_value (toast), variant);
   g_assert_cmpint (notified, ==, 3);
-  g_variant_unref (variant3);
 
   g_assert_finalize_object (toast);
+
+  g_variant_unref (variant);
 }
 
 static void
diff --git a/tests/test-window-title.c b/tests/test-window-title.c
index d48242cb..fd4b4a8a 100644
--- a/tests/test-window-title.c
+++ b/tests/test-window-title.c
@@ -29,7 +29,6 @@ test_adw_window_title_title (void)
 
   g_object_get (window_title, "title", &title, NULL);
   g_assert_cmpstr (title, ==, "Some title");
-  g_free (title);
 
   adw_window_title_set_title (window_title, "Some title");
   g_assert_cmpint (notified, ==, 0);
@@ -43,6 +42,8 @@ test_adw_window_title_title (void)
   g_assert_cmpint (notified, ==, 2);
 
   g_assert_finalize_object (window_title);
+
+  g_free (title);
 }
 
 static void
@@ -58,7 +59,6 @@ test_adw_window_title_subtitle (void)
 
   g_object_get (window_title, "subtitle", &subtitle, NULL);
   g_assert_cmpstr (subtitle, ==, "Some subtitle");
-  g_free (subtitle);
 
   adw_window_title_set_subtitle (window_title, "Some subtitle");
   g_assert_cmpint (notified, ==, 0);
@@ -72,6 +72,8 @@ test_adw_window_title_subtitle (void)
   g_assert_cmpint (notified, ==, 2);
 
   g_assert_finalize_object (window_title);
+
+  g_free (subtitle);
 }
 
 int


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