summaryrefslogtreecommitdiff
path: root/src/test/test-ellipsize.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-04-11 19:52:25 +0200
committerLennart Poettering <lennart@poettering.net>2018-04-18 12:35:45 +0200
commitc30a49b2d019d8657f5a2ca1a3bfdd8bc7ca673c (patch)
tree6c9bd1c638d36ff277899658c370ed2819f68737 /src/test/test-ellipsize.c
parentadea407d111c04deef81e2e615de6102adb3956a (diff)
downloadsystemd-c30a49b2d019d8657f5a2ca1a3bfdd8bc7ca673c.tar.gz
string-util: tweak ellipsation a bit
This primarily changes to things: 1. Ellipsation to 0, 1 or 2 characters is now supported. Previously we'd hit an assert if the new lengths was < 3, this is now permitted. The result strings won't show too much info still of course, but the code becomes a bit more generic and robust to use. 2. If a UTF-8 mode is disabled and the input string is pure ASCII, then "..." is used for ellipsation, otherwise (as before) "…". This means on a pure-ASCII system we should remain pure-ASCII, matching behaviour otherwise exposed with special_glyph() and friends. Note that we'll use "…" for ellipsiation as soon as either the locale settings indicate an UTF-8 mode or the input string already contains non-ASCII unicode characters. Testing for these special cases is improved.
Diffstat (limited to 'src/test/test-ellipsize.c')
-rw-r--r--src/test/test-ellipsize.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/test/test-ellipsize.c b/src/test/test-ellipsize.c
index ba4b043fc9..902bc3342f 100644
--- a/src/test/test-ellipsize.c
+++ b/src/test/test-ellipsize.c
@@ -17,6 +17,30 @@ static void test_one(const char *p) {
_cleanup_free_ char *t;
t = ellipsize(p, columns(), 70);
puts(t);
+ free(t);
+ t = ellipsize(p, columns(), 0);
+ puts(t);
+ free(t);
+ t = ellipsize(p, columns(), 100);
+ puts(t);
+ free(t);
+ t = ellipsize(p, 0, 50);
+ puts(t);
+ free(t);
+ t = ellipsize(p, 1, 50);
+ puts(t);
+ free(t);
+ t = ellipsize(p, 2, 50);
+ puts(t);
+ free(t);
+ t = ellipsize(p, 3, 50);
+ puts(t);
+ free(t);
+ t = ellipsize(p, 4, 50);
+ puts(t);
+ free(t);
+ t = ellipsize(p, 5, 50);
+ puts(t);
}
int main(int argc, char *argv[]) {