Improve test coverage of g_utf8_collate_key_for_filename
authorMatthias Clasen <mclasen@redhat.com>
Mon, 30 Dec 2013 14:48:56 +0000 (09:48 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Wed, 1 Jan 2014 22:59:22 +0000 (17:59 -0500)
The existing tests were accidentally using the same test data
twice. Fix that, and add another set of tests that exercise
the filename collation special cases.

glib/tests/collate.c

index a99d1f9..a6fda18 100644 (file)
@@ -188,13 +188,64 @@ const gchar *file_sorted1[] = {
   NULL
 };
 
+const gchar *input2[] = {
+  "file26",
+  "file100",
+  "file1",
+  "file:foo",
+  "a.a",
+  "file027",
+  "file10",
+  "aa.a",
+  "file5",
+  "file0027",
+  "a-.a",
+  "file0000",
+  "file000x",
+  NULL
+};
+
+const gchar *sorted2[] = {
+  "a-.a",
+  "a.a",
+  "aa.a",
+  "file0000",
+  "file000x",
+  "file0027",
+  "file027",
+  "file1",
+  "file10",
+  "file100",
+  "file26",
+  "file5",
+  "file:foo",
+  NULL
+};
+
+const gchar *file_sorted2[] = {
+  "a.a",
+  "a-.a",
+  "aa.a",
+  "file0000",
+  "file000x",
+  "file1",
+  "file5",
+  "file10",
+  "file26",
+  "file027",
+  "file0027",
+  "file100",
+  "file:foo",
+  NULL
+};
+
 int
 main (int argc, char *argv[])
 {
   gchar *path;
   gint i;
   const gchar *locale;
-  CollateTest test[2];
+  CollateTest test[3];
 
   g_test_init (&argc, &argv, NULL);
 
@@ -212,6 +263,9 @@ main (int argc, char *argv[])
   test[1].input = input1;
   test[1].sorted = sorted1;
   test[1].file_sorted = file_sorted1;
+  test[2].input = input2;
+  test[2].sorted = sorted2;
+  test[2].file_sorted = file_sorted2;
 
   for (i = 0; i < G_N_ELEMENTS (test); i++)
     {
@@ -219,10 +273,10 @@ main (int argc, char *argv[])
       g_test_add_data_func (path, &test[i], test_collate);
       g_free (path);
       path = g_strdup_printf ("/unicode/collate-key/%d", i);
-      g_test_add_data_func (path, test, test_collate_key);
+      g_test_add_data_func (path, &test[i], test_collate_key);
       g_free (path);
       path = g_strdup_printf ("/unicode/collate-filename/%d", i);
-      g_test_add_data_func (path, test, test_collate_file);
+      g_test_add_data_func (path, &test[i], test_collate_file);
       g_free (path);
     }