diff options
author | Emmanuele Bassi <ebassi@gnome.org> | 2020-03-09 12:21:57 +0000 |
---|---|---|
committer | Emmanuele Bassi <ebassi@gnome.org> | 2020-03-09 12:21:57 +0000 |
commit | 8b20cd91a96eae39bafe82ccf444dbc00759ad43 (patch) | |
tree | d592c51e26c025e31346f82b8eac7792c8001d89 | |
parent | fd320cad19f319c7c5dcfa16e3a30c5f7c922ab8 (diff) | |
download | libgweather-skip-locale.tar.gz |
Do not run local-dependent tests with missing localesskip-locale
Not everyone has all the locales installed all the time, so let's check
if a locale is available before using it.
-rw-r--r-- | libgweather/test_libgweather.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/libgweather/test_libgweather.c b/libgweather/test_libgweather.c index 8a21911..77ee459 100644 --- a/libgweather/test_libgweather.c +++ b/libgweather/test_libgweather.c @@ -643,6 +643,7 @@ static void test_location_names (void) { GWeatherLocation *world, *brussels; + char *old_locale; world = gweather_location_get_world (); g_assert (world); @@ -653,7 +654,16 @@ test_location_names (void) g_assert_cmpstr (gweather_location_get_sort_name (brussels), ==, "brussels"); g_assert_cmpstr (gweather_location_get_english_name (brussels), ==, "Brussels"); + old_locale = g_strdup (setlocale (LC_ALL, NULL)); setlocale (LC_ALL, "fr_FR.UTF-8"); + if (strstr (setlocale (LC_ALL, NULL), "fr_FR.UTF-8") == NULL) + { + g_test_skip ("locale fr_FR.UTF-8 not available, skipping localization tests"); + setlocale (LC_ALL, old_locale); + g_free (old_locale); + return; + } + _gweather_location_reset_world (); world = gweather_location_get_world (); @@ -665,7 +675,7 @@ test_location_names (void) g_assert_cmpstr (gweather_location_get_sort_name (brussels), ==, "bruxelles"); g_assert_cmpstr (gweather_location_get_english_name (brussels), ==, "Brussels"); - setlocale (LC_ALL, ""); + setlocale (LC_ALL, old_locale); _gweather_location_reset_world (); } |