From e3b7da9b85e2fd388ed9d0e5ee1aa7883a392b01 Mon Sep 17 00:00:00 2001 From: Sven Eden Date: Tue, 23 Oct 2018 20:06:23 +0200 Subject: Prep v240: Fix tests running on systems with non-UTF-8 locales. Bug: #85 Closes: #85 Signed-off-by: Sven Eden --- src/test/test-format-table.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/test/test-format-table.c') diff --git a/src/test/test-format-table.c b/src/test/test-format-table.c index 2527cacbb..f94cdf624 100644 --- a/src/test/test-format-table.c +++ b/src/test/test-format-table.c @@ -5,6 +5,9 @@ #include "string-util.h" #include "time-util.h" +/// Additional includes needed by elogind +#include "locale-util.h" + static void test_issue_9549(void) { _cleanup_(table_unrefp) Table *table = NULL; _cleanup_free_ char *formatted = NULL; @@ -74,6 +77,10 @@ int main(int argc, char *argv[]) { table_set_width(t, 12); assert_se(table_format(t, &formatted) >= 0); + +#if 1 /// elogind supports systems with non-UTF-8 locales, the next would fail there + if (is_locale_utf8()) { +#endif // 1 printf("%s\n", formatted); assert_se(streq(formatted, @@ -104,6 +111,9 @@ int main(int argc, char *argv[]) { "… … …\n")); formatted = mfree(formatted); +#if 1 /// elogind supports systems with non-UTF-8 locales, the previous would fail there + } +#endif // 1 table_set_width(t, (size_t) -1); assert_se(table_set_sort(t, (size_t) 0, (size_t) 2, (size_t) -1) >= 0); @@ -120,6 +130,9 @@ int main(int argc, char *argv[]) { table_set_header(t, false); +#if 1 /// elogind supports systems with non-UTF-8 locales, the next would fail there + if (is_locale_utf8()) { +#endif // 1 assert_se(table_add_many(t, TABLE_STRING, "fäää", TABLE_STRING, "uuu", @@ -158,6 +171,9 @@ int main(int argc, char *argv[]) { " yes fäää yes fäää fäää \n" " yes xxx yes xxx xxx \n" "5min 5min \n")); +#if 1 /// elogind supports systems with non-UTF-8 locales, the previous would fail there + } +#endif // 1 test_issue_9549(); -- cgit v1.2.3