Comparison

spec/util_human_io_spec.lua @ 11896:93e9f7ae2f9b

util.human.io: Fix cutting of UTF-8 into pieces Down the rabbit hole we go...
author Kim Alvefur <zash@zash.se>
date Fri, 12 Nov 2021 14:21:15 +0100
parent 10978:4d3247a1f6b3
child 13054:f4d7fe919969
comparison
equal deleted inserted replaced
11895:d278a4c6da7f 11896:93e9f7ae2f9b
21 assert.equal("100 | ...", row({ 100, "..." })); 21 assert.equal("100 | ...", row({ 100, "..." }));
22 assert.equal("10… | ..…", row({ 1000, "...." })); 22 assert.equal("10… | ..…", row({ 1000, "...." }));
23 23
24 end); 24 end);
25 end); 25 end);
26
27 describe("ellipsis", function()
28 it("works", function()
29 assert.equal("…", human_io.ellipsis("abc", 1));
30 assert.equal("a…", human_io.ellipsis("abc", 2));
31 assert.equal("abc", human_io.ellipsis("abc", 3));
32
33 assert.equal("…", human_io.ellipsis("räksmörgås", 1));
34 assert.equal("r…", human_io.ellipsis("räksmörgås", 2));
35 assert.equal("rä…", human_io.ellipsis("räksmörgås", 3));
36 assert.equal("räk…", human_io.ellipsis("räksmörgås", 4));
37 assert.equal("räks…", human_io.ellipsis("räksmörgås", 5));
38 assert.equal("räksm…", human_io.ellipsis("räksmörgås", 6));
39 assert.equal("räksmö…", human_io.ellipsis("räksmörgås", 7));
40 assert.equal("räksmör…", human_io.ellipsis("räksmörgås", 8));
41 assert.equal("räksmörg…", human_io.ellipsis("räksmörgås", 9));
42 assert.equal("räksmörgås", human_io.ellipsis("räksmörgås", 10));
43 end);
44 end);
26 end); 45 end);
27 46
28 47
29 48