robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
f907614088
master
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 () 10before_each ( function () 11clear () 12-- sanity check: tests should run with encoding=utf-8 13eq ( 'utf-8' , eval ( '&encoding' )) 14eq ( 3 , eval ( 'strwidth("Bär")' )) 15end ) 16 17it ( 'cannot be changed after setup' , function () 18t . matches ( 'E519%:' , t . pcall_err ( n . command , 'set encoding=latin1' )) 19eq ( 'utf-8' , eval ( '&encoding' )) 20-- check nvim is still in utf-8 mode 21eq ( 3 , eval ( 'strwidth("Bär")' )) 22end ) 23 24it ( 'cannot be changed before startup' , function () 25clear ( '--cmd' , 'set enc=latin1' ) 26-- error message expected 27feed ( '<cr>' ) 28neq ( nil , string . find ( eval ( 'v:errmsg' ), '^E519:' )) 29eq ( 'utf-8' , eval ( '&encoding' )) 30eq ( 3 , eval ( 'strwidth("Bär")' )) 31end ) 32 33it ( 'can be set to utf-8 without error' , function () 34n . command ( 'set encoding=utf-8' ) 35eq ( '' , eval ( 'v:errmsg' )) 36 37clear ( '--cmd' , 'set enc=utf-8' ) 38eq ( '' , eval ( 'v:errmsg' )) 39end ) 40end )