summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2020-06-08 17:39:50 +0000
committerMatthias Clasen <mclasen@redhat.com>2020-06-08 17:39:50 +0000
commit1fb9e50c73bb8c6389c7eaa9adb2eee13642d2ff (patch)
tree9a9e1b5f1de7162b283af8a1c5a910ae55cafffa /tests
parent0b32b337a85031f2db44309caa190338ee93d677 (diff)
parentf6032b754fd76ebbf0ae6ec4f3c8b2616add0e91 (diff)
downloadpango-1fb9e50c73bb8c6389c7eaa9adb2eee13642d2ff.tar.gz
Merge branch 'for-master' into 'master'
For master See merge request GNOME/pango!184
Diffstat (limited to 'tests')
-rw-r--r--tests/test-break.c31
-rw-r--r--tests/test-itemize.c32
-rw-r--r--tests/test-layout.c30
3 files changed, 74 insertions, 19 deletions
diff --git a/tests/test-break.c b/tests/test-break.c
index 3258cb98..aec36008 100644
--- a/tests/test-break.c
+++ b/tests/test-break.c
@@ -241,6 +241,19 @@ test_break (gconstpointer d)
GString *dump;
gchar *diff;
+ const char *old_locale = setlocale (LC_ALL, NULL);
+ setlocale (LC_ALL, "en_US.utf8");
+ if (strstr (setlocale (LC_ALL, NULL), "en_US") == NULL)
+ {
+ char *msg = g_strdup_printf ("Locale en_US.UTF-8 not available, skipping break %s", filename);
+ g_test_skip (msg);
+ g_free (msg);
+ return;
+ }
+
+ if (context == NULL)
+ context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
+
expected_file = get_expected_filename (filename);
dump = g_string_sized_new (0);
@@ -250,11 +263,22 @@ test_break (gconstpointer d)
diff = diff_with_file (expected_file, dump->str, dump->len, &error);
g_assert_no_error (error);
+ setlocale (LC_ALL, old_locale);
+
if (diff && diff[0])
{
+ char **lines = g_strsplit (diff, "\n", -1);
+ const char *line;
+ int i = 0;
+
g_test_message ("Contents don't match expected contents");
- g_test_message ("%s", diff);
+
+ for (line = lines[0]; line != NULL; line = lines[++i])
+ g_test_message ("%s", line);
+
g_test_fail ();
+
+ g_strfreev (lines);
g_free (diff);
}
@@ -270,13 +294,8 @@ main (int argc, char *argv[])
const gchar *name;
gchar *path;
- g_setenv ("LC_ALL", "en_US.UTF-8", TRUE);
- setlocale (LC_ALL, "");
-
g_test_init (&argc, &argv, NULL);
- context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
-
/* allow to easily generate expected output for new test cases */
if (argc > 1)
{
diff --git a/tests/test-itemize.c b/tests/test-itemize.c
index 167e4e80..3c58e18f 100644
--- a/tests/test-itemize.c
+++ b/tests/test-itemize.c
@@ -110,7 +110,7 @@ test_file (const gchar *filename, GString *string)
gchar *contents;
gsize length;
GError *error = NULL;
- GString *s1, *s2, *s3, *s4, *s5, *s6;
+ GString *s1, *s2, *s3, *s4, *s5, *s6;
char *test;
char *text;
PangoAttrList *attrs;
@@ -237,6 +237,18 @@ test_itemize (gconstpointer d)
GString *dump;
gchar *diff;
+ const char *old_locale = setlocale (LC_ALL, NULL);
+ setlocale (LC_ALL, "en_US.utf8");
+ if (strstr (setlocale (LC_ALL, NULL), "en_US") == NULL)
+ {
+ char *msg = g_strdup_printf ("Locale en_US.UTF-8 not available, skipping itemization %s", filename);
+ g_test_skip (msg);
+ g_free (msg);
+ return;
+ }
+
+ context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
+
expected_file = get_expected_filename (filename);
dump = g_string_sized_new (0);
@@ -246,11 +258,22 @@ test_itemize (gconstpointer d)
diff = diff_with_file (expected_file, dump->str, dump->len, &error);
g_assert_no_error (error);
+ setlocale (LC_ALL, old_locale);
+
if (diff && diff[0])
{
+ char **lines = g_strsplit (diff, "\n", -1);
+ const char *line;
+ int i = 0;
+
g_test_message ("Contents don't match expected contents");
- g_test_message ("%s", diff);
+
+ for (line = lines[0]; line != NULL; line = lines[++i])
+ g_test_message ("%s", line);
+
g_test_fail ();
+
+ g_strfreev (lines);
g_free (diff);
}
@@ -266,13 +289,8 @@ main (int argc, char *argv[])
const gchar *name;
gchar *path;
- g_setenv ("LC_ALL", "en_US.UTF-8", TRUE);
- setlocale (LC_ALL, "");
-
g_test_init (&argc, &argv, NULL);
- context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
-
/* allow to easily generate expected output for new test cases */
if (argc > 1)
{
diff --git a/tests/test-layout.c b/tests/test-layout.c
index 2fc78240..52617ce6 100644
--- a/tests/test-layout.c
+++ b/tests/test-layout.c
@@ -304,6 +304,19 @@ test_layout (gconstpointer d)
GString *dump;
gchar *diff;
+ const char *old_locale = setlocale (LC_ALL, NULL);
+ setlocale (LC_ALL, "en_US.utf8");
+ if (strstr (setlocale (LC_ALL, NULL), "en_US") == NULL)
+ {
+ char *msg = g_strdup_printf ("Locale en_US.UTF-8 not available, skipping layout %s", filename);
+ g_test_skip (msg);
+ g_free (msg);
+ return;
+ }
+
+ if (context == NULL)
+ context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
+
expected_file = get_expected_filename (filename);
dump = g_string_sized_new (0);
@@ -313,11 +326,21 @@ test_layout (gconstpointer d)
diff = diff_with_file (expected_file, dump->str, dump->len, &error);
g_assert_no_error (error);
+ setlocale (LC_ALL, old_locale);
+
if (diff && diff[0])
{
+ char **lines = g_strsplit (diff, "\n", -1);
+ const char *line;
+ int i = 0;
+
g_test_message ("Contents don't match expected contents");
- g_test_message ("%s", diff);
+
+ for (line = lines[0]; line != NULL; line = lines[++i])
+ g_test_message ("%s", line);
+
g_test_fail ();
+ g_strfreev (lines);
g_free (diff);
}
@@ -333,13 +356,8 @@ main (int argc, char *argv[])
const gchar *name;
gchar *path;
- g_setenv ("LC_ALL", "en_US.UTF-8", TRUE);
- setlocale (LC_ALL, "");
-
g_test_init (&argc, &argv, NULL);
- context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
-
/* allow to easily generate expected output for new test cases */
if (argc > 1)
{