[gnome-desktop/jbicha/gnome-desktop-tests-unset-env: 1/3] tests: Use uselocale instead of setlocale



commit ca8fede7a01ac069864f17190b3633a80acd193f
Author: Jeremy Bicha <jbicha ubuntu com>
Date:   Tue Feb 12 14:30:36 2019 -0500

    tests: Use uselocale instead of setlocale
    
    uselocale is generally recommend instead of setlocale as a safer choice.

 tests/wallclock-reftest.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/tests/wallclock-reftest.c b/tests/wallclock-reftest.c
index 3db9cf1d..da8cafd4 100644
--- a/tests/wallclock-reftest.c
+++ b/tests/wallclock-reftest.c
@@ -438,14 +438,17 @@ test_ui_file (GFile         *file,
   GtkStyleProvider *provider;
   GnomeWallClock *clock;
   GDateTime *datetime;
-  char *str, *set_locale;
+  char *str;
+  locale_t loc, set_locale;
 
   ui_file = g_file_get_path (file);
 
   locale = get_locale_for_file (ui_file);
   g_assert (locale);
-  set_locale = setlocale (LC_ALL, locale);
-  g_assert_cmpstr (set_locale, ==, locale);
+  loc = newlocale (LC_ALL_MASK, locale, (locale_t) 0);
+  set_locale = uselocale (loc);
+  /*TODO: CI fails when I tried to use freelocale (loc); later */
+  g_assert_true (set_locale != (locale_t) 0);
 
   clock = gnome_wall_clock_new();
   datetime = g_date_time_new_local (2014, 5, 28, 23, 59, 59);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]