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