diff options
author | Carlos Soriano <csoriano@gnome.org> | 2016-08-29 18:24:05 +0200 |
---|---|---|
committer | Carlos Soriano <csoriano@gnome.org> | 2016-08-29 18:37:10 +0200 |
commit | 52d960542b4d5fdf2bd06735d0dbf7934cf2ec12 (patch) | |
tree | 5e000d5ed40b52b003c02b597e51ae0b87ff22ac /test | |
parent | 4cafccd82859a4ee0bdfad3e31a310f2d94c0485 (diff) | |
download | nautilus-52d960542b4d5fdf2bd06735d0dbf7934cf2ec12.tar.gz |
general: run uncrustify
And make the style of Nautilus the same for all files.
Hopefully we can fix all the style issues we can find in the next days,
so expect a little of movement on this.
https://bugzilla.gnome.org/show_bug.cgi?id=770564
Diffstat (limited to 'test')
-rw-r--r-- | test/test-copy.c | 142 | ||||
-rw-r--r-- | test/test-eel-background.c | 35 | ||||
-rw-r--r-- | test/test-eel-string-get-common-prefix.c | 192 | ||||
-rw-r--r-- | test/test-eel-string-rtrim-punctuation.c | 123 | ||||
-rw-r--r-- | test/test-file-utilities-get-common-filename-prefix.c | 597 | ||||
-rw-r--r-- | test/test-nautilus-directory-async.c | 116 | ||||
-rw-r--r-- | test/test-nautilus-mime-actions-set.c | 251 | ||||
-rw-r--r-- | test/test-nautilus-mime-actions.c | 198 | ||||
-rw-r--r-- | test/test-nautilus-search-engine.c | 91 | ||||
-rw-r--r-- | test/test.c | 146 | ||||
-rw-r--r-- | test/uncrustify-sample.c | 63 |
11 files changed, 979 insertions, 975 deletions
diff --git a/test/test-copy.c b/test/test-copy.c index 428eea743..c927e47b1 100644 --- a/test/test-copy.c +++ b/test/test-copy.c @@ -5,96 +5,98 @@ #include <src/nautilus-progress-info-manager.h> static void -copy_done (GHashTable *debuting_uris, - gboolean success, - gpointer data) +copy_done (GHashTable *debuting_uris, + gboolean success, + gpointer data) { - g_print ("Copy done\n"); + g_print ("Copy done\n"); } static void changed_cb (NautilusProgressInfo *info, - gpointer data) + gpointer data) { - g_print ("Changed: %s -- %s\n", - nautilus_progress_info_get_status (info), - nautilus_progress_info_get_details (info)); + g_print ("Changed: %s -- %s\n", + nautilus_progress_info_get_status (info), + nautilus_progress_info_get_details (info)); } static void progress_changed_cb (NautilusProgressInfo *info, - gpointer data) + gpointer data) { - g_print ("Progress changed: %f\n", - nautilus_progress_info_get_progress (info)); + g_print ("Progress changed: %f\n", + nautilus_progress_info_get_progress (info)); } static void finished_cb (NautilusProgressInfo *info, - gpointer data) + gpointer data) { - g_print ("Finished\n"); - gtk_main_quit (); + g_print ("Finished\n"); + gtk_main_quit (); } -int -main (int argc, char* argv[]) +int +main (int argc, + char *argv[]) { - GtkWidget *window; - GList *sources; - GFile *dest; - GFile *source; - int i; - GList *infos; - NautilusProgressInfoManager *manager; - NautilusProgressInfo *progress_info; - - test_init (&argc, &argv); - - if (argc < 3) { - g_print ("Usage test-copy <sources...> <dest dir>\n"); - return 1; - } - - sources = NULL; - for (i = 1; i < argc - 1; i++) { - source = g_file_new_for_commandline_arg (argv[i]); - sources = g_list_prepend (sources, source); - } - sources = g_list_reverse (sources); - - dest = g_file_new_for_commandline_arg (argv[i]); - - window = test_window_new ("copy test", 5); - - gtk_widget_show (window); - - manager = nautilus_progress_info_manager_dup_singleton (); - - nautilus_file_operations_copy (sources, - NULL /* GArray *relative_item_points */, - dest, - GTK_WINDOW (window), - copy_done, NULL); - - infos = nautilus_progress_info_manager_get_all_infos (manager); - - if (infos == NULL) { - g_object_unref (manager); - return 0; - } - - progress_info = NAUTILUS_PROGRESS_INFO (infos->data); - - g_signal_connect (progress_info, "changed", (GCallback)changed_cb, NULL); - g_signal_connect (progress_info, "progress-changed", (GCallback)progress_changed_cb, NULL); - g_signal_connect (progress_info, "finished", (GCallback)finished_cb, NULL); - - gtk_main (); + GtkWidget *window; + GList *sources; + GFile *dest; + GFile *source; + int i; + GList *infos; + NautilusProgressInfoManager *manager; + NautilusProgressInfo *progress_info; + test_init (&argc, &argv); + + if (argc < 3) + { + g_print ("Usage test-copy <sources...> <dest dir>\n"); + return 1; + } + + sources = NULL; + for (i = 1; i < argc - 1; i++) + { + source = g_file_new_for_commandline_arg (argv[i]); + sources = g_list_prepend (sources, source); + } + sources = g_list_reverse (sources); + + dest = g_file_new_for_commandline_arg (argv[i]); + + window = test_window_new ("copy test", 5); + + gtk_widget_show (window); + + manager = nautilus_progress_info_manager_dup_singleton (); + + nautilus_file_operations_copy (sources, + NULL /* GArray *relative_item_points */, + dest, + GTK_WINDOW (window), + copy_done, NULL); + + infos = nautilus_progress_info_manager_get_all_infos (manager); + + if (infos == NULL) + { g_object_unref (manager); - - return 0; -} + return 0; + } + + progress_info = NAUTILUS_PROGRESS_INFO (infos->data); + g_signal_connect (progress_info, "changed", (GCallback) changed_cb, NULL); + g_signal_connect (progress_info, "progress-changed", (GCallback) progress_changed_cb, NULL); + g_signal_connect (progress_info, "finished", (GCallback) finished_cb, NULL); + gtk_main (); + + g_object_unref (manager); + + return 0; +} diff --git a/test/test-eel-background.c b/test/test-eel-background.c index cb2e897ab..047508890 100644 --- a/test/test-eel-background.c +++ b/test/test-eel-background.c @@ -6,33 +6,34 @@ #define PATTERNS_DIR "/gnome-source/eel/data/patterns" int -main (int argc, char *argv[]) +main (int argc, + char *argv[]) { - GtkWidget *window; - EelBackground *background; - char *image_uri; + GtkWidget *window; + EelBackground *background; + char *image_uri; - gtk_init (&argc, &argv); + gtk_init (&argc, &argv); - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - g_signal_connect (window, "destroy", - gtk_main_quit, NULL); + window = gtk_window_new (GTK_WINDOW_TOPLEVEL); + g_signal_connect (window, "destroy", + gtk_main_quit, NULL); - background = eel_get_widget_background (window); + background = eel_get_widget_background (window); - eel_background_set_color (background, - "red-blue:h"); + eel_background_set_color (background, + "red-blue:h"); - image_uri = g_filename_to_uri (PATTERNS_DIR "/50s.png", NULL, NULL); + image_uri = g_filename_to_uri (PATTERNS_DIR "/50s.png", NULL, NULL); #if 1 - eel_background_set_image_uri (background, image_uri); + eel_background_set_image_uri (background, image_uri); #endif - g_free (image_uri); + g_free (image_uri); - gtk_widget_show_all (window); - gtk_main (); + gtk_widget_show_all (window); + gtk_main (); - return 0; + return 0; } diff --git a/test/test-eel-string-get-common-prefix.c b/test/test-eel-string-get-common-prefix.c index 140b0be74..2dc5d9e9a 100644 --- a/test/test-eel-string-get-common-prefix.c +++ b/test/test-eel-string-get-common-prefix.c @@ -5,184 +5,186 @@ static void -free_list_and_result (GList *list, char *result) +free_list_and_result (GList *list, + char *result) { - g_list_free (list); - g_free (result); + g_list_free (list); + g_free (result); } static void test_has_large_enough_common_prefix () { - GList *list = NULL; - char *actual; + GList *list = NULL; + char *actual; - list = g_list_append (list, "foo-1.txt"); - list = g_list_append (list, "foo-1.tar"); + list = g_list_append (list, "foo-1.txt"); + list = g_list_append (list, "foo-1.tar"); - actual = eel_str_get_common_prefix (list, 4); - g_assert_cmpstr ("foo-1.t", ==, actual); + actual = eel_str_get_common_prefix (list, 4); + g_assert_cmpstr ("foo-1.t", ==, actual); - free_list_and_result (list, actual); + free_list_and_result (list, actual); } static void test_has_common_prefix_that_equals_the_min_required_length () { - GList *list = NULL; - char *actual; + GList *list = NULL; + char *actual; - list = g_list_append (list, "food"); - list = g_list_append (list, "foody"); + list = g_list_append (list, "food"); + list = g_list_append (list, "foody"); - actual = eel_str_get_common_prefix (list, 4); - g_assert_cmpstr ("food", ==, actual); + actual = eel_str_get_common_prefix (list, 4); + g_assert_cmpstr ("food", ==, actual); - free_list_and_result (list, actual); + free_list_and_result (list, actual); } static void test_has_common_prefix_that_equals_the_min_required_length2 () { - GList *list = NULL; - char *actual; + GList *list = NULL; + char *actual; - list = g_list_append (list, "foody"); - list = g_list_append (list, "food"); + list = g_list_append (list, "foody"); + list = g_list_append (list, "food"); - actual = eel_str_get_common_prefix (list, 4); - g_assert_cmpstr ("food", ==, actual); + actual = eel_str_get_common_prefix (list, 4); + g_assert_cmpstr ("food", ==, actual); - free_list_and_result (list, actual); + free_list_and_result (list, actual); } static void test_many_strings_with_common_prefix () { - GList *list = NULL; - char *actual; + GList *list = NULL; + char *actual; - list = g_list_append (list, "some text that matches abcde"); - list = g_list_append (list, "some text that matches abc22"); - list = g_list_append (list, "some text that 11"); - list = g_list_append (list, "some text that matches---"); - list = g_list_append (list, "some text that matches £$$"); - list = g_list_append (list, "some text that matches.txt"); + list = g_list_append (list, "some text that matches abcde"); + list = g_list_append (list, "some text that matches abc22"); + list = g_list_append (list, "some text that 11"); + list = g_list_append (list, "some text that matches---"); + list = g_list_append (list, "some text that matches £$$"); + list = g_list_append (list, "some text that matches.txt"); - actual = eel_str_get_common_prefix (list, 4); - g_assert_cmpstr ("some text that ", ==, actual); + actual = eel_str_get_common_prefix (list, 4); + g_assert_cmpstr ("some text that ", ==, actual); - free_list_and_result (list, actual); + free_list_and_result (list, actual); } static void test_strings_with_unicode_characters_that_have_common_prefix () { - GList *list = NULL; - char *actual; + GList *list = NULL; + char *actual; - list = g_list_append (list, "ƹƱƱƬ"); - list = g_list_append (list, "ƹƱƱƬƧƥƧ"); + list = g_list_append (list, "ƹƱƱƬ"); + list = g_list_append (list, "ƹƱƱƬƧƥƧ"); - actual = eel_str_get_common_prefix (list, 4); - g_assert_cmpstr ("ƹƱƱƬ", ==, actual); + actual = eel_str_get_common_prefix (list, 4); + g_assert_cmpstr ("ƹƱƱƬ", ==, actual); - free_list_and_result (list, actual); + free_list_and_result (list, actual); } static void test_no_common_prefix () { - GList *list = NULL; - char *actual; + GList *list = NULL; + char *actual; - list = g_list_append (list, "fyod"); - list = g_list_append (list, "completely different string"); + list = g_list_append (list, "fyod"); + list = g_list_append (list, "completely different string"); - actual = eel_str_get_common_prefix (list, 4); - g_assert_null (actual); + actual = eel_str_get_common_prefix (list, 4); + g_assert_null (actual); - free_list_and_result (list, actual); + free_list_and_result (list, actual); } static void test_has_common_prefix_but_smaller_than_min_required_length () { - GList *list = NULL; - char *actual; + GList *list = NULL; + char *actual; - list = g_list_append (list, "fyod"); - list = g_list_append (list, "fyoa"); + list = g_list_append (list, "fyod"); + list = g_list_append (list, "fyoa"); - actual = eel_str_get_common_prefix (list, 4); - g_assert_null (actual); + actual = eel_str_get_common_prefix (list, 4); + g_assert_null (actual); - free_list_and_result (list, actual); + free_list_and_result (list, actual); } static void test_first_character_differs () { - GList *list = NULL; - char *actual; + GList *list = NULL; + char *actual; - list = g_list_append (list, "tyodaa"); - list = g_list_append (list, "fyodaa"); + list = g_list_append (list, "tyodaa"); + list = g_list_append (list, "fyodaa"); - actual = eel_str_get_common_prefix (list, 4); - g_assert_null (actual); + actual = eel_str_get_common_prefix (list, 4); + g_assert_null (actual); - free_list_and_result (list, actual); + free_list_and_result (list, actual); } static void test_strings_with_unicode_characters_that_dont_have_common_prefix () { - GList *list = NULL; - char *actual; + GList *list = NULL; + char *actual; - list = g_list_append (list, "ƹƱƱƬ"); - list = g_list_append (list, "ƹƱƢƱƬƧƥƧ"); + list = g_list_append (list, "ƹƱƱƬ"); + list = g_list_append (list, "ƹƱƢƱƬƧƥƧ"); - actual = eel_str_get_common_prefix (list, 4); - g_assert_null (actual); + actual = eel_str_get_common_prefix (list, 4); + g_assert_null (actual); - free_list_and_result (list, actual); + free_list_and_result (list, actual); } static void setup_test_suite () { - g_test_add_func ("/get-common-prefix/1.0", - test_has_large_enough_common_prefix); - g_test_add_func ("/get-common-prefix/1.1", - test_has_common_prefix_that_equals_the_min_required_length); - g_test_add_func ("/get-common-prefix/1.2", - test_has_common_prefix_that_equals_the_min_required_length2); - g_test_add_func ("/get-common-prefix/1.3", - test_many_strings_with_common_prefix); - g_test_add_func ("/get-common-prefix/1.4", - test_strings_with_unicode_characters_that_have_common_prefix); - - g_test_add_func ("/get-common-prefix/2.0", - test_no_common_prefix); - g_test_add_func ("/get-common-prefix/2.1", - test_has_common_prefix_but_smaller_than_min_required_length); - g_test_add_func ("/get-common-prefix/2.2", - test_first_character_differs); - g_test_add_func ("/get-common-prefix/2.3", - test_strings_with_unicode_characters_that_dont_have_common_prefix); + g_test_add_func ("/get-common-prefix/1.0", + test_has_large_enough_common_prefix); + g_test_add_func ("/get-common-prefix/1.1", + test_has_common_prefix_that_equals_the_min_required_length); + g_test_add_func ("/get-common-prefix/1.2", + test_has_common_prefix_that_equals_the_min_required_length2); + g_test_add_func ("/get-common-prefix/1.3", + test_many_strings_with_common_prefix); + g_test_add_func ("/get-common-prefix/1.4", + test_strings_with_unicode_characters_that_have_common_prefix); + + g_test_add_func ("/get-common-prefix/2.0", + test_no_common_prefix); + g_test_add_func ("/get-common-prefix/2.1", + test_has_common_prefix_but_smaller_than_min_required_length); + g_test_add_func ("/get-common-prefix/2.2", + test_first_character_differs); + g_test_add_func ("/get-common-prefix/2.3", + test_strings_with_unicode_characters_that_dont_have_common_prefix); } int -main (int argc, char *argv[]) +main (int argc, + char *argv[]) { - g_test_init (&argc, &argv, NULL); - g_test_bug_base ("http://bugzilla.gnome.org/show_bug.cgi?id=747907"); - g_test_set_nonfatal_assertions (); + g_test_init (&argc, &argv, NULL); + g_test_bug_base ("http://bugzilla.gnome.org/show_bug.cgi?id=747907"); + g_test_set_nonfatal_assertions (); - setup_test_suite (); + setup_test_suite (); - return g_test_run (); + return g_test_run (); } diff --git a/test/test-eel-string-rtrim-punctuation.c b/test/test-eel-string-rtrim-punctuation.c index 3dc1f947f..526ac9fb4 100644 --- a/test/test-eel-string-rtrim-punctuation.c +++ b/test/test-eel-string-rtrim-punctuation.c @@ -6,116 +6,117 @@ static void test_single_punctuation_character_removed () { - char *actual; - actual = eel_str_rtrim_punctuation ("Yossarian-"); - g_assert_cmpstr ("Yossarian", ==, actual); - g_free (actual); + char *actual; + actual = eel_str_rtrim_punctuation ("Yossarian-"); + g_assert_cmpstr ("Yossarian", ==, actual); + g_free (actual); } static void test_tailing_space_is_removed () { - char *actual; - actual = eel_str_rtrim_punctuation ("Yossarian "); - g_assert_cmpstr ("Yossarian", ==, actual); - g_free (actual); + char *actual; + actual = eel_str_rtrim_punctuation ("Yossarian "); + g_assert_cmpstr ("Yossarian", ==, actual); + g_free (actual); } static void test_multiple_punctuation_characters_removed () { - char *actual; - actual = eel_str_rtrim_punctuation ("Yossarian-$$!£"); - g_assert_cmpstr ("Yossarian", ==, actual); - g_free (actual); + char *actual; + actual = eel_str_rtrim_punctuation ("Yossarian-$$!£"); + g_assert_cmpstr ("Yossarian", ==, actual); + g_free (actual); } static void test_multiple_punctuation_characters_removed_try_all_punctuation_characters () { - char *actual; - actual = eel_str_rtrim_punctuation ("Yossarian-`¬!\"£$%^&*()_+-= {}[]:@~;'#<>?,./\\"); - g_assert_cmpstr ("Yossarian", ==, actual); - g_free (actual); + char *actual; + actual = eel_str_rtrim_punctuation ("Yossarian-`¬!\"£$%^&*()_+-= {}[]:@~;'#<>?,./\\"); + g_assert_cmpstr ("Yossarian", ==, actual); + g_free (actual); } static void test_punctuation_characters_removed_when_punctuation_in_middle_of_string () { - char *actual; - actual = eel_str_rtrim_punctuation ("Yoss,,arian-$$!£"); - g_assert_cmpstr ("Yoss,,arian", ==, actual); - g_free (actual); + char *actual; + actual = eel_str_rtrim_punctuation ("Yoss,,arian-$$!£"); + g_assert_cmpstr ("Yoss,,arian", ==, actual); + g_free (actual); } static void test_punctuation_characters_removed_when_prefix_is_single_character () { - char *actual; - actual = eel_str_rtrim_punctuation ("Y-$$ !£"); - g_assert_cmpstr ("Y", ==, actual); - g_free (actual); + char *actual; + actual = eel_str_rtrim_punctuation ("Y-$$ !£"); + g_assert_cmpstr ("Y", ==, actual); + g_free (actual); } static void test_punctuation_characters_removed_when_unicode_characters_are_used () { - char *actual; - actual = eel_str_rtrim_punctuation ("Y✺ǨǨǨ-$$ !£"); - g_assert_cmpstr ("Y✺ǨǨǨ", ==, actual); - g_free (actual); + char *actual; + actual = eel_str_rtrim_punctuation ("Y✺ǨǨǨ-$$ !£"); + g_assert_cmpstr ("Y✺ǨǨǨ", ==, actual); + g_free (actual); } static void test_when_no_trailing_punctuation () { - char *actual; - actual = eel_str_rtrim_punctuation ("Yoss,,arian"); - g_assert_cmpstr ("Yoss,,arian", ==, actual); - g_free (actual); + char *actual; + actual = eel_str_rtrim_punctuation ("Yoss,,arian"); + g_assert_cmpstr ("Yoss,,arian", ==, actual); + g_free (actual); } static void test_when_single_character_and_no_trailing_punctuation () { - char *actual; - actual = eel_str_rtrim_punctuation ("t"); - g_assert_cmpstr ("t", ==, actual); - g_free (actual); + char *actual; + actual = eel_str_rtrim_punctuation ("t"); + g_assert_cmpstr ("t", ==, actual); + g_free (actual); } static void setup_test_suite () { - g_test_add_func ("/rtrim-punctuation/1.0", - test_single_punctuation_character_removed); - g_test_add_func ("/rtrim-punctuation/1.1", - test_tailing_space_is_removed); - g_test_add_func ("/rtrim-punctuation/1.2", - test_multiple_punctuation_characters_removed); - g_test_add_func ("/rtrim-punctuation/1.3", - test_multiple_punctuation_characters_removed_try_all_punctuation_characters); - g_test_add_func ("/rtrim-punctuation/1.4", - test_punctuation_characters_removed_when_punctuation_in_middle_of_string); - g_test_add_func ("/rtrim-punctuation/1.5", - test_punctuation_characters_removed_when_prefix_is_single_character); - g_test_add_func ("/rtrim-punctuation/1.6", - test_punctuation_characters_removed_when_unicode_characters_are_used); - - g_test_add_func ("/rtrim-punctuation/2.0", - test_when_no_trailing_punctuation); - g_test_add_func ("/rtrim-punctuation/2.1", - test_when_single_character_and_no_trailing_punctuation); + g_test_add_func ("/rtrim-punctuation/1.0", + test_single_punctuation_character_removed); + g_test_add_func ("/rtrim-punctuation/1.1", + test_tailing_space_is_removed); + g_test_add_func ("/rtrim-punctuation/1.2", + test_multiple_punctuation_characters_removed); + g_test_add_func ("/rtrim-punctuation/1.3", + test_multiple_punctuation_characters_removed_try_all_punctuation_characters); + g_test_add_func ("/rtrim-punctuation/1.4", + test_punctuation_characters_removed_when_punctuation_in_middle_of_string); + g_test_add_func ("/rtrim-punctuation/1.5", + test_punctuation_characters_removed_when_prefix_is_single_character); + g_test_add_func ("/rtrim-punctuation/1.6", + test_punctuation_characters_removed_when_unicode_characters_are_used); + + g_test_add_func ("/rtrim-punctuation/2.0", + test_when_no_trailing_punctuation); + g_test_add_func ("/rtrim-punctuation/2.1", + test_when_single_character_and_no_trailing_punctuation); } int -main (int argc, char *argv[]) +main (int argc, + char *argv[]) { - g_test_init (&argc, &argv, NULL); - g_test_bug_base ("http://bugzilla.gnome.org/show_bug.cgi?id=747907"); - g_test_set_nonfatal_assertions (); + g_test_init (&argc, &argv, NULL); + g_test_bug_base ("http://bugzilla.gnome.org/show_bug.cgi?id=747907"); + g_test_set_nonfatal_assertions (); - setup_test_suite (); + setup_test_suite (); - return g_test_run (); + return g_test_run (); } diff --git a/test/test-file-utilities-get-common-filename-prefix.c b/test/test-file-utilities-get-common-filename-prefix.c index 786c7dfb8..ae4dffc4d 100644 --- a/test/test-file-utilities-get-common-filename-prefix.c +++ b/test/test-file-utilities-get-common-filename-prefix.c @@ -5,533 +5,540 @@ static void -free_list_and_result (GList *list, char *result) +free_list_and_result (GList *list, + char *result) { - g_list_free (list); - g_free (result); + g_list_free (list); + g_free (result); } static void test_has_large_enough_common_prefix () { - GList *list = NULL; - char *actual; + GList *list = NULL; + char *actual; - list = g_list_append (list, "test"); - list = g_list_append (list, "tests"); + list = g_list_append (list, "test"); + list = g_list_append (list, "tests"); - actual = nautilus_get_common_filename_prefix_from_filenames (list, 4); - g_assert_cmpstr ("test", ==, actual); + actual = nautilus_get_common_filename_prefix_from_filenames (list, 4); + g_assert_cmpstr ("test", ==, actual); - free_list_and_result (list, actual); + free_list_and_result (list, actual); } static void test_has_large_enough_common_prefix_with_spaces_in_middle () { - GList *list = NULL; - char *actual; + GList *list = NULL; + char *actual; - list = g_list_append (list, "Cpt J Yossarian r1"); - list = g_list_append (list, "Cpt J Yossarian a1"); + list = g_list_append (list, "Cpt J Yossarian r1"); + list = g_list_append (list, "Cpt J Yossarian a1"); - actual = nautilus_get_common_filename_prefix_from_filenames (list, 4); - g_assert_cmpstr ("Cpt J Yossarian", ==, actual); + actual = nautilus_get_common_filename_prefix_from_filenames (list, 4); + g_assert_cmpstr ("Cpt J Yossarian", ==, actual); - free_list_and_result (list, actual); + free_list_and_result (list, actual); } static void test_has_large_enough_common_prefix_with_punctuation_in_middle () { - GList *list = NULL; - char *actual; + GList *list = NULL; + char *actual; - list = g_list_append (list, "Cpt-J_Yossarian r1"); - list = g_list_append (list, "Cpt-J_Yossarian a1"); + list = g_list_append (list, "Cpt-J_Yossarian r1"); + list = g_list_append (list, "Cpt-J_Yossarian a1"); - actual = nautilus_get_common_filename_prefix_from_filenames (list, 4); - g_assert_cmpstr ("Cpt-J_Yossarian", ==, actual); + actual = nautilus_get_common_filename_prefix_from_filenames (list, 4); + g_assert_cmpstr ("Cpt-J_Yossarian", ==, actual); - free_list_and_result (list, actual); + free_list_and_result (list, actual); } static void test_has_large_enough_common_prefix_with_punctuation_in_middle_and_extension () { - GList *list = NULL; - char *actual; + GList *list = NULL; + char *actual; - list = g_list_append (list, "Cpt-J, Yossarian.xml"); - list = g_list_append (list, "Cpt-J, Yossarian.xsl"); + list = g_list_append (list, "Cpt-J, Yossarian.xml"); + list = g_list_append (list, "Cpt-J, Yossarian.xsl"); - actual = nautilus_get_common_filename_prefix_from_filenames (list, 4); - g_assert_cmpstr ("Cpt-J, Yossarian", ==, actual); + actual = nautilus_get_common_filename_prefix_from_filenames (list, 4); + g_assert_cmpstr ("Cpt-J, Yossarian", ==, actual); - free_list_and_result (list, actual); + free_list_and_result (list, actual); } static void test_doesnt_have_large_enough_common_prefix () { - GList *list = NULL; - char *actual; + GList *list = NULL; + char *actual; - list = g_list_append (list, "foo"); - list = g_list_append (list, "foob"); + list = g_list_append (list, "foo"); + list = g_list_append (list, "foob"); - actual = nautilus_get_common_filename_prefix_from_filenames (list, 4); - g_assert_null (actual); + actual = nautilus_get_common_filename_prefix_from_filenames (list, 4); + g_assert_null (actual); - free_list_and_result (list, actual); + free_list_and_result (list, actual); } static void test_doesnt_have_large_enough_common_prefix_completely_different_strings () { - GList *list = NULL; - char *actual; + GList *list = NULL; + char *actual; - list = g_list_append (list, "this string really"); - list = g_list_append (list, "isn't the same as the other"); + list = g_list_append (list, "this string really"); + list = g_list_append (list, "isn't the same as the other"); - actual = nautilus_get_common_filename_prefix_from_filenames (list, 4); - g_assert_null (actual); + actual = nautilus_get_common_filename_prefix_from_filenames (list, 4); + g_assert_null (actual); - free_list_and_result (list, actual); + free_list_and_result (list, actual); } static void test_doesnt_have_large_enough_common_prefix_first_character_differs () { - GList *list = NULL; - char *actual; + GList *list = NULL; + char *actual; - list = g_list_append (list, "foo"); - list = g_list_append (list, "roo"); + list = g_list_append (list, "foo"); + list = g_list_append (list, "roo"); - actual = nautilus_get_common_filename_prefix_from_filenames (list, 4); - g_assert_null (actual); + actual = nautilus_get_common_filename_prefix_from_filenames (list, 4); + g_assert_null (actual); - free_list_and_result (list, actual); + free_list_and_result (list, actual); } static void test_doesnt_have_large_enough_common_prefix_first_character_differs_longer_string () { - GList *list = NULL; - char *actual; + GList *list = NULL; + char *actual; - list = g_list_append (list, "fools"); - list = g_list_append (list, "rools"); + list = g_list_append (list, "fools"); + list = g_list_append (list, "rools"); - actual = nautilus_get_common_filename_prefix_from_filenames (list, 4); - g_assert_null (actual); + actual = nautilus_get_common_filename_prefix_from_filenames (list, 4); + g_assert_null (actual); - free_list_and_result (list, actual); + free_list_and_result (list, actual); } static void test_has_large_enough_common_prefix_until_punctuation_removed () { - GList *list = NULL; - char *actual; + GList *list = NULL; + char *actual; - list = g_list_append (list, "tes$%^"); - list = g_list_append (list, "tes$%something"); + list = g_list_append (list, "tes$%^"); + list = g_list_append (list, "tes$%something"); - actual = nautilus_get_common_filename_prefix_from_filenames (list, 4); - g_assert_null (actual); + actual = nautilus_get_common_filename_prefix_from_filenames (list, 4); + g_assert_null (actual); - free_list_and_result (list, actual); + free_list_and_result (list, actual); } static void test_has_large_enough_common_prefix_until_extension_removed () { - GList *list = NULL; - char *actual; + GList *list = NULL; + char *actual; - list = g_list_append (list, "tes.txt"); - list = g_list_append (list, "tes.tar"); + list = g_list_append (list, "tes.txt"); + list = g_list_append (list, "tes.tar"); - actual = nautilus_get_common_filename_prefix_from_filenames (list, 4); - g_assert_null (actual); + actual = nautilus_get_common_filename_prefix_from_filenames (list, 4); + g_assert_null (actual); - free_list_and_result (list, actual); + free_list_and_result (list, actual); } static void test_has_large_enough_common_prefix_until_extension_and_punctuation_removed () { - GList *list = NULL; - char *actual; + GList *list = NULL; + char *actual; - list = g_list_append (list, "tux$&&&.txt"); - list = g_list_append (list, "tux$&&&.tar"); + list = g_list_append (list, "tux$&&&.txt"); + list = g_list_append (list, "tux$&&&.tar"); - actual = nautilus_get_common_filename_prefix_from_filenames (list, 4); - g_assert_null (actual); + actual = nautilus_get_common_filename_prefix_from_filenames (list, 4); + g_assert_null (actual); - free_list_and_result (list, actual); + free_list_and_result (list, actual); } static void test_extension_is_removed () { - GList *list = NULL; - char *actual; + GList *list = NULL; + char *actual; - list = g_list_append (list, "nau tilus.c"); - list = g_list_append (list, "nau tilus.cpp"); + list = g_list_append (list, "nau tilus.c"); + list = g_list_append (list, "nau tilus.cpp"); - actual = nautilus_get_common_filename_prefix_from_filenames (list, 4); - g_assert_cmpstr ("nau tilus", ==, actual); + actual = nautilus_get_common_filename_prefix_from_filenames (list, 4); + g_assert_cmpstr ("nau tilus", ==, actual); - free_list_and_result (list, actual); + free_list_and_result (list, actual); } static void test_punctuation_is_removed () { - GList *list = NULL; - char *actual; + GList *list = NULL; + char *actual; - list = g_list_append (list, "nautilus((&&£"); - list = g_list_append (list, "nautilus((&&xyz"); + list = g_list_append (list, "nautilus((&&£"); + list = g_list_append (list, "nautilus((&&xyz"); - actual = nautilus_get_common_filename_prefix_from_filenames (list, 4); - g_assert_cmpstr ("nautilus", ==, actual); + actual = nautilus_get_common_filename_prefix_from_filenames (list, 4); + g_assert_cmpstr ("nautilus", ==, actual); - free_list_and_result (list, actual); + free_list_and_result (list, actual); } static void test_whitespace_is_removed () { - GList *list = NULL; - char *actual; + GList *list = NULL; + char *actual; - list = g_list_append (list, "nautilus "); - list = g_list_append (list, "nautilus two"); + list = g_list_append (list, "nautilus "); + list = g_list_append (list, "nautilus two"); - actual = nautilus_get_common_filename_prefix_from_filenames (list, 4); - g_assert_cmpstr ("nautilus", ==, actual); + actual = nautilus_get_common_filename_prefix_from_filenames (list, 4); + g_assert_cmpstr ("nautilus", ==, actual); - free_list_and_result (list, actual); + free_list_and_result (list, actual); } static void test_punctuation_and_whitespace_are_removed () { - GList *list = NULL; - char *actual; + GList *list = NULL; + char *actual; - list = g_list_append (list, "nautilus! £ $\"TTR"); - list = g_list_append (list, "nautilus! £ $\""); + list = g_list_append (list, "nautilus! £ $\"TTR"); + list = g_list_append (list, "nautilus! £ $\""); - actual = nautilus_get_common_filename_prefix_from_filenames (list, 4); - g_assert_cmpstr ("nautilus", ==, actual); + actual = nautilus_get_common_filename_prefix_from_filenames (list, 4); + g_assert_cmpstr ("nautilus", ==, actual); - free_list_and_result (list, actual); + free_list_and_result (list, actual); } static void test_whitespace_and_punctuation_are_removed () { - GList *list = NULL; - char *actual; + GList *list = NULL; + char *actual; - list = g_list_append (list, "nautilus !£ $\"TTR"); - list = g_list_append (list, "nautilus !£ $\""); + list = g_list_append (list, "nautilus !£ $\"TTR"); + list = g_list_append (list, "nautilus !£ $\""); - actual = nautilus_get_common_filename_prefix_from_filenames (list, 4); - g_assert_cmpstr ("nautilus", ==, actual); + actual = nautilus_get_common_filename_prefix_from_filenames (list, 4); + g_assert_cmpstr ("nautilus", ==, actual); - free_list_and_result (list, actual); + free_list_and_result (list, actual); } static void test_puctuation_and_extension_are_removed () { - GList *list = NULL; - char *actual; + GList *list = NULL; + char *actual; - list = g_list_append (list, "nautilus!£$%^&*()_+-={}[];':@#~<>?,./\".tar"); - list = g_list_append (list, "nautilus!£$%^&*()_+-={}[];':@#~<>?,./\".tat"); + list = g_list_append (list, "nautilus!£$%^&*()_+-={}[];':@#~<>?,./\".tar"); + list = g_list_append (list, "nautilus!£$%^&*()_+-={}[];':@#~<>?,./\".tat"); - actual = nautilus_get_common_filename_prefix_from_filenames (list, 4); - g_assert_cmpstr ("nautilus", ==, actual); + actual = nautilus_get_common_filename_prefix_from_filenames (list, 4); + g_assert_cmpstr ("nautilus", ==, actual); - free_list_and_result (list, actual); + free_list_and_result (list, actual); } static void test_puctuation_extension_and_whitespace_are_removed () { - GList *list = NULL; - char *actual; + GList *list = NULL; + char *actual; - list = g_list_append (list, "nautilus!£$%^&* ()_+-={}[ ];':@#~<>?,./\".tar"); - list = g_list_append (list, "nautilus!£$%^&* ()_+-={}[ ];':@#~<>?,./\".tat"); + list = g_list_append (list, "nautilus!£$%^&* ()_+-={}[ ];':@#~<>?,./\".tar"); + list = g_list_append (list, "nautilus!£$%^&* ()_+-={}[ ];':@#~<>?,./\".tat"); - actual = nautilus_get_common_filename_prefix_from_filenames (list, 4); - g_assert_cmpstr ("nautilus", ==, actual); + actual = nautilus_get_common_filename_prefix_from_filenames (list, 4); + g_assert_cmpstr ("nautilus", ==, actual); - free_list_and_result (list, actual); + free_list_and_result (list, actual); } static void test_unicode_on_outside () { - GList *list = NULL; - char *actual; + GList *list = NULL; + char *actual; - list = g_list_append (list, "ӶtestӶ234"); - list = g_list_append (list, "ӶtestӶ1"); + list = g_list_append (list, "ӶtestӶ234"); + list = g_list_append (list, "ӶtestӶ1"); - actual = nautilus_get_common_filename_prefix_from_filenames (list, 4); - g_assert_cmpstr ("ӶtestӶ", ==, actual); + actual = nautilus_get_common_filename_prefix_from_filenames (list, 4); + g_assert_cmpstr ("ӶtestӶ", ==, actual); - free_list_and_result (list, actual); + free_list_and_result (list, actual); } static void test_unicode_on_inside () { - GList *list = NULL; - char *actual; + GList *list = NULL; + char *actual; - list = g_list_append (list, "QQӶtestӶabb234"); - list = g_list_append (list, "QQӶtestӶabb1"); + list = g_list_append (list, "QQӶtestӶabb234"); + list = g_list_append (list, "QQӶtestӶabb1"); - actual = nautilus_get_common_filename_prefix_from_filenames (list, 4); - g_assert_cmpstr ("QQӶtestӶabb", ==, actual); + actual = nautilus_get_common_filename_prefix_from_filenames (list, 4); + g_assert_cmpstr ("QQӶtestӶabb", ==, actual); - free_list_and_result (list, actual); + free_list_and_result (list, actual); } static void test_unicode_whole_string () { - GList *list = NULL; - char *actual; + GList *list = NULL; + char *actual; - list = g_list_append (list, "ǣȸʸͻͻΎΘΛ"); - list = g_list_append (list, "ǣȸʸͻͻΎΘ"); + list = g_list_append (list, "ǣȸʸͻͻΎΘΛ"); + list = g_list_append (list, "ǣȸʸͻͻΎΘ"); - actual = nautilus_get_common_filename_prefix_from_filenames (list, 4); - g_assert_cmpstr ("ǣȸʸͻͻΎΘ", ==, actual); + actual = nautilus_get_common_filename_prefix_from_filenames (list, 4); + g_assert_cmpstr ("ǣȸʸͻͻΎΘ", ==, actual); - free_list_and_result (list, actual); + free_list_and_result (list, actual); } static void test_unicode_extension () { - GList *list = NULL; - char *actual; + GList *list = NULL; + char *actual; - list = g_list_append (list, "test.ǣȸʸͻͻΎΘΛ"); - list = g_list_append (list, "test.ǣȸʸͻͻΎΘ"); + list = g_list_append (list, "test.ǣȸʸͻͻΎΘΛ"); + list = g_list_append (list, "test.ǣȸʸͻͻΎΘ"); - actual = nautilus_get_common_filename_prefix_from_filenames (list, 4); - g_assert_cmpstr ("test", ==, actual); + actual = nautilus_get_common_filename_prefix_from_filenames (list, 4); + g_assert_cmpstr ("test", ==, actual); - free_list_and_result (list, actual); + free_list_and_result (list, actual); } static void test_unicode_with_punctuation () { - GList *list = NULL; - char *actual; + GList *list = NULL; + char *actual; - list = g_list_append (list, "ǣȸʸ- ͻͻΎΘ$%%^"); - list = g_list_append (list, "ǣȸʸ- ͻͻΎΘ$%%&"); + list = g_list_append (list, "ǣȸʸ- ͻͻΎΘ$%%^"); + list = g_list_append (list, "ǣȸʸ- ͻͻΎΘ$%%&"); - actual = nautilus_get_common_filename_prefix_from_filenames (list, 4); - g_assert_cmpstr ("ǣȸʸ- ͻͻΎΘ", ==, actual); + actual = nautilus_get_common_filename_prefix_from_filenames (list, 4); + g_assert_cmpstr ("ǣȸʸ- ͻͻΎΘ", ==, actual); - free_list_and_result (list, actual); + free_list_and_result (list, actual); } static void test_many_strings () { - GList *list = NULL; - char *actual; - char *filename; - int i; - - for (i = 0; i < 500; ++i) { - filename = g_strdup_printf ("we are no longer the knights who say nii%d", i); - list = g_list_append (list, filename); - } - - actual = nautilus_get_common_filename_prefix_from_filenames (list, 4); - g_assert_cmpstr ("we are no longer the knights who say nii", ==, actual); - - g_free (actual); - g_list_free_full (list, g_free); + GList *list = NULL; + char *actual; + char *filename; + int i; + + for (i = 0; i < 500; ++i) + { + filename = g_strdup_printf ("we are no longer the knights who say nii%d", i); + list = g_list_append (list, filename); + } + + actual = nautilus_get_common_filename_prefix_from_filenames (list, 4); + g_assert_cmpstr ("we are no longer the knights who say nii", ==, actual); + + g_free (actual); + g_list_free_full (list, g_free); } static void test_many_strings_last_differs () { - GList *list = NULL; - char *actual; - char *filename; - int i; - - for (i = 0; i < 500; ++i) { - filename = g_strdup_printf ("we are no longer the knights who say nii%d", i); - - if (i == 499) { - filename[2] = 'X'; - } - - list = g_list_append (list, filename); + GList *list = NULL; + char *actual; + char *filename; + int i; + + for (i = 0; i < 500; ++i) + { + filename = g_strdup_printf ("we are no longer the knights who say nii%d", i); + + if (i == 499) + { + filename[2] = 'X'; } - actual = nautilus_get_common_filename_prefix_from_filenames (list, 4); - g_assert_null (actual); + list = g_list_append (list, filename); + } - g_free (actual); - g_list_free_full (list, g_free); + actual = nautilus_get_common_filename_prefix_from_filenames (list, 4); + g_assert_null (actual); + + g_free (actual); + g_list_free_full (list, g_free); } static void test_many_strings_first_differs () { - GList *list = NULL; - char *actual; - char *filename; - int i; - - for (i = 0; i < 500; ++i) { - filename = g_strdup_printf ("we are no longer the knights who say nii%d", i); - - if (i == 0) { - filename[2] = 'X'; - } - - list = g_list_append (list, filename); + GList *list = NULL; + char *actual; + char *filename; + int i; + + for (i = 0; i < 500; ++i) + { + filename = g_strdup_printf ("we are no longer the knights who say nii%d", i); + + if (i == 0) + { + filename[2] = 'X'; } - actual = nautilus_get_common_filename_prefix_from_filenames (list, 4); - g_assert_null (actual); + list = g_list_append (list, filename); + } + + actual = nautilus_get_common_filename_prefix_from_filenames (list, 4); + g_assert_null (actual); - g_free (actual); - g_list_free_full (list, g_free); + g_free (actual); + g_list_free_full (list, g_free); } static void test_smaller_min_length_and_does_have_common_prefix () { - GList *list = NULL; - char *actual; + GList *list = NULL; + char *actual; - list = g_list_append (list, "CA"); - list = g_list_append (list, "CB"); + list = g_list_append (list, "CA"); + list = g_list_append (list, "CB"); - actual = nautilus_get_common_filename_prefix_from_filenames (list, 1); - g_assert_cmpstr ("C", ==, actual); + actual = nautilus_get_common_filename_prefix_from_filenames (list, 1); + g_assert_cmpstr ("C", ==, actual); - free_list_and_result (list, actual); + free_list_and_result (list, actual); } static void test_smaller_min_length_and_doesnt_have_common_prefix () { - GList *list = NULL; - char *actual; + GList *list = NULL; + char *actual; - list = g_list_append (list, "CA"); - list = g_list_append (list, "BB"); + list = g_list_append (list, "CA"); + list = g_list_append (list, "BB"); - actual = nautilus_get_common_filename_prefix_from_filenames (list, 1); - g_assert_null (actual); + actual = nautilus_get_common_filename_prefix_from_filenames (list, 1); + g_assert_null (actual); - free_list_and_result (list, actual); + free_list_and_result (list, actual); } static void setup_test_suite () { - g_test_add_func ("/get-common-filename-prefix/1.0", - test_has_large_enough_common_prefix); - g_test_add_func ("/get-common-filename-prefix/1.1", - test_has_large_enough_common_prefix_with_spaces_in_middle); - g_test_add_func ("/get-common-filename-prefix/1.2", - test_has_large_enough_common_prefix_with_punctuation_in_middle); - g_test_add_func ("/get-common-filename-prefix/1.3", - test_has_large_enough_common_prefix_with_punctuation_in_middle_and_extension); - - g_test_add_func ("/get-common-filename-prefix/2.0", - test_doesnt_have_large_enough_common_prefix); - g_test_add_func ("/get-common-filename-prefix/2.1", - test_doesnt_have_large_enough_common_prefix_completely_different_strings); - g_test_add_func ("/get-common-filename-prefix/2.2", - test_doesnt_have_large_enough_common_prefix_first_character_differs); - g_test_add_func ("/get-common-filename-prefix/2.3", - test_doesnt_have_large_enough_common_prefix_first_character_differs_longer_string); - - g_test_add_func ("/get-common-filename-prefix/3.0", - test_has_large_enough_common_prefix_until_punctuation_removed); - g_test_add_func ("/get-common-filename-prefix/3.1", - test_has_large_enough_common_prefix_until_extension_removed); - g_test_add_func ("/get-common-filename-prefix/3.2", - test_has_large_enough_common_prefix_until_extension_and_punctuation_removed); - - g_test_add_func ("/get-common-filename-prefix/4.0", - test_extension_is_removed); - g_test_add_func ("/get-common-filename-prefix/4.1", - test_punctuation_is_removed); - g_test_add_func ("/get-common-filename-prefix/4.2", - test_whitespace_is_removed); - g_test_add_func ("/get-common-filename-prefix/4.3", - test_punctuation_and_whitespace_are_removed); - g_test_add_func ("/get-common-filename-prefix/4.4", - test_whitespace_and_punctuation_are_removed); - g_test_add_func ("/get-common-filename-prefix/4.5", - test_puctuation_and_extension_are_removed); - g_test_add_func ("/get-common-filename-prefix/4.6", - test_puctuation_extension_and_whitespace_are_removed); - - g_test_add_func ("/get-common-filename-prefix/5.0", - test_unicode_on_inside); - g_test_add_func ("/get-common-filename-prefix/5.1", - test_unicode_on_outside); - g_test_add_func ("/get-common-filename-prefix/5.2", - test_unicode_whole_string); - g_test_add_func ("/get-common-filename-prefix/5.3", - test_unicode_extension); - g_test_add_func ("/get-common-filename-prefix/5.4", - test_unicode_with_punctuation); - - g_test_add_func ("/get-common-filename-prefix/6.0", - test_many_strings); - g_test_add_func ("/get-common-filename-prefix/6.1", - test_many_strings_last_differs); - g_test_add_func ("/get-common-filename-prefix/6.2", - test_many_strings_first_differs); - - g_test_add_func ("/get-common-filename-prefix/7.0", - test_smaller_min_length_and_does_have_common_prefix); - g_test_add_func ("/get-common-filename-prefix/7.1", - test_smaller_min_length_and_doesnt_have_common_prefix); + g_test_add_func ("/get-common-filename-prefix/1.0", + test_has_large_enough_common_prefix); + g_test_add_func ("/get-common-filename-prefix/1.1", + test_has_large_enough_common_prefix_with_spaces_in_middle); + g_test_add_func ("/get-common-filename-prefix/1.2", + test_has_large_enough_common_prefix_with_punctuation_in_middle); + g_test_add_func ("/get-common-filename-prefix/1.3", + test_has_large_enough_common_prefix_with_punctuation_in_middle_and_extension); + + g_test_add_func ("/get-common-filename-prefix/2.0", + test_doesnt_have_large_enough_common_prefix); + g_test_add_func ("/get-common-filename-prefix/2.1", + test_doesnt_have_large_enough_common_prefix_completely_different_strings); + g_test_add_func ("/get-common-filename-prefix/2.2", + test_doesnt_have_large_enough_common_prefix_first_character_differs); + g_test_add_func ("/get-common-filename-prefix/2.3", + test_doesnt_have_large_enough_common_prefix_first_character_differs_longer_string); + + g_test_add_func ("/get-common-filename-prefix/3.0", + test_has_large_enough_common_prefix_until_punctuation_removed); + g_test_add_func ("/get-common-filename-prefix/3.1", + test_has_large_enough_common_prefix_until_extension_removed); + g_test_add_func ("/get-common-filename-prefix/3.2", + test_has_large_enough_common_prefix_until_extension_and_punctuation_removed); + + g_test_add_func ("/get-common-filename-prefix/4.0", + test_extension_is_removed); + g_test_add_func ("/get-common-filename-prefix/4.1", + test_punctuation_is_removed); + g_test_add_func ("/get-common-filename-prefix/4.2", + test_whitespace_is_removed); + g_test_add_func ("/get-common-filename-prefix/4.3", + test_punctuation_and_whitespace_are_removed); + g_test_add_func ("/get-common-filename-prefix/4.4", + test_whitespace_and_punctuation_are_removed); + g_test_add_func ("/get-common-filename-prefix/4.5", + test_puctuation_and_extension_are_removed); + g_test_add_func ("/get-common-filename-prefix/4.6", + test_puctuation_extension_and_whitespace_are_removed); + + g_test_add_func ("/get-common-filename-prefix/5.0", + test_unicode_on_inside); + g_test_add_func ("/get-common-filename-prefix/5.1", + test_unicode_on_outside); + g_test_add_func ("/get-common-filename-prefix/5.2", + test_unicode_whole_string); + g_test_add_func ("/get-common-filename-prefix/5.3", + test_unicode_extension); + g_test_add_func ("/get-common-filename-prefix/5.4", + test_unicode_with_punctuation); + + g_test_add_func ("/get-common-filename-prefix/6.0", + test_many_strings); + g_test_add_func ("/get-common-filename-prefix/6.1", + test_many_strings_last_differs); + g_test_add_func ("/get-common-filename-prefix/6.2", + test_many_strings_first_differs); + + g_test_add_func ("/get-common-filename-prefix/7.0", + test_smaller_min_length_and_does_have_common_prefix); + g_test_add_func ("/get-common-filename-prefix/7.1", + test_smaller_min_length_and_doesnt_have_common_prefix); } int -main (int argc, char *argv[]) +main (int argc, + char *argv[]) { - g_test_init (&argc, &argv, NULL); - g_test_bug_base ("http://bugzilla.gnome.org/show_bug.cgi?id=747907"); - g_test_set_nonfatal_assertions (); + g_test_init (&argc, &argv, NULL); + g_test_bug_base ("http://bugzilla.gnome.org/show_bug.cgi?id=747907"); + g_test_set_nonfatal_assertions (); - setup_test_suite (); + setup_test_suite (); - return g_test_run (); + return g_test_run (); } diff --git a/test/test-nautilus-directory-async.c b/test/test-nautilus-directory-async.c index 4fbbb3268..da86ecab8 100644 --- a/test/test-nautilus-directory-async.c +++ b/test/test-nautilus-directory-async.c @@ -8,83 +8,89 @@ void *client1, *client2; static void files_added (NautilusDirectory *directory, - GList *added_files) + GList *added_files) { #if 0 - GList *list; + GList *list; - for (list = added_files; list != NULL; list = list->next) { - NautilusFile *file = list->data; + for (list = added_files; list != NULL; list = list->next) + { + NautilusFile *file = list->data; - g_print (" - %s\n", nautilus_file_get_uri (file)); - } + g_print (" - %s\n", nautilus_file_get_uri (file)); + } #endif - g_print ("files added: %d files\n", - g_list_length (added_files)); + g_print ("files added: %d files\n", + g_list_length (added_files)); } static void files_changed (NautilusDirectory *directory, - GList *changed_files) + GList *changed_files) { #if 0 - GList *list; + GList *list; - for (list = changed_files; list != NULL; list = list->next) { - NautilusFile *file = list->data; + for (list = changed_files; list != NULL; list = list->next) + { + NautilusFile *file = list->data; - g_print (" - %s\n", nautilus_file_get_uri (file)); - } + g_print (" - %s\n", nautilus_file_get_uri (file)); + } #endif - g_print ("files changed: %d\n", - g_list_length (changed_files)); + g_print ("files changed: %d\n", + g_list_length (changed_files)); } static void done_loading (NautilusDirectory *directory) { - g_print ("done loading\n"); - gtk_main_quit (); + g_print ("done loading\n"); + gtk_main_quit (); } int -main (int argc, char **argv) +main (int argc, + char **argv) { - NautilusDirectory *directory; - NautilusFileAttributes attributes; - const char *uri; - - client1 = g_new0 (int, 1); - client2 = g_new0 (int, 1); - - gtk_init (&argc, &argv); - - if (argv[1] == NULL) { - uri = "file:///tmp"; - } else { - uri = argv[1]; - } - g_print ("loading %s", uri); - directory = nautilus_directory_get_by_uri (uri); - - g_signal_connect (directory, "files-added", G_CALLBACK (files_added), NULL); - g_signal_connect (directory, "files-changed", G_CALLBACK (files_changed), NULL); - g_signal_connect (directory, "done-loading", G_CALLBACK (done_loading), NULL); - - attributes = - NAUTILUS_FILE_ATTRIBUTES_FOR_ICON | - NAUTILUS_FILE_ATTRIBUTE_DIRECTORY_ITEM_COUNT | - NAUTILUS_FILE_ATTRIBUTE_INFO | - NAUTILUS_FILE_ATTRIBUTE_LINK_INFO | - NAUTILUS_FILE_ATTRIBUTE_MOUNT | - NAUTILUS_FILE_ATTRIBUTE_EXTENSION_INFO; - - nautilus_directory_file_monitor_add (directory, client1, TRUE, - attributes, - NULL, NULL); - - - gtk_main (); - return 0; + NautilusDirectory *directory; + NautilusFileAttributes attributes; + const char *uri; + + client1 = g_new0 (int, 1); + client2 = g_new0 (int, 1); + + gtk_init (&argc, &argv); + + if (argv[1] == NULL) + { + uri = "file:///tmp"; + } + else + { + uri = argv[1]; + } + g_print ("loading %s", uri); + directory = nautilus_directory_get_by_uri (uri); + + g_signal_connect (directory, "files-added", G_CALLBACK (files_added), NULL); + g_signal_connect (directory, "files-changed", G_CALLBACK (files_changed), NULL); + g_signal_connect (directory, "done-loading", G_CALLBACK (done_loading), NULL); + + attributes = + NAUTILUS_FILE_ATTRIBUTES_FOR_ICON | + NAUTILUS_FILE_ATTRIBUTE_DIRECTORY_ITEM_COUNT | + NAUTILUS_FILE_ATTRIBUTE_INFO | + NAUTILUS_FILE_ATTRIBUTE_LINK_INFO | + NAUTILUS_FILE_ATTRIBUTE_MOUNT | + NAUTILUS_FILE_ATTRIBUTE_EXTENSION_INFO; + + nautilus_directory_file_monitor_add (directory, client1, TRUE, + attributes, + NULL, NULL); + + + gtk_main (); + return 0; } diff --git a/test/test-nautilus-mime-actions-set.c b/test/test-nautilus-mime-actions-set.c index b80c31767..a08f817d6 100644 --- a/test/test-nautilus-mime-actions-set.c +++ b/test/test-nautilus-mime-actions-set.c @@ -1,25 +1,25 @@ /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ /* test-mime.c - Test for the mime handler detection features of the GNOME - Virtual File System Library - - Copyright (C) 2000 Eazel - - The Gnome Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Gnome Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Gnome Library; see the file COPYING.LIB. If not, - see <http://www.gnu.org/licenses/>. - - Author: Maciej Stachowiak <mjs@eazel.com> -*/ + * Virtual File System Library + * + * Copyright (C) 2000 Eazel + * + * The Gnome Library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * The Gnome Library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with the Gnome Library; see the file COPYING.LIB. If not, + * see <http://www.gnu.org/licenses/>. + * + * Author: Maciej Stachowiak <mjs@eazel.com> + */ #include <config.h> @@ -32,129 +32,156 @@ static gboolean ready = FALSE; static void usage (const char *name) { - fprintf (stderr, "Usage: %s uri field value\n", name); - fprintf (stderr, "Valid field values are: \n"); - fprintf (stderr, "\tdefault_action_type\n"); - fprintf (stderr, "\tdefault_application\n"); - fprintf (stderr, "\tdefault_component\n"); - fprintf (stderr, "\tshort_list_applicationss\n"); - fprintf (stderr, "\tshort_list_components\n"); - fprintf (stderr, "\tadd_to_all_applicationss\n"); - fprintf (stderr, "\tremove_from_all_applications\n"); - exit (1); + fprintf (stderr, "Usage: %s uri field value\n", name); + fprintf (stderr, "Valid field values are: \n"); + fprintf (stderr, "\tdefault_action_type\n"); + fprintf (stderr, "\tdefault_application\n"); + fprintf (stderr, "\tdefault_component\n"); + fprintf (stderr, "\tshort_list_applicationss\n"); + fprintf (stderr, "\tshort_list_components\n"); + fprintf (stderr, "\tadd_to_all_applicationss\n"); + fprintf (stderr, "\tremove_from_all_applications\n"); + exit (1); } static GnomeVFSMimeActionType str_to_action_type (const char *str) { - if (g_ascii_strcasecmp (str, "component") == 0) { - return GNOME_VFS_MIME_ACTION_TYPE_COMPONENT; - } else if (g_ascii_strcasecmp (str, "application") == 0) { - return GNOME_VFS_MIME_ACTION_TYPE_APPLICATION; - } else { - return GNOME_VFS_MIME_ACTION_TYPE_NONE; - } + if (g_ascii_strcasecmp (str, "component") == 0) + { + return GNOME_VFS_MIME_ACTION_TYPE_COMPONENT; + } + else if (g_ascii_strcasecmp (str, "application") == 0) + { + return GNOME_VFS_MIME_ACTION_TYPE_APPLICATION; + } + else + { + return GNOME_VFS_MIME_ACTION_TYPE_NONE; + } } static char ** -strsplit_handle_null (const char *str, const char *delim, int max) +strsplit_handle_null (const char *str, + const char *delim, + int max) { - return g_strsplit ((str == NULL ? "" : str), delim, max); + return g_strsplit ((str == NULL ? "" : str), delim, max); } static GList * -strsplit_to_list (const char *str, const char *delim, int max) +strsplit_to_list (const char *str, + const char *delim, + int max) { - char **strv; - GList *retval; - int i; + char **strv; + GList *retval; + int i; - strv = strsplit_handle_null (str, delim, max); + strv = strsplit_handle_null (str, delim, max); - retval = NULL; + retval = NULL; - for (i = 0; strv[i] != NULL; i++) { - retval = g_list_prepend (retval, strv[i]); - } + for (i = 0; strv[i] != NULL; i++) + { + retval = g_list_prepend (retval, strv[i]); + } - retval = g_list_reverse (retval); - /* Don't strfreev, since we didn't copy the individual strings. */ - g_free (strv); + retval = g_list_reverse (retval); + /* Don't strfreev, since we didn't copy the individual strings. */ + g_free (strv); - return retval; + return retval; } static GList * comma_separated_str_to_str_list (const char *str) { - return strsplit_to_list (str, ",", 0); + return strsplit_to_list (str, ",", 0); } static void ready_callback (NautilusFile *file, - gpointer callback_data) + gpointer callback_data) { - ready = TRUE; + ready = TRUE; } int -main (int argc, char **argv) +main (int argc, + char **argv) { - const char *uri; - const char *field; - const char *value; - NautilusFile *file; - NautilusFileAttributes attributes; - - gtk_init (&argc, &argv); - - if (argc < 3) { - usage (argv[0]); - } - - uri = argv[1]; - field = argv[2]; - value = argv[3]; - - file = nautilus_file_get_by_uri (uri); - - attributes = nautilus_mime_actions_get_full_file_attributes (); - nautilus_file_call_when_ready (file, attributes, ready_callback, NULL); - - while (!ready) { - gtk_main_iteration (); - } - - if (strcmp (field, "default_action_type") == 0) { - puts ("default_action_type"); - nautilus_mime_set_default_action_type_for_file (file, str_to_action_type (value)); - } else if (strcmp (field, "default_application") == 0) { - puts ("default_application"); - nautilus_mime_set_default_application_for_file (file, value); - } else if (strcmp (field, "default_component") == 0) { - puts ("default_component"); - nautilus_mime_set_default_component_for_file (file, value); - } else if (strcmp (field, "short_list_applicationss") == 0) { - puts ("short_list_applications"); - nautilus_mime_set_short_list_applications_for_file - (file, comma_separated_str_to_str_list (value)); - } else if (strcmp (field, "short_list_components") == 0) { - puts ("short_list_components"); - nautilus_mime_set_short_list_components_for_file - (file, comma_separated_str_to_str_list (value)); - } else if (strcmp (field, "add_to_all_applicationss") == 0) { - puts ("add_to_all_applications"); - nautilus_mime_extend_all_applications_for_file - (file, comma_separated_str_to_str_list (value)); - } else if (strcmp (field, "remove_from_all_applications") == 0) { - puts ("remove_from_all_applications"); - nautilus_mime_remove_from_all_applications_for_file - (file, comma_separated_str_to_str_list (value)); - - } else { - usage (argv[0]); - } - - return 0; + const char *uri; + const char *field; + const char *value; + NautilusFile *file; + NautilusFileAttributes attributes; + + gtk_init (&argc, &argv); + + if (argc < 3) + { + usage (argv[0]); + } + + uri = argv[1]; + field = argv[2]; + value = argv[3]; + + file = nautilus_file_get_by_uri (uri); + + attributes = nautilus_mime_actions_get_full_file_attributes (); + nautilus_file_call_when_ready (file, attributes, ready_callback, NULL); + + while (!ready) + { + gtk_main_iteration (); + } + + if (strcmp (field, "default_action_type") == 0) + { + puts ("default_action_type"); + nautilus_mime_set_default_action_type_for_file (file, str_to_action_type (value)); + } + else if (strcmp (field, "default_application") == 0) + { + puts ("default_application"); + nautilus_mime_set_default_application_for_file (file, value); + } + else if (strcmp (field, "default_component") == 0) + { + puts ("default_component"); + nautilus_mime_set_default_component_for_file (file, value); + } + else if (strcmp (field, "short_list_applicationss") == 0) + { + puts ("short_list_applications"); + nautilus_mime_set_short_list_applications_for_file + (file, comma_separated_str_to_str_list (value)); + } + else if (strcmp (field, "short_list_components") == 0) + { + puts ("short_list_components"); + nautilus_mime_set_short_list_components_for_file + (file, comma_separated_str_to_str_list (value)); + } + else if (strcmp (field, "add_to_all_applicationss") == 0) + { + puts ("add_to_all_applications"); + nautilus_mime_extend_all_applications_for_file + (file, comma_separated_str_to_str_list (value)); + } + else if (strcmp (field, "remove_from_all_applications") == 0) + { + puts ("remove_from_all_applications"); + nautilus_mime_remove_from_all_applications_for_file + (file, comma_separated_str_to_str_list (value)); + } + else + { + usage (argv[0]); + } + + return 0; } diff --git a/test/test-nautilus-mime-actions.c b/test/test-nautilus-mime-actions.c index 761c4a960..38e140fd6 100644 --- a/test/test-nautilus-mime-actions.c +++ b/test/test-nautilus-mime-actions.c @@ -1,25 +1,25 @@ /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ /* test-mime.c - Test for the mime handler detection features of the GNOME - Virtual File System Library - - Copyright (C) 2000 Eazel - - The Gnome Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Gnome Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Gnome Library; see the file COPYING.LIB. If not, - see <http://www.gnu.org/licenses/>. - - Author: Maciej Stachowiak <mjs@eazel.com> -*/ + * Virtual File System Library + * + * Copyright (C) 2000 Eazel + * + * The Gnome Library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * The Gnome Library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with the Gnome Library; see the file COPYING.LIB. If not, + * see <http://www.gnu.org/licenses/>. + * + * Author: Maciej Stachowiak <mjs@eazel.com> + */ #include <config.h> @@ -32,104 +32,114 @@ static gboolean ready = FALSE; static void append_comma_and_scheme (gpointer scheme, - gpointer user_data) + gpointer user_data) { - char **string; - - string = (char **) user_data; - if (strlen (*string) > 0) { - *string = g_strconcat (*string, ", ", scheme, NULL); - } - else { - *string = g_strdup (scheme); - } + char **string; + + string = (char **) user_data; + if (strlen (*string) > 0) + { + *string = g_strconcat (*string, ", ", scheme, NULL); + } + else + { + *string = g_strdup (scheme); + } } static char * format_supported_uri_schemes_for_display (GList *supported_uri_schemes) { - char *string; + char *string; - string = g_strdup (""); - g_list_foreach (supported_uri_schemes, - append_comma_and_scheme, - &string); - return string; + string = g_strdup (""); + g_list_foreach (supported_uri_schemes, + append_comma_and_scheme, + &string); + return string; } static void print_application (GAppInfo *application) { - if (application == NULL) { - puts ("(none)"); - } else { - printf ("name: %s\ncommand: %s\nexpects_uris: %s\n", - g_application_get_name (application), - g_application_get_executable (application), - (g_app_info_supports_uris (application) ? "TRUE" : "FALSE")); - } + if (application == NULL) + { + puts ("(none)"); + } + else + { + printf ("name: %s\ncommand: %s\nexpects_uris: %s\n", + g_application_get_name (application), + g_application_get_executable (application), + (g_app_info_supports_uris (application) ? "TRUE" : "FALSE")); + } } -static void +static void print_application_list (GList *applications) { - GList *p; - - if (applications == NULL) { - puts ("(none)"); - } else { - for (p = applications; p != NULL; p = p->next) { - print_application (p->data); - puts ("------"); - } - } + GList *p; + + if (applications == NULL) + { + puts ("(none)"); + } + else + { + for (p = applications; p != NULL; p = p->next) + { + print_application (p->data); + puts ("------"); + } + } } static void ready_callback (NautilusFile *file, - gpointer callback_data) + gpointer callback_data) { - ready = TRUE; + ready = TRUE; } int -main (int argc, char **argv) +main (int argc, + char **argv) { - const char *uri; - GAppInfo *default_application; - GList *all_applications; - NautilusFile *file; - NautilusFileAttributes attributes; - - gtk_init (&argc, &argv); - - if (argc != 2) { - fprintf (stderr, "Usage: %s uri\n", *argv); - return 1; - } - - uri = argv[1]; - file = nautilus_file_get_by_uri (uri); - - attributes = nautilus_mime_actions_get_full_file_attributes (); - nautilus_file_call_when_ready (file, attributes, ready_callback, NULL); - - while (!ready) { - gtk_main_iteration (); - } - - default_application = nautilus_mime_get_default_application_for_file (file); - puts("Default Application"); - print_application (default_application); - puts (""); - - all_applications = nautilus_mime_get_applications_for_file (file); - puts("All Applications"); - print_application_list (all_applications); - puts (""); - - return 0; + const char *uri; + GAppInfo *default_application; + GList *all_applications; + NautilusFile *file; + NautilusFileAttributes attributes; + + gtk_init (&argc, &argv); + + if (argc != 2) + { + fprintf (stderr, "Usage: %s uri\n", *argv); + return 1; + } + + uri = argv[1]; + file = nautilus_file_get_by_uri (uri); + + attributes = nautilus_mime_actions_get_full_file_attributes (); + nautilus_file_call_when_ready (file, attributes, ready_callback, NULL); + + while (!ready) + { + gtk_main_iteration (); + } + + default_application = nautilus_mime_get_default_application_for_file (file); + puts ("Default Application"); + print_application (default_application); + puts (""); + + all_applications = nautilus_mime_get_applications_for_file (file); + puts ("All Applications"); + print_application_list (all_applications); + puts (""); + + return 0; } - - diff --git a/test/test-nautilus-search-engine.c b/test/test-nautilus-search-engine.c index f37718072..2847109f4 100644 --- a/test/test-nautilus-search-engine.c +++ b/test/test-nautilus-search-engine.c @@ -3,57 +3,60 @@ #include <gtk/gtk.h> static void -hits_added_cb (NautilusSearchEngine *engine, GSList *hits) -{ - g_print ("hits added\n"); - while (hits) { - g_print (" - %s\n", (char *)hits->data); - hits = hits->next; - } +hits_added_cb (NautilusSearchEngine *engine, + GSList *hits) +{ + g_print ("hits added\n"); + while (hits) + { + g_print (" - %s\n", (char *) hits->data); + hits = hits->next; + } } static void finished_cb (NautilusSearchEngine *engine, NautilusSearchProviderStatus status) { - g_print ("finished!\n"); - gtk_main_quit (); + g_print ("finished!\n"); + gtk_main_quit (); } -int -main (int argc, char* argv[]) +int +main (int argc, + char *argv[]) { - NautilusSearchEngine *engine; - NautilusSearchEngineModel *model; - NautilusDirectory *directory; - NautilusQuery *query; - GFile *location; - - gtk_init (&argc, &argv); - - engine = nautilus_search_engine_new (); - g_signal_connect (engine, "hits-added", - G_CALLBACK (hits_added_cb), NULL); - g_signal_connect (engine, "finished", - G_CALLBACK (finished_cb), NULL); - - query = nautilus_query_new (); - nautilus_query_set_text (query, "richard hult"); - nautilus_search_provider_set_query (NAUTILUS_SEARCH_PROVIDER (engine), query); - g_object_unref (query); - - location = g_file_new_for_path (g_get_home_dir ()); - directory = nautilus_directory_get (location); - g_object_unref (location); - - model = nautilus_search_engine_get_model_provider (engine); - nautilus_search_engine_model_set_model (model, directory); - g_object_unref (directory); - - nautilus_search_provider_start (NAUTILUS_SEARCH_PROVIDER (engine)); - nautilus_search_provider_stop (NAUTILUS_SEARCH_PROVIDER (engine)); - g_object_unref (engine); - - gtk_main (); - return 0; + NautilusSearchEngine *engine; + NautilusSearchEngineModel *model; + NautilusDirectory *directory; + NautilusQuery *query; + GFile *location; + + gtk_init (&argc, &argv); + + engine = nautilus_search_engine_new (); + g_signal_connect (engine, "hits-added", + G_CALLBACK (hits_added_cb), NULL); + g_signal_connect (engine, "finished", + G_CALLBACK (finished_cb), NULL); + + query = nautilus_query_new (); + nautilus_query_set_text (query, "richard hult"); + nautilus_search_provider_set_query (NAUTILUS_SEARCH_PROVIDER (engine), query); + g_object_unref (query); + + location = g_file_new_for_path (g_get_home_dir ()); + directory = nautilus_directory_get (location); + g_object_unref (location); + + model = nautilus_search_engine_get_model_provider (engine); + nautilus_search_engine_model_set_model (model, directory); + g_object_unref (directory); + + nautilus_search_provider_start (NAUTILUS_SEARCH_PROVIDER (engine)); + nautilus_search_provider_stop (NAUTILUS_SEARCH_PROVIDER (engine)); + g_object_unref (engine); + + gtk_main (); + return 0; } diff --git a/test/test.c b/test/test.c index 5481044f5..43e8fbc43 100644 --- a/test/test.c +++ b/test/test.c @@ -3,115 +3,123 @@ #include <unistd.h> void -test_init (int *argc, - char ***argv) +test_init (int *argc, + char ***argv) { - gtk_init (argc, argv); + gtk_init (argc, argv); - eel_make_warnings_and_criticals_stop_in_debugger (); + eel_make_warnings_and_criticals_stop_in_debugger (); } int test_quit (int exit_code) { - if (gtk_main_level () > 0) { - gtk_main_quit (); - } + if (gtk_main_level () > 0) + { + gtk_main_quit (); + } - return exit_code; + return exit_code; } void test_delete_event (GtkWidget *widget, - GdkEvent *event, - gpointer callback_data) + GdkEvent *event, + gpointer callback_data) { - test_quit (0); + test_quit (0); } GtkWidget * -test_window_new (const char *title, guint border_width) +test_window_new (const char *title, + guint border_width) { - GtkWidget *window; - - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - - if (title != NULL) { - gtk_window_set_title (GTK_WINDOW (window), title); - } - - g_signal_connect (window, "delete_event", - G_CALLBACK (test_delete_event), NULL); - - gtk_container_set_border_width (GTK_CONTAINER (window), border_width); - - return window; + GtkWidget *window; + + window = gtk_window_new (GTK_WINDOW_TOPLEVEL); + + if (title != NULL) + { + gtk_window_set_title (GTK_WINDOW (window), title); + } + + g_signal_connect (window, "delete_event", + G_CALLBACK (test_delete_event), NULL); + + gtk_container_set_border_width (GTK_CONTAINER (window), border_width); + + return window; } GdkPixbuf * -test_pixbuf_new_named (const char *name, float scale) +test_pixbuf_new_named (const char *name, + float scale) { - GdkPixbuf *pixbuf; - char *path; + GdkPixbuf *pixbuf; + char *path; - g_return_val_if_fail (name != NULL, NULL); - g_return_val_if_fail (scale >= 0.0, NULL); + g_return_val_if_fail (name != NULL, NULL); + g_return_val_if_fail (scale >= 0.0, NULL); - if (name[0] == '/') { - path = g_strdup (name); - } else { - path = g_strdup_printf ("%s/%s", NAUTILUS_DATADIR, name); - } + if (name[0] == '/') + { + path = g_strdup (name); + } + else + { + path = g_strdup_printf ("%s/%s", NAUTILUS_DATADIR, name); + } - pixbuf = gdk_pixbuf_new_from_file (path, NULL); + pixbuf = gdk_pixbuf_new_from_file (path, NULL); - g_free (path); + g_free (path); - g_return_val_if_fail (pixbuf != NULL, NULL); - - if (scale != 1.0) { - GdkPixbuf *scaled; - float width = gdk_pixbuf_get_width (pixbuf) * scale; - float height = gdk_pixbuf_get_width (pixbuf) * scale; + g_return_val_if_fail (pixbuf != NULL, NULL); - scaled = gdk_pixbuf_scale_simple (pixbuf, width, height, GDK_INTERP_BILINEAR); + if (scale != 1.0) + { + GdkPixbuf *scaled; + float width = gdk_pixbuf_get_width (pixbuf) * scale; + float height = gdk_pixbuf_get_width (pixbuf) * scale; - g_object_unref (pixbuf); + scaled = gdk_pixbuf_scale_simple (pixbuf, width, height, GDK_INTERP_BILINEAR); - g_return_val_if_fail (scaled != NULL, NULL); + g_object_unref (pixbuf); - pixbuf = scaled; - } + g_return_val_if_fail (scaled != NULL, NULL); - return pixbuf; + pixbuf = scaled; + } + + return pixbuf; } GtkWidget * test_label_new (const char *text, - gboolean with_background, - int num_sizes_larger) + gboolean with_background, + int num_sizes_larger) { - GtkWidget *label; + GtkWidget *label; + + if (text == NULL) + { + text = "Foo"; + } - if (text == NULL) { - text = "Foo"; - } - - label = gtk_label_new (text); + label = gtk_label_new (text); - return label; + return label; } -void -test_window_set_title_with_pid (GtkWindow *window, - const char *title) +void +test_window_set_title_with_pid (GtkWindow *window, + const char *title) { - char *tmp; - - g_return_if_fail (GTK_IS_WINDOW (window)); + char *tmp; - tmp = g_strdup_printf ("%lu: %s", (gulong) getpid (), title); - gtk_window_set_title (GTK_WINDOW (window), tmp); - g_free (tmp); -} + g_return_if_fail (GTK_IS_WINDOW (window)); + tmp = g_strdup_printf ("%lu: %s", (gulong) getpid (), title); + gtk_window_set_title (GTK_WINDOW (window), tmp); + g_free (tmp); +} diff --git a/test/uncrustify-sample.c b/test/uncrustify-sample.c deleted file mode 100644 index 2ed14be4f..000000000 --- a/test/uncrustify-sample.c +++ /dev/null @@ -1,63 +0,0 @@ -/* -Extremely poorly formatted code to test uncrustify.cfg against the contiki code style - */ - -#if defined (FOO) - # define BAR 3 -#else - # define BAR 3 -# endif - -/* Aligment of parameters doesn't work as completely expected. Should align the - * stars themselves. */ -static int some_function ( int *f , char **c, LongTypeException a) { - - /* This is indented with a tab. Should become spaces */ - int a = 5; // This should become a C comment - int d= - 10; /* Space around assignment, No space between - and 10 */ - int* b; /* no space before the *, yes space between * and variable name */ - - some_function( - a, - b - ) - -/* Should indent the for correctly and sort out spacing mess: - - for(i = 0; i < 10; ++i) - - Should pull the opening brace up to the same line as the for -*/ -for( i=0 ;i<10; ++ i ) { if (a < 0) { - a= ! c ; /* Should add space after a and remove space before and after c */ - - /* } else { always in the same line */ - } - else - { - /* incorrect indentation here */ - - f(); - } - } - - b = & c; /* 'address of' adjacent to variable */ - * b = 3; /* dereference: no space */ - - /* Should automatically add braces below */ - if(a == 0) - printf ( "a\n") ; - - while(1) ; /* This needs fixed */ - - switch(a) { - case 3 : -4; -5; - break; - } - - /* No blank lines before the closing brace */ - - return (-1); /* No parenthesis around return values */ - - -} |