Software /
code /
prosody
Comparison
spec/util_human_io_spec.lua @ 10978:4d3247a1f6b3
util.human.io: Add brief test of table generation
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 28 Jun 2020 14:58:32 +0200 |
child | 11896:93e9f7ae2f9b |
comparison
equal
deleted
inserted
replaced
10977:29b9b679bdbc | 10978:4d3247a1f6b3 |
---|---|
1 describe("util.human.io", function () | |
2 local human_io | |
3 setup(function () | |
4 human_io = require "util.human.io"; | |
5 end); | |
6 describe("table", function () | |
7 | |
8 it("alignment works", function () | |
9 local row = human_io.table({ | |
10 { | |
11 width = 3, | |
12 align = "right" | |
13 }, | |
14 { | |
15 width = 3, | |
16 }, | |
17 }); | |
18 | |
19 assert.equal(" 1 | . ", row({ 1, "." })); | |
20 assert.equal(" 10 | .. ", row({ 10, ".." })); | |
21 assert.equal("100 | ...", row({ 100, "..." })); | |
22 assert.equal("10… | ..…", row({ 1000, "...." })); | |
23 | |
24 end); | |
25 end); | |
26 end); | |
27 | |
28 | |
29 |