#include "alloc-util.h"
#include "format-table.h"
+#include "locale-util.h"
#include "string-util.h"
#include "time-util.h"
assert_se(table_format(table, &formatted) >= 0);
printf("%s\n", formatted);
- assert_se(streq(formatted,
- "NAME TYPE RO USAGE CREATED MODIFIED \n"
- "foooo raw no 673.6M Wed 2018-07-11 00:10:33 J… Wed 2018-07-11 00:16:00 JST\n"
- ));
+ if (is_locale_utf8())
+ assert_se(streq(formatted,
+ "NAME TYPE RO USAGE CREATED MODIFIED \n"
+ "foooo raw no 673.6M Wed 2018-07-11 00:10:33 J… Wed 2018-07-11 00:16:00 JST\n"
+ ));
+ else
+ assert_se(streq(formatted,
+ "NAME TYPE RO USAGE CREATED MODIFIED \n"
+ "foooo raw no 673.6M Wed 2018-07-11 00:10:33... Wed 2018-07-11 00:16:00 JST\n"
+ ));
}
int main(int argc, char *argv[]) {
assert_se(table_format(t, &formatted) >= 0);
printf("%s\n", formatted);
- assert_se(streq(formatted,
- "ONE TWO THR…\n"
- "xxx yyy yes\n"
- "a … YYY no\n"));
+ if (is_locale_utf8())
+ assert_se(streq(formatted,
+ "ONE TWO THR…\n"
+ "xxx yyy yes\n"
+ "a … YYY no\n"));
+ else
+ assert_se(streq(formatted,
+ "ONE TWO T...\n"
+ "xxx yyy yes\n"
+ "... YYY no\n"));
formatted = mfree(formatted);
assert_se(table_format(t, &formatted) >= 0);
printf("%s\n", formatted);
- assert_se(streq(formatted,
- "… … …\n"
- "… … …\n"
- "… … …\n"));
+ if (is_locale_utf8())
+ assert_se(streq(formatted,
+ "… … …\n"
+ "… … …\n"
+ "… … …\n"));
+ else
+ assert_se(streq(formatted,
+ ". . .\n"
+ ". . .\n"
+ ". . .\n"));
formatted = mfree(formatted);
assert_se(table_format(t, &formatted) >= 0);
printf("%s\n", formatted);
- assert_se(streq(formatted,
- "… … …\n"
- "… … …\n"
- "… … …\n"));
+ if (is_locale_utf8())
+ assert_se(streq(formatted,
+ "… … …\n"
+ "… … …\n"
+ "… … …\n"));
+ else
+ assert_se(streq(formatted,
+ ". . .\n"
+ ". . .\n"
+ ". . .\n"));
formatted = mfree(formatted);
assert_se(table_format(t, &formatted) >= 0);
printf("%s\n", formatted);
- if (isatty(STDOUT_FILENO))
- assert_se(streq(formatted,
- " no a long f… no a long f… a long fi…\n"
- " no fäää no fäää fäää \n"
- " yes fäää yes fäää fäää \n"
- " yes xxx yes xxx xxx \n"
- "5min 5min \n"));
- else
+ if (isatty(STDOUT_FILENO)) {
+ if (is_locale_utf8())
+ assert_se(streq(formatted,
+ " no a long f… no a long f… a long fi…\n"
+ " no fäää no fäää fäää \n"
+ " yes fäää yes fäää fäää \n"
+ " yes xxx yes xxx xxx \n"
+ "5min 5min \n"));
+ else
+ assert_se(streq(formatted,
+ " no a long... no a long... a long ...\n"
+ " no fäää no fäää fäää \n"
+ " yes fäää yes fäää fäää \n"
+ " yes xxx yes xxx xxx \n"
+ "5min 5min \n"));
+ } else
assert_se(streq(formatted,
" no a long field no a long field a long field\n"
" no fäää no fäää fäää \n"
assert_se(streq(cellescape(buf, 1, "\020"), ""));
assert_se(streq(cellescape(buf, 2, "\020"), "."));
assert_se(streq(cellescape(buf, 3, "\020"), ".."));
- assert_se(streq(cellescape(buf, 4, "\020"), "…"));
+ assert_se(streq(cellescape(buf, 4, "\020"), is_locale_utf8() ? "…" : "..."));
assert_se(streq(cellescape(buf, 5, "\020"), "\\020"));
- assert_se(streq(cellescape(buf, 5, "1234\020"), "1…"));
- 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…"));
+ assert_se(streq(cellescape(buf, 5, "1234\020"), is_locale_utf8() ? "1…" : "1..."));
+ assert_se(streq(cellescape(buf, 6, "1234\020"), is_locale_utf8() ? "12…" : "12..."));
+ assert_se(streq(cellescape(buf, 7, "1234\020"), is_locale_utf8() ? "123…" : "123..."));
+ assert_se(streq(cellescape(buf, 8, "1234\020"), is_locale_utf8() ? "1234…" : "1234..."));
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"), ".."));
- assert_se(streq(cellescape(buf, 4, "\t\n"), "…"));
+ assert_se(streq(cellescape(buf, 4, "\t\n"), is_locale_utf8() ? "…" : "..."));
assert_se(streq(cellescape(buf, 5, "\t\n"), "\\t\\n"));
- 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…"));
+ assert_se(streq(cellescape(buf, 5, "1234\t\n"), is_locale_utf8() ? "1…" : "1..."));
+ assert_se(streq(cellescape(buf, 6, "1234\t\n"), is_locale_utf8() ? "12…" : "12..."));
+ assert_se(streq(cellescape(buf, 7, "1234\t\n"), is_locale_utf8() ? "123…" : "123..."));
+ assert_se(streq(cellescape(buf, 8, "1234\t\n"), is_locale_utf8() ? "1234…" : "1234..."));
assert_se(streq(cellescape(buf, 9, "1234\t\n"), "1234\\t\\n"));
- 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…"));
+ assert_se(streq(cellescape(buf, 4, "x\t\020\n"), is_locale_utf8() ? "…" : "..."));
+ assert_se(streq(cellescape(buf, 5, "x\t\020\n"), is_locale_utf8() ? "x…" : "x..."));
+ assert_se(streq(cellescape(buf, 6, "x\t\020\n"), is_locale_utf8() ? "x…" : "x..."));
+ assert_se(streq(cellescape(buf, 7, "x\t\020\n"), is_locale_utf8() ? "x\\t…" : "x\\t..."));
+ assert_se(streq(cellescape(buf, 8, "x\t\020\n"), is_locale_utf8() ? "x\\t…" : "x\\t..."));
+ assert_se(streq(cellescape(buf, 9, "x\t\020\n"), is_locale_utf8() ? "x\\t…" : "x\\t..."));
assert_se(streq(cellescape(buf, 10, "x\t\020\n"), "x\\t\\020\\n"));
assert_se(streq(cellescape(buf, 6, "1\011"), "1\\t"));