[gtk/ci-file-filters: 5476/5477] Add tests for case-insensitive globs




commit 4e0eed8baeacea46c8d8c3f44f01c4aa58fcbf81
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Jun 3 23:50:36 2021 -0400

    Add tests for case-insensitive globs

 testsuite/gtk/fnmatch.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
---
diff --git a/testsuite/gtk/fnmatch.c b/testsuite/gtk/fnmatch.c
index a614c1f99b..be9192f11f 100644
--- a/testsuite/gtk/fnmatch.c
+++ b/testsuite/gtk/fnmatch.c
@@ -125,6 +125,28 @@ test_fnmatch (gconstpointer data)
   g_assert_true (_gtk_fnmatch (test->pat, test->str, test->no_leading_period, test->ci) == test->result);
 }
 
+typedef struct {
+  const char *glob;
+  const char *ci;
+} CITest;
+
+static CITest citests[] = {
+  { "*.txt", "*.[tT][xX][tT]" },
+  { "*.TXT", "*.[tT][xX][tT]" },
+  { "*?[]-abc]t", "*?[]-abc][tT]" },
+};
+
+static void
+test_ci_glob (gconstpointer data)
+{
+  const CITest *test = data;
+  char *ci;
+
+  ci = _gtk_make_ci_glob_pattern (test->glob);
+  g_assert_cmpstr (ci, ==, test->ci);
+  g_free (ci);
+}
+
 int
 main (int argc, char *argv[])
 {
@@ -136,5 +158,11 @@ main (int argc, char *argv[])
       g_test_add_data_func (path, &tests[i], test_fnmatch);
     }
 
+  for (int i = 0; i < G_N_ELEMENTS (citests); i++)
+    {
+      char *path = g_strdup_printf ("/ci-glob/test%d", i);
+      g_test_add_data_func (path, &citests[i], test_ci_glob);
+    }
+
   return g_test_run ();
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]