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