robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

Justin M. KeyesMerge #40865 from justinmk/fixcif907614088

master
994 B41 linesraw
1local t = require('test.testutil')
2local n = require('test.functional.testnvim')()
3
4local describe, it, before_each = t.describe, t.it, t.before_each
5local call = n.call
6local clear = n.clear
7local eq = t.eq
8local expect = n.expect
9
10describe('getline()', function()
11  before_each(function()
12    clear()
13    call('setline', 1, { 'a', 'b', 'c' })
14    expect([[
15      a
16      b
17      c]])
18  end)
19
20  it('returns empty string for invalid line', function()
21    eq('', call('getline', -1))
22    eq('', call('getline', 0))
23    eq('', call('getline', 4))
24  end)
25
26  it('returns empty list for invalid range', function()
27    eq({}, call('getline', 2, 1))
28    eq({}, call('getline', -1, 1))
29    eq({}, call('getline', 4, 4))
30  end)
31
32  it('returns value of valid line', function()
33    eq('b', call('getline', 2))
34    eq('a', call('getline', '.'))
35  end)
36
37  it('returns value of valid range', function()
38    eq({ 'a', 'b' }, call('getline', 1, 2))
39    eq({ 'a', 'b', 'c' }, call('getline', 1, 4))
40  end)
41end)