robin/laufey

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

Justin M. KeyesMerge #40865 from justinmk/fixcif907614088

master
1.1 KiB40 linesraw
1local t = require('test.testutil')
2local describe, it, before_each = t.describe, t.it, t.before_each
3local pcall_err = t.pcall_err
4local n = require('test.functional.testnvim')()
5
6local clear, feed = n.clear, n.feed
7local eq, neq, eval = t.eq, t.neq, n.eval
8
9describe('&encoding', function()
10  before_each(function()
11    clear()
12    -- sanity check: tests should run with encoding=utf-8
13    eq('utf-8', eval('&encoding'))
14    eq(3, eval('strwidth("Bär")'))
15  end)
16
17  it('cannot be changed after setup', function()
18    t.matches('E519%:', t.pcall_err(n.command, 'set encoding=latin1'))
19    eq('utf-8', eval('&encoding'))
20    -- check nvim is still in utf-8 mode
21    eq(3, eval('strwidth("Bär")'))
22  end)
23
24  it('cannot be changed before startup', function()
25    clear('--cmd', 'set enc=latin1')
26    -- error message expected
27    feed('<cr>')
28    neq(nil, string.find(eval('v:errmsg'), '^E519:'))
29    eq('utf-8', eval('&encoding'))
30    eq(3, eval('strwidth("Bär")'))
31  end)
32
33  it('can be set to utf-8 without error', function()
34    n.command('set encoding=utf-8')
35    eq('', eval('v:errmsg'))
36
37    clear('--cmd', 'set enc=utf-8')
38    eq('', eval('v:errmsg'))
39  end)
40end)