comparison src/testdir/test_startup_utf8.vim @ 9828:e84e45786691 v7.4.2189

commit https://github.com/vim/vim/commit/f71d7b9ee5ceba75f70c30845332ddd728fd16c6 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Aug 9 22:14:05 2016 +0200 patch 7.4.2189 Problem: Cannot detect encoding in a fifo. Solution: Extend the stdin way of detecting encoding to fifo. Add a test for detecting encoding on stdin and fifo. (Ken Takata)
author Christian Brabandt <cb@256bit.org>
date Tue, 09 Aug 2016 22:15:06 +0200
parents
children 1e6666885bc0
comparison
equal deleted inserted replaced
9827:bc358576ace1 9828:e84e45786691
1 " Tests for startup using utf-8.
2 if !has('multi_byte')
3 finish
4 endif
5
6 source shared.vim
7
8 func 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')
32 endfunc
33
34 func 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')
64 endfunc