From cddce179f56fdec2cb18c0837bad55e29c552ad1 Mon Sep 17 00:00:00 2001 From: Emmanuel Fleury Date: Sat, 15 Jan 2022 13:44:15 +0100 Subject: [PATCH] Remove a disabled test case that was covered by glib/tests/collate.c Related to issue #1434 --- tests/meson.build | 1 - tests/run-collate-tests.sh | 36 ----------- tests/unicode-collate.c | 124 ------------------------------------- 3 files changed, 161 deletions(-) delete mode 100755 tests/run-collate-tests.sh delete mode 100644 tests/unicode-collate.c diff --git a/tests/meson.build b/tests/meson.build index 585e10549..71623ab8c 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -56,7 +56,6 @@ test_extra_programs = { 'extra_sources' : ['memchunks.c'], }, 'assert-msg-test' : {}, - 'unicode-collate' : {}, } if host_machine.system() != 'windows' diff --git a/tests/run-collate-tests.sh b/tests/run-collate-tests.sh deleted file mode 100755 index fe6f020b1..000000000 --- a/tests/run-collate-tests.sh +++ /dev/null @@ -1,36 +0,0 @@ -#! /bin/sh - -fail () -{ - echo "Test failed: $*" - exit 1 -} - -echo_v () -{ - if [ "$verbose" = "1" ]; then - echo "$*" - fi -} - -if [ "$1" = "-v" ]; then - verbose=1 -fi -for I in "${srcdir:-.}"/collate/*.in; do - echo_v "Sorting $I" - name=$(basename "${I}" .in) - ./unicode-collate "${I}" > collate.out - if [ $? -eq 2 ]; then - exit 0 - fi - diff collate.out "${srcdir:-.}/collate/$name.unicode" || - fail "unexpected error when using g_utf8_collate() on $I" - ./unicode-collate --key "${I}" > collate.out - diff collate.out "${srcdir:-.}/collate/$name.unicode" || - fail "unexpected error when using g_utf8_collate_key() on $I" - ./unicode-collate --file "${I}" > collate.out - diff collate.out "${srcdir:-.}/collate/$name.file" || - fail "unexpected error when using g_utf8_collate_key_for_filename() on $I" -done - -echo_v "All tests passed." diff --git a/tests/unicode-collate.c b/tests/unicode-collate.c deleted file mode 100644 index 8de3f60ca..000000000 --- a/tests/unicode-collate.c +++ /dev/null @@ -1,124 +0,0 @@ -#undef G_DISABLE_ASSERT -#undef G_LOG_DOMAIN - -#include -#include -#include -#include -#include - -typedef struct { - const char *key; - const char *str; -} Line; - - -static int -compare_collate (const void *a, const void *b) -{ - const Line *line_a = a; - const Line *line_b = b; - - return g_utf8_collate (line_a->str, line_b->str); -} - -static int -compare_key (const void *a, const void *b) -{ - const Line *line_a = a; - const Line *line_b = b; - - return strcmp (line_a->key, line_b->key); -} - -int main (int argc, char **argv) -{ - GIOChannel *in; - GError *error = NULL; - GArray *line_array = g_array_new (FALSE, FALSE, sizeof(Line)); - guint i; - gboolean do_key = FALSE; - gboolean do_file = FALSE; - gchar *locale; - - /* FIXME: need to modify environment here, - * since g_utf8_collate_key calls setlocal (LC_COLLATE, "") - */ - g_setenv ("LC_ALL", "en_US", TRUE); - locale = setlocale (LC_ALL, ""); - if (locale == NULL || strcmp (locale, "en_US") != 0) - { - fprintf (stderr, "No suitable locale, skipping test\n"); - return 2; - } - - if (argc != 1 && argc != 2 && argc != 3) - { - fprintf (stderr, "Usage: unicode-collate [--key|--file] [FILE]\n"); - return 1; - } - - i = 1; - if (argc > 1) - { - if (strcmp (argv[1], "--key") == 0) - { - do_key = TRUE; - i = 2; - } - else if (strcmp (argv[1], "--file") == 0) - { - do_key = TRUE; - do_file = TRUE; - i = 2; - } - } - - if (argc > (gint) i) - { - in = g_io_channel_new_file (argv[i], "r", &error); - if (!in) - { - fprintf (stderr, "Cannot open %s: %s\n", argv[i], error->message); - return 1; - } - } - else - { - in = g_io_channel_unix_new (fileno (stdin)); - } - - while (TRUE) - { - gsize term_pos; - gchar *str; - Line line; - - if (g_io_channel_read_line (in, &str, NULL, &term_pos, &error) != G_IO_STATUS_NORMAL) - break; - - str[term_pos] = '\0'; - - if (do_file) - line.key = g_utf8_collate_key_for_filename (str, -1); - else - line.key = g_utf8_collate_key (str, -1); - line.str = str; - - g_array_append_val (line_array, line); - } - - if (error) - { - fprintf (stderr, "Error reading test file, %s\n", error->message); - return 1; - } - - qsort (line_array->data, line_array->len, sizeof (Line), do_key ? compare_key : compare_collate); - for (i = 0; i < line_array->len; i++) - printf ("%s\n", g_array_index (line_array, Line, i).str); - - g_io_channel_unref (in); - - return 0; -}