Imported Upstream version 2.66.1
[platform/upstream/glib.git] / glib / tests / collate.c
index a6fda18..bd9ea23 100644 (file)
@@ -1,8 +1,12 @@
+#include "config.h"
+
 #include <glib.h>
 #include <locale.h>
 #include <stdlib.h>
 #include <string.h>
 
+static gboolean missing_locale = FALSE;
+
 typedef struct {
   const gchar **input;
   const gchar **sorted;
@@ -45,6 +49,12 @@ do_collate (gboolean for_file, gboolean use_key, const CollateTest *test)
   Line line;
   gint i;
 
+  if (missing_locale)
+    {
+      g_test_skip ("no en_US locale");
+      return;
+    }
+
   line_array = g_array_new (FALSE, FALSE, sizeof(Line));
   g_array_set_clear_func (line_array, (GDestroyNotify)clear_line);
 
@@ -223,6 +233,23 @@ const gchar *sorted2[] = {
 };
 
 const gchar *file_sorted2[] = {
+  /* Filename collation in OS X follows Finder style which gives
+   * a slightly different order from usual Linux locales. */
+#ifdef HAVE_CARBON
+  "a-.a",
+  "a.a",
+  "aa.a",
+  "file:foo",
+  "file0000",
+  "file000x",
+  "file1",
+  "file5",
+  "file10",
+  "file26",
+  "file0027",
+  "file027",
+  "file100",
+#else
   "a.a",
   "a-.a",
   "aa.a",
@@ -236,6 +263,7 @@ const gchar *file_sorted2[] = {
   "file0027",
   "file100",
   "file:foo",
+#endif
   NULL
 };
 
@@ -243,7 +271,7 @@ int
 main (int argc, char *argv[])
 {
   gchar *path;
-  gint i;
+  guint i;
   const gchar *locale;
   CollateTest test[3];
 
@@ -253,8 +281,10 @@ main (int argc, char *argv[])
   locale = setlocale (LC_ALL, "");
   if (locale == NULL || strcmp (locale, "en_US") != 0)
     {
-      g_test_message ("No suitable locale, skipping test");
-      return 0;
+      g_test_message ("No suitable locale, skipping tests");
+      missing_locale = TRUE;
+      /* let the tests run to completion so they show up as SKIP'd in TAP
+       * output */
     }
 
   test[0].input = input0;
@@ -282,4 +312,3 @@ main (int argc, char *argv[])
 
   return g_test_run ();
 }
-