summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-07-10 17:14:39 -0400
committerMatthias Clasen <mclasen@redhat.com>2021-07-10 18:50:07 -0400
commit5d8694fd3085ce6d870d49f96f9cdd07de151f8e (patch)
tree45c021b519e4281f7e814fa0bad2b30879043fbf
parent6a28e306a4b4a779aa62f0eab4e2f1c70241345c (diff)
downloadpango-5d8694fd3085ce6d870d49f96f9cdd07de151f8e.tar.gz
tests: Locale handling fixes
The return value of setlocale is only good until the next call. Also, consistently use en_US.UTF-8.
-rw-r--r--tests/meson.build1
-rw-r--r--tests/test-break.c2
-rw-r--r--tests/test-font.c1
-rw-r--r--tests/test-itemize.c6
-rw-r--r--tests/test-layout.c10
-rw-r--r--tests/test-shape.c1
6 files changed, 12 insertions, 9 deletions
diff --git a/tests/meson.build b/tests/meson.build
index baf5ad6b..841a78eb 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -16,6 +16,7 @@ test_env = environment()
test_env.set('srcdir', meson.current_source_dir())
test_env.set('G_TEST_SRCDIR', meson.current_source_dir())
test_env.set('G_TEST_BUILDDIR', meson.current_build_dir())
+test_env.set('LC_ALL', 'en_US.UTF-8')
tests = [
[ 'test-bidi' ],
diff --git a/tests/test-break.c b/tests/test-break.c
index 0158bd40..66c207a5 100644
--- a/tests/test-break.c
+++ b/tests/test-break.c
@@ -292,7 +292,7 @@ test_break (gconstpointer d)
gchar *diff;
char *old_locale = g_strdup (setlocale (LC_ALL, NULL));
- setlocale (LC_ALL, "en_US.utf8");
+ setlocale (LC_ALL, "en_US.UTF-8");
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);
diff --git a/tests/test-font.c b/tests/test-font.c
index 3c5f3070..f291cec8 100644
--- a/tests/test-font.c
+++ b/tests/test-font.c
@@ -463,7 +463,6 @@ test_match (void)
int
main (int argc, char *argv[])
{
- g_setenv ("LC_ALL", "C", TRUE);
setlocale (LC_ALL, "");
g_test_init (&argc, &argv, NULL);
diff --git a/tests/test-itemize.c b/tests/test-itemize.c
index d1447a0f..52556284 100644
--- a/tests/test-itemize.c
+++ b/tests/test-itemize.c
@@ -237,13 +237,14 @@ test_itemize (gconstpointer d)
GString *dump;
gchar *diff;
- const char *old_locale = setlocale (LC_ALL, NULL);
- setlocale (LC_ALL, "en_US.utf8");
+ char *old_locale = g_strdup (setlocale (LC_ALL, NULL));
+ setlocale (LC_ALL, "en_US.UTF-8");
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);
+ g_free (old_locale);
return;
}
@@ -259,6 +260,7 @@ test_itemize (gconstpointer d)
g_assert_no_error (error);
setlocale (LC_ALL, old_locale);
+ g_free (old_locale);
if (diff && diff[0])
{
diff --git a/tests/test-layout.c b/tests/test-layout.c
index ca9e5da5..502bc98a 100644
--- a/tests/test-layout.c
+++ b/tests/test-layout.c
@@ -703,13 +703,14 @@ test_layout (gconstpointer d)
GString *dump;
gchar *diff;
- const char *old_locale = setlocale (LC_ALL, NULL);
- setlocale (LC_ALL, "en_US.utf8");
+ char *old_locale = g_strdup (setlocale (LC_ALL, NULL));
+ setlocale (LC_ALL, "en_US.UTF-8");
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);
+ g_free (old_locale);
return;
}
@@ -726,6 +727,7 @@ test_layout (gconstpointer d)
g_assert_no_error (error);
setlocale (LC_ALL, old_locale);
+ g_free (old_locale);
if (diff && diff[0])
{
@@ -755,6 +757,8 @@ main (int argc, char *argv[])
const gchar *name;
gchar *path;
+ setlocale (LC_ALL, "");
+
if (g_getenv ("PANGO_TEST_SHOW_FONT"))
opt_show_font = TRUE;
@@ -763,8 +767,6 @@ main (int argc, char *argv[])
{
GString *string;
- setlocale (LC_ALL, "en_US.utf8");
-
string = g_string_sized_new (0);
test_file (argv[1], string);
g_print ("%s", string->str);
diff --git a/tests/test-shape.c b/tests/test-shape.c
index be3e4415..a04291e4 100644
--- a/tests/test-shape.c
+++ b/tests/test-shape.c
@@ -337,7 +337,6 @@ 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);