[glom/gtkmm4v4] tests: parsing_time: Ignore the current locale.



commit fc562ed7dd4b4ab1fa54514b76d7ce9cf73a9473
Author: Murray Cumming <murrayc murrayc com>
Date:   Mon Apr 17 08:27:55 2017 +0200

    tests: parsing_time: Ignore the current locale.
    
    Because this fails otherwise if LC_TIME is, for instance, de_DE.UTF-8,
    because strptime() then incorrectly parses strings with AM or PM.

 tests/test_parsing_time.cc |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
---
diff --git a/tests/test_parsing_time.cc b/tests/test_parsing_time.cc
index 39f2386..3927b56 100644
--- a/tests/test_parsing_time.cc
+++ b/tests/test_parsing_time.cc
@@ -6,6 +6,21 @@ int main()
 {
   Gnome::Gda::init();
 
+  // Use the C locale, to make this test behave the same regardless of the user's current locale.
+  // (This is necessary, because Glib::init (via Gnome::Gda::init()) sets the locale, as of glibmm-2.54.
+
+  try
+  {
+    std::locale::global(std::locale("C"));
+  }
+  catch(const std::runtime_error& ex)
+  {
+    //This has been known to throw an exception at least once:
+    //https://bugzilla.gnome.org/show_bug.cgi?id=619445
+    //This should tell us what the problem is:
+    std::cerr << G_STRFUNC << ": exception from std::locale::global(): " << ex.what() << std::endl;
+  }
+
   const Glib::ustring time_text_input = "01:00 PM";
   //std::cout << "time_text_input=" << time_text_input << std::endl;
 


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