blob: 33f50a9cfe2e3d2a82d13c16823fe0200fd6d589 [file] [log] [blame]
Bram Moolenaarf71d7b92016-08-09 22:14:05 +02001" Tests for startup using utf-8.
Bram Moolenaarf71d7b92016-08-09 22:14:05 +02002
Bram Moolenaara45551a2020-06-09 15:57:37 +02003source check.vim
Bram Moolenaarf71d7b92016-08-09 22:14:05 +02004source shared.vim
Bram Moolenaar24839ed2018-09-13 20:46:52 +02005source screendump.vim
Bram Moolenaarf71d7b92016-08-09 22:14:05 +02006
7func Test_read_stdin_utf8()
8 let linesin = ['テスト', '€ÀÈÌÒÙ']
9 call writefile(linesin, 'Xtestin')
10 let before = [
11 \ 'set enc=utf-8',
12 \ 'set fencs=cp932,utf-8',
13 \ ]
14 let after = [
15 \ 'write ++enc=utf-8 Xtestout',
16 \ 'quit!',
17 \ ]
18 if has('win32')
19 let pipecmd = 'type Xtestin | '
20 else
21 let pipecmd = 'cat Xtestin | '
22 endif
23 if RunVimPiped(before, after, '-', pipecmd)
24 let lines = readfile('Xtestout')
25 call assert_equal(linesin, lines)
26 else
27 call assert_equal('', 'RunVimPiped failed.')
28 endif
29 call delete('Xtestout')
30 call delete('Xtestin')
31endfunc
32
33func Test_read_fifo_utf8()
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +020034 CheckUnix
Bram Moolenaarf71d7b92016-08-09 22:14:05 +020035 " Using bash/zsh's process substitution.
36 if executable('bash')
37 set shell=bash
38 elseif executable('zsh')
39 set shell=zsh
40 else
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +020041 throw 'Skipped: bash or zsh is required'
Bram Moolenaarf71d7b92016-08-09 22:14:05 +020042 endif
43 let linesin = ['テスト', '€ÀÈÌÒÙ']
44 call writefile(linesin, 'Xtestin')
45 let before = [
46 \ 'set enc=utf-8',
47 \ 'set fencs=cp932,utf-8',
48 \ ]
49 let after = [
50 \ 'write ++enc=utf-8 Xtestout',
51 \ 'quit!',
52 \ ]
53 if RunVim(before, after, '<(cat Xtestin)')
54 let lines = readfile('Xtestout')
55 call assert_equal(linesin, lines)
56 else
57 call assert_equal('', 'RunVim failed.')
58 endif
59 call delete('Xtestout')
60 call delete('Xtestin')
61endfunc
Bram Moolenaar24839ed2018-09-13 20:46:52 +020062
63func Test_detect_ambiwidth()
Bram Moolenaar494e9062020-05-31 21:28:02 +020064 CheckRunVimInTerminal
Bram Moolenaar24839ed2018-09-13 20:46:52 +020065
66 " Use the title termcap entries to output the escape sequence.
67 call writefile([
68 \ 'set enc=utf-8',
69 \ 'set ambiwidth=double',
70 \ 'call test_option_not_set("ambiwidth")',
71 \ 'redraw',
72 \ ], 'Xscript')
Bram Moolenaara45551a2020-06-09 15:57:37 +020073 let buf = RunVimInTerminal('-S Xscript', #{keep_t_u7: 1})
Bram Moolenaar6a2c5a72020-04-08 21:50:25 +020074 call TermWait(buf)
Bram Moolenaar24839ed2018-09-13 20:46:52 +020075 call term_sendkeys(buf, "S\<C-R>=&ambiwidth\<CR>\<Esc>")
76 call WaitForAssert({-> assert_match('single', term_getline(buf, 1))})
77
78 call StopVimInTerminal(buf)
79 call delete('Xscript')
80endfunc
Bram Moolenaar6d91bcb2020-08-12 18:50:36 +020081
82" vim: shiftwidth=2 sts=2 expandtab