1" Tests for complicated + argument to :edit command
2function 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')
10endfunction
11
12func Test_edit_bad()
13  if !has('multi_byte')
14    finish
15  endif
16
17  " Test loading a utf8 file with bad utf8 sequences.
18  call writefile(["[\xff][\xc0][\xe2\x89\xf0][\xc2\xc2]"], "Xfile")
19  new
20
21  " Without ++bad=..., the default behavior is like ++bad=?
22  e! ++enc=utf8 Xfile
23  call assert_equal('[?][?][???][??]', getline(1))
24
25  e! ++enc=utf8 ++bad=_ Xfile
26  call assert_equal('[_][_][___][__]', getline(1))
27
28  e! ++enc=utf8 ++bad=drop Xfile
29  call assert_equal('[][][][]', getline(1))
30
31  e! ++enc=utf8 ++bad=keep Xfile
32  call assert_equal("[\xff][\xc0][\xe2\x89\xf0][\xc2\xc2]", getline(1))
33
34  call assert_fails('e! ++enc=utf8 ++bad=foo Xfile', 'E474:')
35
36  bw!
37  call delete('Xfile')
38endfunc
39