diff options
author | Juan Pablo Ugarte <juanpablougarte@gmail.com> | 2020-07-18 11:56:45 -0300 |
---|---|---|
committer | Juan Pablo Ugarte <juanpablougarte@gmail.com> | 2020-07-18 11:58:17 -0300 |
commit | 238ec80d11c9482dc25d2970985028ef72fe5075 (patch) | |
tree | 03c27f089f5600b6475dbeb1ddfdb523303113ed /tests | |
parent | f34c5377423c46976342f33341dac5c08ca6b26e (diff) | |
download | glade-238ec80d11c9482dc25d2970985028ef72fe5075.tar.gz |
Tests: use g_assert_true() instead of g_assert()
g_assert() should not be used in unit tests because it can be turned off
in final releases of code by defining G_DISABLE_ASSERT.
Fix issue #460 "3.37.0: test suite fails because glade uses incorrectly asserts in test units"
Diffstat (limited to 'tests')
-rw-r--r-- | tests/add-child.c | 22 | ||||
-rw-r--r-- | tests/create-widgets.c | 8 | ||||
-rw-r--r-- | tests/modules.c | 8 | ||||
-rw-r--r-- | tests/toplevel-order.c | 20 |
4 files changed, 29 insertions, 29 deletions
diff --git a/tests/add-child.c b/tests/add-child.c index ad12a00c..5359e79d 100644 --- a/tests/add-child.c +++ b/tests/add-child.c @@ -70,7 +70,7 @@ test_add_child (gconstpointer data) /* Pass ownership to the parent */ g_object_unref (gchild); - g_assert (glade_widget_get_parent (gchild) == gparent); + g_assert_true (glade_widget_get_parent (gchild) == gparent); if (test->func) test->func (parent, child); @@ -96,10 +96,10 @@ test_add_child (gconstpointer data) g_object_unref (gparent); - g_assert (gparent_finalized); - g_assert (gchild_finalized); - g_assert (parent_finalized); - g_assert (child_finalized); + g_assert_true (gparent_finalized); + g_assert_true (gchild_finalized); + g_assert_true (parent_finalized); + g_assert_true (child_finalized); } static void @@ -126,7 +126,7 @@ static void assert_widget_parented (GObject *parent, GObject *child) { - g_assert (gtk_widget_get_parent (GTK_WIDGET (child)) == GTK_WIDGET (parent)); + g_assert_true (gtk_widget_get_parent (GTK_WIDGET (child)) == GTK_WIDGET (parent)); } static void @@ -134,11 +134,11 @@ assert_submenu (GObject *parent, GObject *child) { if (GTK_IS_MENU_ITEM (parent)) - g_assert (gtk_menu_item_get_submenu (GTK_MENU_ITEM (parent)) == GTK_WIDGET (child)); + g_assert_true (gtk_menu_item_get_submenu (GTK_MENU_ITEM (parent)) == GTK_WIDGET (child)); else if (GTK_IS_MENU_TOOL_BUTTON (parent)) - g_assert (gtk_menu_tool_button_get_menu (GTK_MENU_TOOL_BUTTON (parent)) == GTK_WIDGET (child)); + g_assert_true (gtk_menu_tool_button_get_menu (GTK_MENU_TOOL_BUTTON (parent)) == GTK_WIDGET (child)); else - g_assert_not_reached (); + g_assert_true (FALSE); } static void @@ -148,7 +148,7 @@ assert_cell_parented (GObject *parent, GList *cells; cells = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (parent)); - g_assert (g_list_find (cells, child) != NULL); + g_assert_true (g_list_find (cells, child) != NULL); g_list_free (cells); } @@ -156,7 +156,7 @@ static void assert_column_parented (GObject *parent, GObject *child) { - g_assert (gtk_tree_view_get_column (GTK_TREE_VIEW (parent), 0) == GTK_TREE_VIEW_COLUMN (child)); + g_assert_true (gtk_tree_view_get_column (GTK_TREE_VIEW (parent), 0) == GTK_TREE_VIEW_COLUMN (child)); } /* Ignore deprecated classes, we test them regardless */ diff --git a/tests/create-widgets.c b/tests/create-widgets.c index e09acc6b..ea39d263 100644 --- a/tests/create-widgets.c +++ b/tests/create-widgets.c @@ -46,10 +46,10 @@ test_create_widget (gconstpointer data) widget = glade_widget_adaptor_create_widget (adaptor, FALSE, NULL); - g_assert (GLADE_IS_WIDGET (widget)); + g_assert_true (GLADE_IS_WIDGET (widget)); object = glade_widget_get_object (widget); - g_assert (G_IS_OBJECT (object)); + g_assert_true (G_IS_OBJECT (object)); g_object_weak_ref (G_OBJECT (widget), check_finalized, &widget_finalized); g_object_weak_ref (G_OBJECT (object), check_finalized, &object_finalized); @@ -72,8 +72,8 @@ test_create_widget (gconstpointer data) */ g_object_unref (widget); - g_assert (widget_finalized); - g_assert (object_finalized); + g_assert_true (widget_finalized); + g_assert_true (object_finalized); } static gint diff --git a/tests/modules.c b/tests/modules.c index ac087988..53f17e72 100644 --- a/tests/modules.c +++ b/tests/modules.c @@ -11,15 +11,15 @@ test_object_class (gconstpointer data) GladeWidget *widget; GObject *object; - g_assert (GLADE_IS_WIDGET_ADAPTOR (adaptor)); + g_assert_true (GLADE_IS_WIDGET_ADAPTOR (adaptor)); widget = glade_widget_adaptor_create_widget (adaptor, FALSE, NULL); - g_assert (GLADE_IS_WIDGET (widget)); + g_assert_true (GLADE_IS_WIDGET (widget)); object = glade_widget_get_object (widget); - g_assert (G_IS_OBJECT (object)); + g_assert_true (G_IS_OBJECT (object)); - g_assert (g_strcmp0 (G_OBJECT_TYPE_NAME (object), data) == 0); + g_assert_true (g_strcmp0 (G_OBJECT_TYPE_NAME (object), data) == 0); g_object_unref (widget); } diff --git a/tests/toplevel-order.c b/tests/toplevel-order.c index 2007845d..104f7f00 100644 --- a/tests/toplevel-order.c +++ b/tests/toplevel-order.c @@ -34,7 +34,7 @@ test_tsort_order (gconstpointer userdata) g_assert_cmpstr (l->data, ==, *orig_nodes); /* make sure all items where tested */ - g_assert (l == NULL && *orig_nodes == NULL); + g_assert_true (l == NULL && *orig_nodes == NULL); g_list_free (nodes); } @@ -72,38 +72,38 @@ test_toplevel_order (gconstpointer userdata) gsize xml_size; GBytes *xml; - g_assert (g_close (g_file_open_tmp ("glade-toplevel-order-XXXXXX.glade", &temp_path, NULL), NULL)); + g_assert_true (g_close (g_file_open_tmp ("glade-toplevel-order-XXXXXX.glade", &temp_path, NULL), NULL)); /* Dump contents to a temp file */ - g_assert ((xml = g_resources_lookup_data (project_path, 0, NULL))); + g_assert_true ((xml = g_resources_lookup_data (project_path, 0, NULL))); xml_data = g_bytes_get_data (xml, &xml_size); - g_assert (g_file_set_contents (temp_path, xml_data, xml_size, NULL)); + g_assert_true (g_file_set_contents (temp_path, xml_data, xml_size, NULL)); g_bytes_unref (xml); /* Load project */ - g_assert ((project = glade_project_load (temp_path))); + g_assert_true ((project = glade_project_load (temp_path))); /* And save it, order should be the same */ - g_assert (glade_project_save (project, temp_path, NULL)); + g_assert_true (glade_project_save (project, temp_path, NULL)); g_object_unref (project); /* Reload saved project */ - g_assert ((project = glade_project_load (temp_path))); + g_assert_true ((project = glade_project_load (temp_path))); g_unlink (temp_path); /* And get toplevels to check order */ - g_assert ((toplevels = glade_project_toplevels (project))); + g_assert_true ((toplevels = glade_project_toplevels (project))); for (l = toplevels; l && names; l = g_list_next (l), names++) { GladeWidget *toplevel; - g_assert ((toplevel = glade_widget_get_from_gobject (l->data))); + g_assert_true ((toplevel = glade_widget_get_from_gobject (l->data))); g_assert_cmpstr (glade_widget_get_name (toplevel), ==, *names); } /* make sure all items where tested */ - g_assert (!l && !*names); + g_assert_true (!l && !*names); g_list_free (toplevels); g_object_unref (project); |