summaryrefslogtreecommitdiff
path: root/src/test/test-format-table.c
diff options
context:
space:
mode:
authorSven Eden <sven.eden@prydeworx.com>2018-10-23 20:06:23 +0200
committerSven Eden <sven.eden@prydeworx.com>2018-11-08 08:02:57 +0100
commite3b7da9b85e2fd388ed9d0e5ee1aa7883a392b01 (patch)
treeefd7cedff42c9d6febc63753f2de1d7eee35c50f /src/test/test-format-table.c
parent21554b54e3ae9e02fdc55f025bc91928633e96a2 (diff)
Prep v240: Fix tests running on systems with non-UTF-8 locales.
Bug: #85 Closes: #85 Signed-off-by: Sven Eden <sven.eden@prydeworx.com>
Diffstat (limited to 'src/test/test-format-table.c')
-rw-r--r--src/test/test-format-table.c16
1 files changed, 16 insertions, 0 deletions
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();