test_startup_utf8.vim 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. " Tests for startup using utf-8.
  2. source check.vim
  3. source shared.vim
  4. source screendump.vim
  5. func Test_read_stdin_utf8()
  6. let linesin = ['テスト', '€ÀÈÌÒÙ']
  7. call writefile(linesin, 'Xtestin', 'D')
  8. let before = [
  9. \ 'set enc=utf-8',
  10. \ 'set fencs=cp932,utf-8',
  11. \ ]
  12. let after = [
  13. \ 'write ++enc=utf-8 Xtestout',
  14. \ 'quit!',
  15. \ ]
  16. if has('win32')
  17. let pipecmd = 'type Xtestin | '
  18. else
  19. let pipecmd = 'cat Xtestin | '
  20. endif
  21. if RunVimPiped(before, after, '-', pipecmd)
  22. let lines = readfile('Xtestout')
  23. call assert_equal(linesin, lines)
  24. else
  25. call assert_equal('', 'RunVimPiped failed.')
  26. endif
  27. call delete('Xtestout')
  28. endfunc
  29. func Test_read_fifo_utf8()
  30. CheckUnix
  31. " Using bash/zsh's process substitution.
  32. if executable('bash')
  33. set shell=bash
  34. elseif executable('zsh')
  35. set shell=zsh
  36. else
  37. throw 'Skipped: bash or zsh is required'
  38. endif
  39. let linesin = ['テスト', '€ÀÈÌÒÙ']
  40. call writefile(linesin, 'Xtestin', 'D')
  41. let before = [
  42. \ 'set enc=utf-8',
  43. \ 'set fencs=cp932,utf-8',
  44. \ ]
  45. let after = [
  46. \ 'write ++enc=utf-8 Xtestout',
  47. \ 'quit!',
  48. \ ]
  49. if RunVim(before, after, '<(cat Xtestin)')
  50. let lines = readfile('Xtestout')
  51. call assert_equal(linesin, lines)
  52. else
  53. call assert_equal('', 'RunVim failed.')
  54. endif
  55. call delete('Xtestout')
  56. endfunc
  57. func Test_detect_ambiwidth()
  58. CheckRunVimInTerminal
  59. " Use the title termcap entries to output the escape sequence.
  60. call writefile([
  61. \ 'set enc=utf-8',
  62. \ 'set ambiwidth=double',
  63. \ 'call test_option_not_set("ambiwidth")',
  64. \ 'redraw',
  65. \ ], 'Xscript', 'D')
  66. let buf = RunVimInTerminal('-S Xscript', #{keep_t_u7: 1})
  67. call TermWait(buf)
  68. call term_sendkeys(buf, "S\<C-R>=&ambiwidth\<CR>\<Esc>")
  69. call WaitForAssert({-> assert_match('single', term_getline(buf, 1))})
  70. call StopVimInTerminal(buf)
  71. endfunc
  72. " vim: shiftwidth=2 sts=2 expandtab