[gnote] Make dttest locale-independent



commit 4a6395857c9bcfa399fab4160273d1f22f45a695
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Thu Sep 26 22:57:18 2013 +0300

    Make dttest locale-independent
    
    Fixes Bug 707546.

 src/test/dttest.cpp |   19 ++++++++++++++++---
 1 files changed, 16 insertions(+), 3 deletions(-)
---
diff --git a/src/test/dttest.cpp b/src/test/dttest.cpp
index adb1607..31196d0 100644
--- a/src/test/dttest.cpp
+++ b/src/test/dttest.cpp
@@ -33,8 +33,21 @@ bool string_ends_with(const std::string & s, const std::string & other)
   return (s.length() - s.rfind(other)) == other.length();
 }
 
+std::string string_to_lower(std::string s)
+{
+  for(std::string::size_type i = 0; i < s.size(); ++i) {
+    if(std::isalpha(s[i]) && std::isupper(s[i])) {
+      s[i] = std::tolower(s[i]);
+    }
+  }
+  return s;
+}
+
 int test_main(int /*argc*/, char ** /*argv*/)
 {
+  // force certain timezone so that time tests work
+  setenv("TZ", "Europe/London", 1);
+
   sharp::DateTime d(678901234, 67890);
 
   std::string date_string = sharp::XmlConvert::to_string(d);
@@ -69,10 +82,10 @@ int test_main(int /*argc*/, char ** /*argv*/)
 
   sharp::DateTime d6 = sharp::DateTime::from_iso8601("2009-03-24T13:34:35.2914680-04:00");
   date_string = gnote::utils::get_pretty_print_date(d6, true, false);
-  BOOST_CHECK(string_ends_with(date_string, "19:34"));
+  BOOST_CHECK(string_ends_with(date_string, "17:34"));
 
-  date_string = gnote::utils::get_pretty_print_date(d6, true, true);
-  BOOST_CHECK(string_ends_with(date_string, "7:34 pm"));
+  date_string = string_to_lower(gnote::utils::get_pretty_print_date(d6, true, true));
+  BOOST_CHECK(string_ends_with(date_string, "5:34 pm"));
 
   return 0;
 }


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