1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
local subject = require('cliargs.utils.wordwrap')
describe("utils::wordwrap", function()
it("should work", function()
-- takes: text, size, padding
local text = "123456789 123456789 123456789!"
local expected, result
result = subject(text, 10)
expected = { "123456789", "123456789", "123456789!" }
assert.is.same(result, expected)
-- exact length + 1 overflow
result = subject(text, 9)
expected = { "123456789", "123456789", "123456789", "!" }
assert.is.same(result, expected)
result = subject(text, 9, true)
expected = { "123456789", "123456789", "123456789!" }
assert.is.same(result, expected)
result = subject(text, 8)
expected = { "12345678", "9", "12345678", "9", "12345678", "9!" }
assert.is.same(result, expected)
end)
end)
|