tests: fix #10694 test suite fails due to use of g_assert

You are not supposed to use g_assert in tests because g_assert can be
disabled using -DG_DISABLE_ASSERT, which makes tests fail.

Instead let's use the recommended replacement g_assert_true. At this
time we are not bothering using more specific g_assert_* functions,
since there are plans to change our test suite.
This commit is contained in:
Jacob Boerema 2024-01-26 13:44:30 -05:00
parent 1148213825
commit 064fd69f18
6 changed files with 113 additions and 113 deletions

View File

@ -194,10 +194,10 @@ gimp_test_session_load_and_write_session_files (const gchar *loaded_sessionrc,
dockrc_file = gimp_directory_file (expected_dockrc, NULL);
/* Remember the modtimes and MD5s */
g_assert (gimp_test_get_file_state_verbose (sessionrc_file,
&initial_sessionrc_state));
g_assert (gimp_test_get_file_state_verbose (dockrc_file,
&initial_dockrc_state));
g_assert_true (gimp_test_get_file_state_verbose (sessionrc_file,
&initial_sessionrc_state));
g_assert_true (gimp_test_get_file_state_verbose (dockrc_file,
&initial_dockrc_state));
/* Use specific input files when restoring the session */
g_setenv ("GIMP_TESTING_SESSIONRC_NAME", loaded_sessionrc, TRUE /*overwrite*/);
@ -232,10 +232,10 @@ gimp_test_session_load_and_write_session_files (const gchar *loaded_sessionrc,
gimp_exit (gimp, TRUE);
/* Now get the new modtimes and MD5s */
g_assert (gimp_test_get_file_state_verbose (sessionrc_file,
&final_sessionrc_state));
g_assert (gimp_test_get_file_state_verbose (dockrc_file,
&final_dockrc_state));
g_assert_true (gimp_test_get_file_state_verbose (sessionrc_file,
&final_sessionrc_state));
g_assert_true (gimp_test_get_file_state_verbose (dockrc_file,
&final_dockrc_state));
/* If things have gone our way, GIMP will have deserialized
* sessionrc and dockrc, shown the GUI, and then serialized the new
@ -243,10 +243,10 @@ gimp_test_session_load_and_write_session_files (const gchar *loaded_sessionrc,
* to make sure that their content remains the same we compare their
* MD5
*/
g_assert (gimp_test_file_state_changes (g_file_new_for_path ("sessionrc"),
&initial_sessionrc_state,
&final_sessionrc_state));
g_assert (gimp_test_file_state_changes (g_file_new_for_path ("dockrc"),
&initial_dockrc_state,
&final_dockrc_state));
g_assert_true (gimp_test_file_state_changes (g_file_new_for_path ("sessionrc"),
&initial_sessionrc_state,
&final_sessionrc_state));
g_assert_true (gimp_test_file_state_changes (g_file_new_for_path ("dockrc"),
&initial_dockrc_state,
&final_dockrc_state));
}

View File

@ -70,7 +70,7 @@ gimp_test_id_table_insert_and_lookup (GimpTestFixture *f,
gint ret_id = gimp_id_table_insert (f->id_table, data1);
gpointer ret_data = gimp_id_table_lookup (f->id_table, ret_id);
g_assert (ret_data == data1);
g_assert_true (ret_data == data1);
}
/**
@ -87,9 +87,9 @@ gimp_test_id_table_insert_twice (GimpTestFixture *f,
gint ret_id2 = gimp_id_table_insert (f->id_table, data2);
gpointer ret_data2 = gimp_id_table_lookup (f->id_table, ret_id2);
g_assert (ret_id != ret_id2);
g_assert (ret_data == data1);
g_assert (ret_data2 == data2);
g_assert_true (ret_id != ret_id2);
g_assert_true (ret_data == data1);
g_assert_true (ret_data2 == data2);
}
/**
@ -106,8 +106,8 @@ gimp_test_id_table_insert_with_id (GimpTestFixture *f,
int ret_id = gimp_id_table_insert_with_id (f->id_table, id, data1);
gpointer ret_data = gimp_id_table_lookup (f->id_table, id);
g_assert (ret_id == id);
g_assert (ret_data == data1);
g_assert_true (ret_id == id);
g_assert_true (ret_data == data1);
}
/**
@ -127,10 +127,10 @@ gimp_test_id_table_insert_with_id_existing (GimpTestFixture *f,
int ret_id2 = gimp_id_table_insert_with_id (f->id_table, id, data2);
gpointer ret_data2 = gimp_id_table_lookup (f->id_table, ret_id2);
g_assert (id == ret_id);
g_assert (ret_id2 == -1);
g_assert (ret_data == data1);
g_assert (ret_data2 == NULL);
g_assert_true (id == ret_id);
g_assert_true (ret_id2 == -1);
g_assert_true (ret_data == data1);
g_assert_true (ret_data2 == NULL);
}
/**
@ -149,7 +149,7 @@ gimp_test_id_table_replace (GimpTestFixture *f,
gimp_id_table_replace (f->id_table, ret_id, data2);
ret_data = gimp_id_table_lookup (f->id_table, ret_id);
g_assert (ret_data == data2);
g_assert_true (ret_data == data2);
}
/**
@ -169,7 +169,7 @@ gimp_test_id_table_replace_as_insert (GimpTestFixture *f,
gimp_id_table_replace (f->id_table, id, data1);
ret_data = gimp_id_table_lookup (f->id_table, id);
g_assert (ret_data == data1);
g_assert_true (ret_data == data1);
}
/**
@ -186,9 +186,9 @@ gimp_test_id_table_remove (GimpTestFixture *f,
gboolean remove_successful = gimp_id_table_remove (f->id_table, ret_id);
void *ret_data2 = gimp_id_table_lookup (f->id_table, ret_id);
g_assert (remove_successful);
g_assert (ret_data == data1);
g_assert (ret_data2 == NULL);
g_assert_true (remove_successful);
g_assert_true (ret_data == data1);
g_assert_true (ret_data2 == NULL);
}
/**
@ -206,8 +206,8 @@ gimp_test_id_table_remove_non_existing (GimpTestFixture *f,
gboolean remove_successful = gimp_id_table_remove (f->id_table, id);
void *ret_data = gimp_id_table_lookup (f->id_table, id);
g_assert (! remove_successful);
g_assert (ret_data == NULL);
g_assert_true (! remove_successful);
g_assert_true (ret_data == NULL);
}
int main(int argc, char **argv)

View File

@ -87,9 +87,9 @@ new_file_has_no_files (gconstpointer data)
Gimp *gimp = GIMP (data);
GimpImage *image = gimp_test_utils_create_image_from_dialog (gimp);
g_assert (gimp_image_get_file (image) == NULL);
g_assert (gimp_image_get_imported_file (image) == NULL);
g_assert (gimp_image_get_exported_file (image) == NULL);
g_assert_true (gimp_image_get_file (image) == NULL);
g_assert_true (gimp_image_get_imported_file (image) == NULL);
g_assert_true (gimp_image_get_exported_file (image) == NULL);
}
/**
@ -125,9 +125,9 @@ opened_xcf_file_files (gconstpointer data)
NULL /*mime_type*/,
NULL /*error*/);
g_assert (g_file_equal (gimp_image_get_file (image), file));
g_assert (gimp_image_get_imported_file (image) == NULL);
g_assert (gimp_image_get_exported_file (image) == NULL);
g_assert_true (g_file_equal (gimp_image_get_file (image), file));
g_assert_true (gimp_image_get_imported_file (image) == NULL);
g_assert_true (gimp_image_get_exported_file (image) == NULL);
g_object_unref (file);
}
@ -150,7 +150,7 @@ imported_file_files (gconstpointer data)
filename = g_build_filename (g_getenv ("GIMP_TESTING_ABS_TOP_SRCDIR"),
"desktop/64x64/gimp.png",
NULL);
g_assert (g_file_test (filename, G_FILE_TEST_EXISTS));
g_assert_true (g_file_test (filename, G_FILE_TEST_EXISTS));
file = g_file_new_for_path (filename);
g_free (filename);
@ -165,9 +165,9 @@ imported_file_files (gconstpointer data)
NULL /*mime_type*/,
NULL /*error*/);
g_assert (gimp_image_get_file (image) == NULL);
g_assert (g_file_equal (gimp_image_get_imported_file (image), file));
g_assert (gimp_image_get_exported_file (image) == NULL);
g_assert_true (gimp_image_get_file (image) == NULL);
g_assert_true (g_file_equal (gimp_image_get_imported_file (image), file));
g_assert_true (gimp_image_get_exported_file (image) == NULL);
g_object_unref (file);
}
@ -232,9 +232,9 @@ saved_imported_file_files (gconstpointer data)
NULL /*error*/);
/* Assert */
g_assert (g_file_equal (gimp_image_get_file (image), save_file));
g_assert (gimp_image_get_imported_file (image) == NULL);
g_assert (gimp_image_get_exported_file (image) == NULL);
g_assert_true (g_file_equal (gimp_image_get_file (image), save_file));
g_assert_true (gimp_image_get_imported_file (image) == NULL);
g_assert_true (gimp_image_get_exported_file (image) == NULL);
g_file_delete (save_file, NULL, NULL);
g_object_unref (save_file);
@ -275,9 +275,9 @@ exported_file_files (gconstpointer data)
TRUE /*export_forward*/,
NULL /*error*/);
g_assert (gimp_image_get_file (image) == NULL);
g_assert (gimp_image_get_imported_file (image) == NULL);
g_assert (g_file_equal (gimp_image_get_exported_file (image), save_file));
g_assert_true (gimp_image_get_file (image) == NULL);
g_assert_true (gimp_image_get_imported_file (image) == NULL);
g_assert_true (g_file_equal (gimp_image_get_exported_file (image), save_file));
g_file_delete (save_file, NULL, NULL);
g_object_unref (save_file);
@ -320,9 +320,9 @@ clear_import_file_after_export (gconstpointer data)
NULL /*mime_type*/,
NULL /*error*/);
g_assert (gimp_image_get_file (image) == NULL);
g_assert (g_file_equal (gimp_image_get_imported_file (image), file));
g_assert (gimp_image_get_exported_file (image) == NULL);
g_assert_true (gimp_image_get_file (image) == NULL);
g_assert_true (g_file_equal (gimp_image_get_imported_file (image), file));
g_assert_true (gimp_image_get_exported_file (image) == NULL);
g_object_unref (file);
@ -345,9 +345,9 @@ clear_import_file_after_export (gconstpointer data)
TRUE /*export_forward*/,
NULL /*error*/);
g_assert (gimp_image_get_file (image) == NULL);
g_assert (gimp_image_get_imported_file (image) == NULL);
g_assert (g_file_equal (gimp_image_get_exported_file (image), save_file));
g_assert_true (gimp_image_get_file (image) == NULL);
g_assert_true (gimp_image_get_imported_file (image) == NULL);
g_assert_true (g_file_equal (gimp_image_get_exported_file (image), save_file));
g_file_delete (save_file, NULL, NULL);
g_object_unref (save_file);

View File

@ -160,8 +160,8 @@ gimp_tools_set_tool (Gimp *gimp,
static GimpDisplay *
gimp_test_get_only_display (Gimp *gimp)
{
g_assert (g_list_length (gimp_get_image_iter (gimp)) == 1);
g_assert (g_list_length (gimp_get_display_iter (gimp)) == 1);
g_assert_true (g_list_length (gimp_get_image_iter (gimp)) == 1);
g_assert_true (g_list_length (gimp_get_display_iter (gimp)) == 1);
return GIMP_DISPLAY (gimp_get_display_iter (gimp)->data);
}
@ -192,8 +192,8 @@ gimp_test_get_only_display_shell (Gimp *gimp)
static GimpImage *
gimp_test_get_only_image (Gimp *gimp)
{
g_assert (g_list_length (gimp_get_image_iter (gimp)) == 1);
g_assert (g_list_length (gimp_get_display_iter (gimp)) == 1);
g_assert_true (g_list_length (gimp_get_image_iter (gimp)) == 1);
g_assert_true (g_list_length (gimp_get_display_iter (gimp)) == 1);
return GIMP_IMAGE (gimp_get_image_iter (gimp)->data);
}
@ -211,8 +211,8 @@ gimp_test_synthesize_tool_button_event (GimpDisplayShell *shell,
GdkDisplay *display = gdk_window_get_display (window);
GdkSeat *seat = gdk_display_get_default_seat (display);
g_assert (button_event_type == GDK_BUTTON_PRESS ||
button_event_type == GDK_BUTTON_RELEASE);
g_assert_true (button_event_type == GDK_BUTTON_PRESS ||
button_event_type == GDK_BUTTON_RELEASE);
gdk_event_set_device (event, gdk_seat_get_pointer (seat));
@ -275,8 +275,8 @@ gimp_test_synthesize_tool_crossing_event (GimpDisplayShell *shell,
GdkDisplay *display = gdk_window_get_display (window);
GdkSeat *seat = gdk_display_get_default_seat (display);
g_assert (crossing_event_type == GDK_ENTER_NOTIFY ||
crossing_event_type == GDK_LEAVE_NOTIFY);
g_assert_true (crossing_event_type == GDK_ENTER_NOTIFY ||
crossing_event_type == GDK_LEAVE_NOTIFY);
gdk_event_set_device (event, gdk_seat_get_pointer (seat));

View File

@ -294,41 +294,41 @@ alt_click_is_layer_to_selection (gconstpointer data)
GTK_TYPE_TREE_VIEW);
/* First make sure there is no selection */
g_assert (gimp_channel_is_empty (selection));
g_assert_true (gimp_channel_is_empty (selection));
/* Now simulate alt-click on the background layer */
g_assert (gimp_ui_synthesize_click (gtk_tree_view,
assumed_layer_x,
assumed_background_layer_y,
1 /*button*/,
GDK_MOD1_MASK));
g_assert_true (gimp_ui_synthesize_click (gtk_tree_view,
assumed_layer_x,
assumed_background_layer_y,
1 /*button*/,
GDK_MOD1_MASK));
gimp_test_run_mainloop_until_idle ();
/* Make sure we got a selection and that the active layer didn't
* change
*/
g_assert (! gimp_channel_is_empty (selection));
g_assert (g_list_length (gimp_image_get_selected_layers (image)) ==
g_list_length (selected_layers));
g_assert_true (! gimp_channel_is_empty (selection));
g_assert_true (g_list_length (gimp_image_get_selected_layers (image)) ==
g_list_length (selected_layers));
for (iter = selected_layers; iter; iter = iter->next)
g_assert (g_list_find (gimp_image_get_selected_layers (image), iter->data));
g_assert_true (g_list_find (gimp_image_get_selected_layers (image), iter->data));
/* Now simulate alt-click on the empty layer */
g_assert (gimp_ui_synthesize_click (gtk_tree_view,
assumed_layer_x,
assumed_empty_layer_y,
1 /*button*/,
GDK_MOD1_MASK));
g_assert_true (gimp_ui_synthesize_click (gtk_tree_view,
assumed_layer_x,
assumed_empty_layer_y,
1 /*button*/,
GDK_MOD1_MASK));
gimp_test_run_mainloop_until_idle ();
/* Make sure that emptied the selection and that the active layer
* still didn't change
*/
g_assert (gimp_channel_is_empty (selection));
g_assert (g_list_length (gimp_image_get_selected_layers (image)) ==
g_list_length (selected_layers));
g_assert_true (gimp_channel_is_empty (selection));
g_assert_true (g_list_length (gimp_image_get_selected_layers (image)) ==
g_list_length (selected_layers));
for (iter = selected_layers; iter; iter = iter->next)
g_assert (g_list_find (gimp_image_get_selected_layers (image), iter->data));
g_assert_true (g_list_find (gimp_image_get_selected_layers (image), iter->data));
g_list_free (selected_layers);
#endif
@ -347,7 +347,7 @@ restore_recently_closed_multi_column_dock (gconstpointer data)
/* Find a non-toolbox dock window */
dock_window = gimp_ui_find_window (gimp_dialog_factory_get_singleton (),
gimp_ui_multicolumn_not_toolbox_window);
g_assert (dock_window != NULL);
g_assert_true (dock_window != NULL);
/* Count number of docks */
session_infos = gimp_dialog_factory_get_session_infos (gimp_dialog_factory_get_singleton ());
@ -404,8 +404,8 @@ tab_toggle_dont_change_dock_window_position (gconstpointer data)
/* Find a non-toolbox dock window */
dock_window = gimp_ui_find_window (gimp_dialog_factory_get_singleton (),
gimp_ui_not_toolbox_window);
g_assert (dock_window != NULL);
g_assert (gtk_widget_get_visible (dock_window));
g_assert_true (dock_window != NULL);
g_assert_true (gtk_widget_get_visible (dock_window));
/* Get the position and size */
gimp_test_run_mainloop_until_idle ();
@ -421,14 +421,14 @@ tab_toggle_dont_change_dock_window_position (gconstpointer data)
"windows",
"windows-hide-docks");
gimp_test_run_mainloop_until_idle ();
g_assert (! gtk_widget_get_visible (dock_window));
g_assert_true (! gtk_widget_get_visible (dock_window));
/* Show them again */
gimp_ui_manager_activate_action (gimp_test_utils_get_ui_manager (gimp),
"windows",
"windows-hide-docks");
gimp_test_run_mainloop_until_idle ();
g_assert (gtk_widget_get_visible (dock_window));
g_assert_true (gtk_widget_get_visible (dock_window));
/* Get the position and size again and make sure it's the same as
* before
@ -468,8 +468,8 @@ gimp_ui_toggle_docks_in_single_window_mode (Gimp *gimp)
gint y_before_hide = -1;
gint x_after_hide = -1;
gint y_after_hide = -1;
g_assert (shell);
g_assert (toplevel);
g_assert_true (shell);
g_assert_true (toplevel);
/* Get toplevel coordinate of image origin */
gimp_test_run_mainloop_until_idle ();
@ -552,11 +552,11 @@ maximize_state_in_aux_data (gconstpointer data)
gimp_test_run_mainloop_until_idle ();
/* Make sure the maximize/unmaximize happened */
g_assert (gimp_image_window_is_maximized (window) == target_max_state);
g_assert_true (gimp_image_window_is_maximized (window) == target_max_state);
/* Make sure we can read out the window state again */
aux_info = gimp_session_managed_get_aux_info (GIMP_SESSION_MANAGED (window));
g_assert (g_list_find_custom (aux_info, target_info, gimp_ui_aux_data_eqiuvalent));
g_assert_true (g_list_find_custom (aux_info, target_info, gimp_ui_aux_data_eqiuvalent));
g_list_free_full (aux_info,
(GDestroyNotify) gimp_session_info_aux_free);
@ -736,7 +736,7 @@ gimp_ui_synthesize_delete_event (GtkWidget *widget)
GdkEvent *event = NULL;
window = gtk_widget_get_window (widget);
g_assert (window);
g_assert_true (window);
event = gdk_event_new (GDK_DELETE);
event->any.window = g_object_ref (window);

View File

@ -323,7 +323,7 @@ gimp_write_and_read_file (Gimp *gimp,
/* Write to file */
file_handle = g_file_open_tmp ("gimp-test-XXXXXX.xcf", &filename, NULL);
g_assert (file_handle != -1);
g_assert_true (file_handle != -1);
close (file_handle);
file = g_file_new_for_path (filename);
g_free (filename);
@ -691,10 +691,10 @@ gimp_assert_vectors (GimpImage *image,
vectors = gimp_image_get_vectors_by_name (image, name);
stroke = gimp_vectors_stroke_get_next (vectors, NULL);
g_assert (stroke != NULL);
g_assert_true (stroke != NULL);
control_points = gimp_stroke_control_points_get (stroke,
&closed);
g_assert (closed);
g_assert_true (closed);
g_assert_cmpint (control_points->len,
==,
coords_size);
@ -712,8 +712,8 @@ gimp_assert_vectors (GimpImage *image,
i).position.y);
}
g_assert (gimp_item_get_visible (GIMP_ITEM (vectors)) ? TRUE : FALSE ==
visible ? TRUE : FALSE);
g_assert_true (gimp_item_get_visible (GIMP_ITEM (vectors)) ? TRUE : FALSE ==
visible ? TRUE : FALSE);
}
/**
@ -809,37 +809,37 @@ gimp_assert_mainimage (GimpImage *image,
/* Guides, note that we rely on internal ordering */
iter = gimp_image_get_guides (image);
g_assert (iter != NULL);
g_assert_true (iter != NULL);
guide = iter->data;
g_assert_cmpint (gimp_guide_get_position (guide),
==,
GIMP_MAINIMAGE_VGUIDE1_POS);
iter = g_list_next (iter);
g_assert (iter != NULL);
g_assert_true (iter != NULL);
guide = iter->data;
g_assert_cmpint (gimp_guide_get_position (guide),
==,
GIMP_MAINIMAGE_VGUIDE2_POS);
iter = g_list_next (iter);
g_assert (iter != NULL);
g_assert_true (iter != NULL);
guide = iter->data;
g_assert_cmpint (gimp_guide_get_position (guide),
==,
GIMP_MAINIMAGE_HGUIDE1_POS);
iter = g_list_next (iter);
g_assert (iter != NULL);
g_assert_true (iter != NULL);
guide = iter->data;
g_assert_cmpint (gimp_guide_get_position (guide),
==,
GIMP_MAINIMAGE_HGUIDE2_POS);
iter = g_list_next (iter);
g_assert (iter == NULL);
g_assert_true (iter == NULL);
/* Sample points, we rely on the same ordering as when we added
* them, although this ordering is not a necessity
*/
iter = gimp_image_get_sample_points (image);
g_assert (iter != NULL);
g_assert_true (iter != NULL);
sample_point = iter->data;
gimp_sample_point_get_position (sample_point,
&sample_point_x, &sample_point_y);
@ -850,7 +850,7 @@ gimp_assert_mainimage (GimpImage *image,
==,
GIMP_MAINIMAGE_SAMPLEPOINT1_Y);
iter = g_list_next (iter);
g_assert (iter != NULL);
g_assert_true (iter != NULL);
sample_point = iter->data;
gimp_sample_point_get_position (sample_point,
&sample_point_x, &sample_point_y);
@ -861,7 +861,7 @@ gimp_assert_mainimage (GimpImage *image,
==,
GIMP_MAINIMAGE_SAMPLEPOINT2_Y);
iter = g_list_next (iter);
g_assert (iter == NULL);
g_assert_true (iter == NULL);
/* Resolution */
gimp_image_get_resolution (image, &xres, &yres);
@ -926,9 +926,9 @@ gimp_assert_mainimage (GimpImage *image,
g_assert_cmpint (gimp_item_get_height (GIMP_ITEM (channel)),
==,
GIMP_MAINIMAGE_CHANNEL1_HEIGHT);
g_assert (memcmp (&expected_channel_color,
&actual_channel_color,
sizeof (GimpRGB)) == 0);
g_assert_true (memcmp (&expected_channel_color,
&actual_channel_color,
sizeof (GimpRGB)) == 0);
/* Selection, if the image contains unusual stuff it contains a
* floating select, and when floating a selection, the selection
@ -968,9 +968,9 @@ gimp_assert_mainimage (GimpImage *image,
FALSE /*visible*/);
if (with_unusual_stuff)
g_assert (gimp_image_get_floating_selection (image) != NULL);
g_assert_true (gimp_image_get_floating_selection (image) != NULL);
else /* if (! with_unusual_stuff) */
g_assert (gimp_image_get_floating_selection (image) == NULL);
g_assert_true (gimp_image_get_floating_selection (image) == NULL);
if (use_gimp_2_8_features)
{
@ -983,11 +983,11 @@ gimp_assert_mainimage (GimpImage *image,
GimpItem *group2 = GIMP_ITEM (gimp_image_get_layer_by_name (image, GIMP_MAINIMAGE_GROUP2_NAME));
GimpItem *layer5 = GIMP_ITEM (gimp_image_get_layer_by_name (image, GIMP_MAINIMAGE_LAYER5_NAME));
g_assert (gimp_item_get_parent (group1) == NULL);
g_assert (gimp_item_get_parent (layer3) == group1);
g_assert (gimp_item_get_parent (layer4) == group1);
g_assert (gimp_item_get_parent (group2) == group1);
g_assert (gimp_item_get_parent (layer5) == group2);
g_assert_true (gimp_item_get_parent (group1) == NULL);
g_assert_true (gimp_item_get_parent (layer3) == group1);
g_assert_true (gimp_item_get_parent (layer4) == group1);
g_assert_true (gimp_item_get_parent (group2) == group1);
g_assert_true (gimp_item_get_parent (layer5) == group2);
}
}