[kdbus] Do not set body message if signature field is empty
[platform/upstream/glib.git] / tests / unicode-encoding.c
index 9065b9e..75c982e 100644 (file)
@@ -1,3 +1,6 @@
+#undef G_DISABLE_ASSERT
+#undef G_LOG_DOMAIN
+
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -6,7 +9,7 @@
 
 static gint exit_status = 0;
 
-void
+static void
 croak (char *format, ...)
 {
   va_list va;
@@ -18,7 +21,7 @@ croak (char *format, ...)
   exit (1);
 }
 
-void
+static void
 fail (char *format, ...)
 {
   va_list va;
@@ -84,7 +87,7 @@ process (gint      line,
   const gchar *end;
   gboolean is_valid = g_utf8_validate (utf8, -1, &end);
   GError *error = NULL;
-  gint items_read, items_written;
+  glong items_read, items_written;
 
   switch (status)
     {
@@ -188,11 +191,11 @@ process (gint      line,
       gunichar2 *utf16_from_utf8;
       gunichar2 *utf16_from_ucs4;
       gunichar *ucs4_result;
-      gint bytes_written;
+      gsize bytes_written;
       gint n_chars;
       gchar *utf8_result;
 
-#ifdef G_OS_WIN32
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
 #define TARGET "UTF-16LE"
 #else
 #define TARGET "UTF-16"
@@ -305,7 +308,6 @@ process (gint      line,
 int
 main (int argc, char **argv)
 {
-  gchar *srcdir = getenv ("srcdir");
   gchar *testfile;
   gchar *contents;
   GError *error = NULL;
@@ -318,11 +320,10 @@ main (int argc, char **argv)
   GArray *ucs4;
   Status status = VALID;       /* Quiet GCC */
 
-  if (!srcdir)
-    srcdir = ".";
-  
-  testfile = g_strconcat (srcdir, G_DIR_SEPARATOR_S "utf8.txt", NULL);
-  
+  g_test_init (&argc, &argv, NULL);
+
+  testfile = g_test_build_filename (G_TEST_DIST, "utf8.txt", NULL);
+
   g_file_get_contents (testfile, &contents, NULL, &error);
   if (error)
     croak ("Cannot open utf8.txt: %s", error->message);
@@ -415,5 +416,8 @@ main (int argc, char **argv)
       line++;
     }
 
-  return 0;
+  g_free (testfile);
+  g_array_free (ucs4, TRUE);
+  g_free (contents);
+  return exit_status;
 }