blob: d179a4cc793e3248257148ad2b3cdd4311a27fde [file] [log] [blame]
Bram Moolenaarf71d7b92016-08-09 22:14:05 +02001" Tests for startup using utf-8.
2if !has('multi_byte')
3 finish
4endif
5
6source shared.vim
7
8func Test_read_stdin_utf8()
9 let linesin = ['テスト', '€ÀÈÌÒÙ']
10 call writefile(linesin, 'Xtestin')
11 let before = [
12 \ 'set enc=utf-8',
13 \ 'set fencs=cp932,utf-8',
14 \ ]
15 let after = [
16 \ 'write ++enc=utf-8 Xtestout',
17 \ 'quit!',
18 \ ]
19 if has('win32')
20 let pipecmd = 'type Xtestin | '
21 else
22 let pipecmd = 'cat Xtestin | '
23 endif
24 if RunVimPiped(before, after, '-', pipecmd)
25 let lines = readfile('Xtestout')
26 call assert_equal(linesin, lines)
27 else
28 call assert_equal('', 'RunVimPiped failed.')
29 endif
30 call delete('Xtestout')
31 call delete('Xtestin')
32endfunc
33
34func Test_read_fifo_utf8()
35 if !has('unix')
36 return
37 endif
38 " Using bash/zsh's process substitution.
39 if executable('bash')
40 set shell=bash
41 elseif executable('zsh')
42 set shell=zsh
43 else
44 return
45 endif
46 let linesin = ['テスト', '€ÀÈÌÒÙ']
47 call writefile(linesin, 'Xtestin')
48 let before = [
49 \ 'set enc=utf-8',
50 \ 'set fencs=cp932,utf-8',
51 \ ]
52 let after = [
53 \ 'write ++enc=utf-8 Xtestout',
54 \ 'quit!',
55 \ ]
56 if RunVim(before, after, '<(cat Xtestin)')
57 let lines = readfile('Xtestout')
58 call assert_equal(linesin, lines)
59 else
60 call assert_equal('', 'RunVim failed.')
61 endif
62 call delete('Xtestout')
63 call delete('Xtestin')
64endfunc