test_plus_arg_edit.vim 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. func Test_edit_bad()
  12. " Test loading a utf8 file with bad utf8 sequences.
  13. call writefile(["[\xff][\xc0][\xe2\x89\xf0][\xc2\xc2]"], "Xfile")
  14. new
  15. " Without ++bad=..., the default behavior is like ++bad=?
  16. e! ++enc=utf8 Xfile
  17. call assert_equal('[?][?][???][??]', getline(1))
  18. e! ++encoding=utf8 ++bad=_ Xfile
  19. call assert_equal('[_][_][___][__]', getline(1))
  20. e! ++enc=utf8 ++bad=drop Xfile
  21. call assert_equal('[][][][]', getline(1))
  22. e! ++enc=utf8 ++bad=keep Xfile
  23. call assert_equal("[\xff][\xc0][\xe2\x89\xf0][\xc2\xc2]", getline(1))
  24. call assert_fails('e! ++enc=utf8 ++bad=foo Xfile', 'E474:')
  25. bw!
  26. call delete('Xfile')
  27. endfunc
  28. " Test for ++bin and ++nobin arguments
  29. func Test_binary_arg()
  30. new
  31. edit ++bin Xfile1
  32. call assert_equal(1, &binary)
  33. edit ++nobin Xfile2
  34. call assert_equal(0, &binary)
  35. call assert_fails('edit ++binabc Xfile3', 'E474:')
  36. close!
  37. endfunc
  38. " vim: shiftwidth=2 sts=2 expandtab