[libadwaita/msvc: 75/79] tests: Remove g_auto* usage
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libadwaita/msvc: 75/79] tests: Remove g_auto* usage
- Date: Thu, 30 Dec 2021 03:19:50 +0000 (UTC)
commit 4f346f13df43b6ba7552bfb624d7447d91167b97
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Mon Jul 26 19:00:02 2021 +0800
tests: Remove g_auto* usage
It is unfortunately a GCCism, so use the traditional method instead.
Unfortunately the autocleanup compiler extensions are not standard across the
board.
tests/test-button-content.c | 7 ++++---
tests/test-easing.c | 7 +++++--
tests/test-leaflet.c | 4 +++-
tests/test-status-page.c | 6 ++++--
tests/test-tab-view.c | 12 +++++++++---
tests/test-toast.c | 15 ++++++++++-----
tests/test-window-title.c | 6 ++++--
7 files changed, 39 insertions(+), 18 deletions(-)
---
diff --git a/tests/test-button-content.c b/tests/test-button-content.c
index 5d5ba196..c4e97c3d 100644
--- a/tests/test-button-content.c
+++ b/tests/test-button-content.c
@@ -20,7 +20,7 @@ static void
test_adw_button_content_icon_name (void)
{
AdwButtonContent *content = g_object_ref_sink (ADW_BUTTON_CONTENT (adw_button_content_new ()));
- g_autofree char *icon_name = NULL;
+ char *icon_name = NULL;
g_assert_nonnull (content);
@@ -40,7 +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);
}
@@ -48,7 +48,7 @@ static void
test_adw_button_content_label (void)
{
AdwButtonContent *content = g_object_ref_sink (ADW_BUTTON_CONTENT (adw_button_content_new ()));
- g_autofree char *label = NULL;
+ char *label;
g_assert_nonnull (content);
@@ -69,6 +69,7 @@ test_adw_button_content_label (void)
g_assert_cmpstr (adw_button_content_get_label (content), ==, "");
g_assert_cmpint (notified, ==, 2);
+ g_free (label);
g_assert_finalize_object (content);
}
diff --git a/tests/test-easing.c b/tests/test-easing.c
index 58ba6287..7c6f81ea 100644
--- a/tests/test-easing.c
+++ b/tests/test-easing.c
@@ -21,7 +21,7 @@ int
main (int argc,
char *argv[])
{
- g_autoptr (GEnumClass) enum_class = NULL;
+ GEnumClass *enum_class = NULL;
guint i;
gtk_test_init (&argc, &argv, NULL);
@@ -31,11 +31,14 @@ main (int argc,
for (i = 0; i < enum_class->n_values; i++) {
GEnumValue *value = &enum_class->values[i];
- g_autofree char *path =
+ char *path =
g_strdup_printf ("/Adwaita/Easing/%s", value->value_nick);
g_test_add_data_func (path, GINT_TO_POINTER (value->value), test_easing_ease);
+
+ g_free (path);
}
+ g_type_class_unref (enum_class);
return g_test_run();
}
diff --git a/tests/test-leaflet.c b/tests/test-leaflet.c
index 39f7aeed..284bc886 100644
--- a/tests/test-leaflet.c
+++ b/tests/test-leaflet.c
@@ -12,11 +12,13 @@ assert_page_position (GtkSelectionModel *pages,
GtkWidget *widget,
int position)
{
- g_autoptr (AdwLeafletPage) page = NULL;
+ AdwLeafletPage *page = NULL;
page = g_list_model_get_item (G_LIST_MODEL (pages), position);
g_assert_true (widget == adw_leaflet_page_get_child (page));
+
+ g_object_unref (page);
}
diff --git a/tests/test-status-page.c b/tests/test-status-page.c
index 7a497961..2c7f7bd0 100644
--- a/tests/test-status-page.c
+++ b/tests/test-status-page.c
@@ -46,7 +46,7 @@ static void
test_adw_status_page_title (void)
{
AdwStatusPage *status_page = ADW_STATUS_PAGE (g_object_ref_sink (adw_status_page_new ()));
- g_autofree char *title = NULL;
+ char *title = NULL;
g_assert_nonnull (status_page);
@@ -67,6 +67,7 @@ test_adw_status_page_title (void)
g_assert_cmpstr (adw_status_page_get_title (status_page), ==, "Other Title");
g_assert_cmpint (notified, ==, 2);
+ g_free (title);
g_assert_finalize_object (status_page);
}
@@ -74,7 +75,7 @@ static void
test_adw_status_page_description (void)
{
AdwStatusPage *status_page = ADW_STATUS_PAGE (g_object_ref_sink (adw_status_page_new ()));
- g_autofree char *description = NULL;
+ char *description = NULL;
g_assert_nonnull (status_page);
@@ -95,6 +96,7 @@ test_adw_status_page_description (void)
g_assert_cmpstr (adw_status_page_get_description (status_page), ==, "Other description");
g_assert_cmpint (notified, ==, 2);
+ g_free (description);
g_assert_finalize_object (status_page);
}
diff --git a/tests/test-tab-view.c b/tests/test-tab-view.c
index 04687867..8ced25c2 100644
--- a/tests/test-tab-view.c
+++ b/tests/test-tab-view.c
@@ -152,6 +152,7 @@ test_adw_tab_view_n_pinned_pages (void)
g_assert_cmpint (notified, ==, 3);
g_assert_finalize_object (view);
+ g_object_unref (page);
}
static void
@@ -160,7 +161,7 @@ test_adw_tab_view_default_icon (void)
AdwTabView *view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
GIcon *icon1 = g_themed_icon_new ("go-previous-symbolic");
GIcon *icon2 = g_themed_icon_new ("go-next-symbolic");
- g_autofree char *icon_str = NULL;
+ char *icon_str = NULL;
g_assert_nonnull (view);
@@ -170,6 +171,7 @@ 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);
@@ -932,7 +934,7 @@ test_adw_tab_page_title (void)
{
AdwTabView *view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
AdwTabPage *page;
- g_autofree char *title = NULL;
+ char *title = NULL;
g_assert_nonnull (view);
@@ -953,6 +955,7 @@ test_adw_tab_page_title (void)
g_object_set (page, "title", "Some other title", NULL);
g_assert_cmpstr (adw_tab_page_get_title (page), ==, "Some other title");
g_assert_cmpint (notified, ==, 2);
+ g_free (title);
g_assert_finalize_object (view);
}
@@ -962,7 +965,7 @@ test_adw_tab_page_tooltip (void)
{
AdwTabView *view = g_object_ref_sink (ADW_TAB_VIEW (adw_tab_view_new ()));
AdwTabPage *page;
- g_autofree char *tooltip = NULL;
+ char *tooltip = NULL;
g_assert_nonnull (view);
@@ -984,6 +987,7 @@ test_adw_tab_page_tooltip (void)
g_assert_cmpstr (adw_tab_page_get_tooltip (page), ==, "Some other tooltip");
g_assert_cmpint (notified, ==, 2);
+ g_free (tooltip);
g_assert_finalize_object (view);
}
@@ -1015,6 +1019,7 @@ test_adw_tab_page_icon (void)
g_object_set (page, "icon", icon2, NULL);
g_assert_true (adw_tab_page_get_icon (page) == icon2);
g_assert_cmpint (notified, ==, 2);
+ g_object_unref (icon2);
g_assert_finalize_object (view);
g_assert_finalize_object (icon1);
@@ -1080,6 +1085,7 @@ test_adw_tab_page_indicator_icon (void)
g_object_set (page, "indicator-icon", icon2, NULL);
g_assert_true (adw_tab_page_get_indicator_icon (page) == icon2);
g_assert_cmpint (notified, ==, 2);
+ g_object_unref (icon2);
g_assert_finalize_object (view);
g_assert_finalize_object (icon1);
diff --git a/tests/test-toast.c b/tests/test-toast.c
index ad293e88..a1b18f10 100644
--- a/tests/test-toast.c
+++ b/tests/test-toast.c
@@ -20,7 +20,7 @@ static void
test_adw_toast_title (void)
{
AdwToast *toast = adw_toast_new ("Title");
- g_autofree char *title = NULL;
+ char *title = NULL;
g_assert_nonnull (toast);
@@ -38,6 +38,7 @@ test_adw_toast_title (void)
g_assert_cmpstr (adw_toast_get_title (toast), ==, "Title");
g_assert_cmpint (notified, ==, 2);
+ g_free (title);
g_assert_finalize_object (toast);
}
@@ -96,9 +97,9 @@ test_adw_toast_action_target (void)
{
AdwToast *toast = adw_toast_new ("Title");
GVariant *action_target;
- g_autoptr (GVariant) variant1 = g_variant_ref_sink (g_variant_new_int32 (1));
- g_autoptr (GVariant) variant2 = g_variant_ref_sink (g_variant_new_int32 (2));
- g_autoptr (GVariant) variant3 = g_variant_ref_sink (g_variant_new_int32 (3));
+ 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));
g_assert_nonnull (toast);
@@ -111,14 +112,17 @@ test_adw_toast_action_target (void)
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_cmpint (notified, ==, 1);
+ g_variant_unref (variant1);
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_cmpint (notified, ==, 2);
+ g_variant_unref (variant2);
adw_toast_set_action_target (toast, "i", 3);
g_assert_cmpvariant (adw_toast_get_action_target_value (toast), variant3);
g_assert_cmpint (notified, ==, 3);
+ g_variant_unref (variant3);
g_assert_finalize_object (toast);
}
@@ -127,7 +131,7 @@ static void
test_adw_toast_detailed_action_name (void)
{
AdwToast *toast = adw_toast_new ("Title");
- g_autoptr (GVariant) variant = g_variant_ref_sink (g_variant_new_int32 (2));
+ GVariant *variant = g_variant_ref_sink (g_variant_new_int32 (2));
g_assert_nonnull (toast);
@@ -141,6 +145,7 @@ test_adw_toast_detailed_action_name (void)
adw_toast_set_detailed_action_name (toast, "win.something(2)");
g_assert_cmpstr (adw_toast_get_action_name (toast), ==, "win.something");
g_assert_cmpvariant (adw_toast_get_action_target_value (toast), variant);
+ g_variant_unref (variant);
g_assert_finalize_object (toast);
}
diff --git a/tests/test-window-title.c b/tests/test-window-title.c
index 0a5616fc..d48242cb 100644
--- a/tests/test-window-title.c
+++ b/tests/test-window-title.c
@@ -20,7 +20,7 @@ static void
test_adw_window_title_title (void)
{
AdwWindowTitle *window_title = g_object_ref_sink (ADW_WINDOW_TITLE (adw_window_title_new ("Some title",
NULL)));
- g_autofree char *title = NULL;
+ char *title = NULL;
g_assert_nonnull (window_title);
@@ -29,6 +29,7 @@ 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);
@@ -48,7 +49,7 @@ static void
test_adw_window_title_subtitle (void)
{
AdwWindowTitle *window_title = g_object_ref_sink (ADW_WINDOW_TITLE (adw_window_title_new (NULL, "Some
subtitle")));
- g_autofree char *subtitle = NULL;
+ char *subtitle = NULL;
g_assert_nonnull (window_title);
@@ -57,6 +58,7 @@ 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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]