stringx_spec.lua

local sh = require 'lsh'

describe('stringx', function()
  it('splits on whitespace', function()
    assert.are.same({'one', 'two', 'three'}, sh.stringx.split('one two  three'))
  end)

  it('splits on a separator', function()
    assert.are.same({'one ', 'wo  ', 'hree'}, sh.stringx.split('one two  three', 't'))
  end)

  it('limits the number of splits', function()
    assert.are.same({'a', 'b,c'}, sh.stringx.split('a,b,c', ',', 1))
  end)

  it('removes a final newline', function()
    assert.are.equal('abc', (sh.stringx.chomp('abc\n')))
    assert.are.equal('abc', (sh.stringx.chomp('abc')))
  end)
end)
generated by LDoc 1.5.0 Last updated 2026-09-27 08:00:58 UTC (28dfb93)