Bram Moolenaar | 292eff0 | 2017-07-11 21:46:28 +0200 | [diff] [blame] | 1 | " Tests for complicated + argument to :edit command |
| 2 | function Test_edit() |
Bram Moolenaar | 7580849 | 2018-06-12 12:39:41 +0200 | [diff] [blame] | 3 | call writefile(["foo|bar"], "Xfile1") |
| 4 | call writefile(["foo/bar"], "Xfile2") |
Bram Moolenaar | 292eff0 | 2017-07-11 21:46:28 +0200 | [diff] [blame] | 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")) |
Bram Moolenaar | 6e77df2 | 2017-11-21 11:43:08 +0100 | [diff] [blame] | 8 | call delete('Xfile1') |
| 9 | call delete('Xfile2') |
Bram Moolenaar | 292eff0 | 2017-07-11 21:46:28 +0200 | [diff] [blame] | 10 | endfunction |
Bram Moolenaar | 7580849 | 2018-06-12 12:39:41 +0200 | [diff] [blame] | 11 | |
| 12 | func Test_edit_bad() |
Bram Moolenaar | 7580849 | 2018-06-12 12:39:41 +0200 | [diff] [blame] | 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! ++enc=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 |
Bram Moolenaar | f0cee19 | 2020-02-16 13:33:56 +0100 | [diff] [blame^] | 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 |