1" Test for :mksession, :mkview and :loadview in latin1 encoding
2
3set encoding=latin1
4scriptencoding latin1
5
6if !has('multi_byte') || !has('mksession')
7  finish
8endif
9
10func Test_mksession()
11  tabnew
12  let wrap_save = &wrap
13  set sessionoptions=buffers splitbelow fileencoding=latin1
14  call setline(1, [
15    \   'start:',
16    \   'no multibyte chAracter',
17    \   '	one leaDing tab',
18    \   '    four leadinG spaces',
19    \   'two		consecutive tabs',
20    \   'two	tabs	in one line',
21    \   'one � multibyteCharacter',
22    \   'a� �  two multiByte characters',
23    \   'A���  three mulTibyte characters'
24    \ ])
25  let tmpfile = 'Xtemp'
26  exec 'w! ' . tmpfile
27  /^start:
28  set wrap
29  vsplit
30  norm! j16|
31  split
32  norm! j16|
33  split
34  norm! j16|
35  split
36  norm! j8|
37  split
38  norm! j8|
39  split
40  norm! j16|
41  split
42  norm! j16|
43  split
44  norm! j16|
45  wincmd l
46
47  set nowrap
48  /^start:
49  norm! j16|3zl
50  split
51  norm! j016|3zl
52  split
53  norm! j016|3zl
54  split
55  norm! j08|3zl
56  split
57  norm! j08|3zl
58  split
59  norm! j016|3zl
60  split
61  norm! j016|3zl
62  split
63  norm! j016|3zl
64  split
65  call wincol()
66  mksession! Xtest_mks.out
67  let li = filter(readfile('Xtest_mks.out'), 'v:val =~# "\\(^ *normal! 0\\|^ *exe ''normal!\\)"')
68  let expected = [
69    \   'normal! 016|',
70    \   'normal! 016|',
71    \   'normal! 016|',
72    \   'normal! 08|',
73    \   'normal! 08|',
74    \   'normal! 016|',
75    \   'normal! 016|',
76    \   'normal! 016|',
77    \   "  exe 'normal! ' . s:c . '|zs' . 16 . '|'",
78    \   "  normal! 016|",
79    \   "  exe 'normal! ' . s:c . '|zs' . 16 . '|'",
80    \   "  normal! 016|",
81    \   "  exe 'normal! ' . s:c . '|zs' . 16 . '|'",
82    \   "  normal! 016|",
83    \   "  exe 'normal! ' . s:c . '|zs' . 8 . '|'",
84    \   "  normal! 08|",
85    \   "  exe 'normal! ' . s:c . '|zs' . 8 . '|'",
86    \   "  normal! 08|",
87    \   "  exe 'normal! ' . s:c . '|zs' . 16 . '|'",
88    \   "  normal! 016|",
89    \   "  exe 'normal! ' . s:c . '|zs' . 16 . '|'",
90    \   "  normal! 016|",
91    \   "  exe 'normal! ' . s:c . '|zs' . 16 . '|'",
92    \   "  normal! 016|",
93    \   "  exe 'normal! ' . s:c . '|zs' . 16 . '|'",
94    \   "  normal! 016|"
95    \ ]
96  call assert_equal(expected, li)
97  tabclose!
98
99  call delete('Xtest_mks.out')
100  call delete(tmpfile)
101  let &wrap = wrap_save
102endfunc
103
104func Test_mksession_winheight()
105  new
106  set winheight=10 winminheight=2
107  mksession! Xtest_mks.out
108  source Xtest_mks.out
109
110  call delete('Xtest_mks.out')
111endfunc
112
113func Test_mksession_arglist()
114  argdel *
115  next file1 file2 file3 file4
116  mksession! Xtest_mks.out
117  source Xtest_mks.out
118  call assert_equal(['file1', 'file2', 'file3', 'file4'], argv())
119
120  call delete('Xtest_mks.out')
121  argdel *
122endfunc
123
124func Test_mksession_one_buffer_two_windows()
125  edit Xtest1
126  new Xtest2
127  split
128  mksession! Xtest_mks.out
129  let lines = readfile('Xtest_mks.out')
130  let count1 = 0
131  let count2 = 0
132  let count2buf = 0
133  for line in lines
134    if line =~ 'edit \f*Xtest1$'
135      let count1 += 1
136    endif
137    if line =~ 'edit \f\{-}Xtest2'
138      let count2 += 1
139    endif
140    if line =~ 'buffer \f\{-}Xtest2'
141      let count2buf += 1
142    endif
143  endfor
144  call assert_equal(1, count1, 'Xtest1 count')
145  call assert_equal(2, count2, 'Xtest2 count')
146  call assert_equal(2, count2buf, 'Xtest2 buffer count')
147
148  close
149  bwipe!
150  call delete('Xtest_mks.out')
151endfunc
152
153
154
155" vim: shiftwidth=2 sts=2 expandtab
156