File: wordwrap_spec.lua

package info (click to toggle)
lua-cliargs 3.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 388 kB
  • sloc: sh: 118; javascript: 14; makefile: 5
file content (26 lines) | stat: -rw-r--r-- 804 bytes parent folder | download | duplicates (3)
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)