robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
af23d17388
master
1" Tests for complicated + argument to :edit command 2function Test_edit () 3call writefile ([ "foo|bar" ], "Xfile1" ) 4call writefile ([ "foo/bar" ], "Xfile2" ) 5edit + 1 |s / |/ PIPE / |w Xfile1| e Xfile2|1 |s /\//SLASH/ |w 6call assert_equal ([ "fooPIPEbar" ], readfile ( "Xfile1" )) 7call assert_equal ([ "fooSLASHbar" ], readfile ( "Xfile2" )) 8call delete ( 'Xfile1' ) 9call delete ( 'Xfile2' ) 10endfunction 11 12func Test_edit_bad () 13" Test loading a utf8 file with bad utf8 sequences. 14call writefile ([ "[\xff][\xc0][\xe2\x89\xf0][\xc2\xc2]" ], "Xfile" ) 15new 16 17" Without ++bad=..., the default behavior is like ++bad=? 18e ! ++enc = utf8 Xfile 19call assert_equal ( '[?][?][???][??]' , getline ( 1 )) 20 21e ! ++encoding = utf8 ++bad = _ Xfile 22call assert_equal ( '[_][_][___][__]' , getline ( 1 )) 23 24e ! ++enc = utf8 ++bad = drop Xfile 25call assert_equal ( '[][][][]' , getline ( 1 )) 26 27e ! ++enc = utf8 ++bad = keep Xfile 28call assert_equal ( "[\xff][\xc0][\xe2\x89\xf0][\xc2\xc2]" , getline ( 1 )) 29 30call assert_fails ( 'e! ++enc=utf8 ++bad=foo Xfile' , 'E474:' ) 31 32bw ! 33call delete ( 'Xfile' ) 34endfunc 35 36" Test for ++bin and ++nobin arguments 37func Test_binary_arg () 38new 39edit ++bin Xfile1 40call assert_equal ( 1 , & binary ) 41edit ++nobin Xfile2 42call assert_equal ( 0 , & binary ) 43call assert_fails ( 'edit ++binabc Xfile3' , 'E474:' ) 44close ! 45endfunc 46 47" vim: shiftwidth=2 sts=2 expandtab