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-string-util.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/test/test-string-util.c') diff --git a/src/test/test-string-util.c b/src/test/test-string-util.c index 2d10041b2..54f9b29ef 100644 --- a/src/test/test-string-util.c +++ b/src/test/test-string-util.c @@ -171,6 +171,9 @@ static void test_cellescape(void) { assert_se(streq(cellescape(buf, 1, "\020"), "")); assert_se(streq(cellescape(buf, 2, "\020"), ".")); assert_se(streq(cellescape(buf, 3, "\020"), "..")); +#if 1 /// elogind supports systems with non-UTF-8 locales, the next would fail there + if (is_locale_utf8()) { +#endif // 1 assert_se(streq(cellescape(buf, 4, "\020"), "…")); assert_se(streq(cellescape(buf, 5, "\020"), "\\020")); @@ -178,26 +181,47 @@ static void test_cellescape(void) { assert_se(streq(cellescape(buf, 6, "1234\020"), "12…")); assert_se(streq(cellescape(buf, 7, "1234\020"), "123…")); assert_se(streq(cellescape(buf, 8, "1234\020"), "1234…")); +#if 1 /// elogind supports systems with non-UTF-8 locales, the previous would fail there + } +#endif // 1 assert_se(streq(cellescape(buf, 9, "1234\020"), "1234\\020")); assert_se(streq(cellescape(buf, 1, "\t\n"), "")); assert_se(streq(cellescape(buf, 2, "\t\n"), ".")); assert_se(streq(cellescape(buf, 3, "\t\n"), "..")); +#if 1 /// elogind supports systems with non-UTF-8 locales, the next would fail there + if (is_locale_utf8()) { +#endif // 1 assert_se(streq(cellescape(buf, 4, "\t\n"), "…")); +#if 1 /// elogind supports systems with non-UTF-8 locales, the previous would fail there + } +#endif // 1 assert_se(streq(cellescape(buf, 5, "\t\n"), "\\t\\n")); +#if 1 /// elogind supports systems with non-UTF-8 locales, the next would fail there + if (is_locale_utf8()) { +#endif // 1 assert_se(streq(cellescape(buf, 5, "1234\t\n"), "1…")); assert_se(streq(cellescape(buf, 6, "1234\t\n"), "12…")); assert_se(streq(cellescape(buf, 7, "1234\t\n"), "123…")); assert_se(streq(cellescape(buf, 8, "1234\t\n"), "1234…")); +#if 1 /// elogind supports systems with non-UTF-8 locales, the previous would fail there + } +#endif // 1 assert_se(streq(cellescape(buf, 9, "1234\t\n"), "1234\\t\\n")); +#if 1 /// elogind supports systems with non-UTF-8 locales, the next would fail there + if (is_locale_utf8()) { +#endif // 1 assert_se(streq(cellescape(buf, 4, "x\t\020\n"), "…")); assert_se(streq(cellescape(buf, 5, "x\t\020\n"), "x…")); assert_se(streq(cellescape(buf, 6, "x\t\020\n"), "x…")); assert_se(streq(cellescape(buf, 7, "x\t\020\n"), "x\\t…")); assert_se(streq(cellescape(buf, 8, "x\t\020\n"), "x\\t…")); assert_se(streq(cellescape(buf, 9, "x\t\020\n"), "x\\t…")); +#if 1 /// elogind supports systems with non-UTF-8 locales, the previous would fail there + } +#endif // 1 assert_se(streq(cellescape(buf, 10, "x\t\020\n"), "x\\t\\020\\n")); assert_se(streq(cellescape(buf, 6, "1\011"), "1\\t")); -- cgit v1.2.3