aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2017-12-08 11:42:40 +0000
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2017-12-08 11:42:40 +0000
commite3dada2f766fdaec79a873de12ef0ad40270da13 (patch)
tree26d518c511989c730f605608e1ce3fa0dc9802ba /tests
parent4d4434fefd229a6678c47d99487e9944ff70ed87 (diff)
downloadayatana-indicator-datetime-e3dada2f766fdaec79a873de12ef0ad40270da13.tar.gz
ayatana-indicator-datetime-e3dada2f766fdaec79a873de12ef0ad40270da13.tar.bz2
ayatana-indicator-datetime-e3dada2f766fdaec79a873de12ef0ad40270da13.zip
tests/test-formatter.cpp: Fix locale setting and ignore failures if the build system does not have en_US.UTF-8 as valid locale available.
Diffstat (limited to 'tests')
-rw-r--r--tests/test-formatter.cpp25
1 files changed, 16 insertions, 9 deletions
diff --git a/tests/test-formatter.cpp b/tests/test-formatter.cpp
index e61daa7..2157e7b 100644
--- a/tests/test-formatter.cpp
+++ b/tests/test-formatter.cpp
@@ -74,16 +74,17 @@ class FormatterFixture: public GlibFixture
}
else
{
- g_warning("Unable to set locale to %s; skipping %s locale tests.", expected_locale, name);
+ g_message("Unable to set locale to %s, actual locale is %s; skipping %s locale tests.", expected_locale, actual_locale, name);
return false;
}
}
- inline bool Set24hLocale() { return SetLocale("C", "24h"); }
- inline bool Set12hLocale() { return SetLocale("en_US.utf8", "12h"); }
+ inline bool Set24hLocale() { return SetLocale("C", "24h"); }
+ inline bool Set12hLocale() { return SetLocale("en_US.UTF-8", "12h"); }
};
+#ifdef HAS_URLDISPATCHER
/**
* Test the phone header format
*/
@@ -145,18 +146,24 @@ TEST_F(FormatterFixture, TestDesktopHeader)
auto now = DateTime::Local(2020, 10, 31, 18, 30, 59);
auto clock = std::make_shared<MockClock>(now);
+ bool locale_set = false;
for(const auto& test_case : test_cases)
{
- if (test_case.is_12h ? Set12hLocale() : Set24hLocale())
- {
- DesktopFormatter f(clock, m_settings);
+ test_case.is_12h ? locale_set = Set12hLocale() : locale_set = Set24hLocale();
+ DesktopFormatter f(clock, m_settings);
- m_settings->show_day.set(test_case.show_day);
- m_settings->show_date.set(test_case.show_date);
- m_settings->show_year.set(test_case.show_year);
+ m_settings->show_day.set(test_case.show_day);
+ m_settings->show_date.set(test_case.show_date);
+ m_settings->show_year.set(test_case.show_year);
+ if (locale_set)
+ {
ASSERT_STREQ(test_case.expected_format_string, f.header_format.get().c_str());
}
+ else
+ {
+ g_message("Ignoring test (expected: %s, probably flawed test result: %s).", test_case.expected_format_string, f.header_format.get().c_str());
+ }
}
}