aboutsummaryrefslogtreecommitdiffstats
path: root/spec/util_human_io_spec.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-11-12 14:21:15 +0100
committerKim Alvefur <zash@zash.se>2021-11-12 14:21:15 +0100
commitd1144a7ede35eb04e0c81c328e3684eb1f7f3f72 (patch)
tree11210945b10d20eb85dd51a9d7e188753511f70f /spec/util_human_io_spec.lua
parentb9837e2d99bddff368c4b5e2721479093c1f8858 (diff)
downloadprosody-d1144a7ede35eb04e0c81c328e3684eb1f7f3f72.tar.gz
prosody-d1144a7ede35eb04e0c81c328e3684eb1f7f3f72.zip
util.human.io: Fix cutting of UTF-8 into pieces
Down the rabbit hole we go...
Diffstat (limited to 'spec/util_human_io_spec.lua')
-rw-r--r--spec/util_human_io_spec.lua19
1 files changed, 19 insertions, 0 deletions
diff --git a/spec/util_human_io_spec.lua b/spec/util_human_io_spec.lua
index ead117df..f1b28883 100644
--- a/spec/util_human_io_spec.lua
+++ b/spec/util_human_io_spec.lua
@@ -23,6 +23,25 @@ describe("util.human.io", function ()
end);
end);
+
+ describe("ellipsis", function()
+ it("works", function()
+ assert.equal("…", human_io.ellipsis("abc", 1));
+ assert.equal("a…", human_io.ellipsis("abc", 2));
+ assert.equal("abc", human_io.ellipsis("abc", 3));
+
+ assert.equal("…", human_io.ellipsis("räksmörgås", 1));
+ assert.equal("r…", human_io.ellipsis("räksmörgås", 2));
+ assert.equal("rä…", human_io.ellipsis("räksmörgås", 3));
+ assert.equal("räk…", human_io.ellipsis("räksmörgås", 4));
+ assert.equal("räks…", human_io.ellipsis("räksmörgås", 5));
+ assert.equal("räksm…", human_io.ellipsis("räksmörgås", 6));
+ assert.equal("räksmö…", human_io.ellipsis("räksmörgås", 7));
+ assert.equal("räksmör…", human_io.ellipsis("räksmörgås", 8));
+ assert.equal("räksmörg…", human_io.ellipsis("räksmörgås", 9));
+ assert.equal("räksmörgås", human_io.ellipsis("räksmörgås", 10));
+ end);
+ end);
end);