robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
071dcab68f
master
1" Test for :mksession, :mkview and :loadview in utf-8 encoding 2 3set encoding = utf-8 4scriptencoding utf-8 5 6source check.vim 7CheckFeature mksession 8 9func Test_mksession_utf8 () 10tabnew 11let wrap_save = & wrap 12set sessionoptions = bufferssplitbelow fileencoding = utf-8 13call setline ( 1 , [ 14 \'start:' , 15 \'no multibyte chAracter' , 16 \' one leaDing tab' , 17 \' four leadinG spaces' , 18 \'two consecutive tabs' , 19 \'two tabs in one line' , 20 \'one … multibyteCharacter' , 21 \'a “b” two multiByte characters' , 22 \'“c”1€ three mulTibyte characters' 23 \]) 24let tmpfile = tempname () 25exec 'w! ' . tmpfile 26/ ^start: 27set wrap 28vsplit 29norm ! j16| 30split 31norm ! j16| 32split 33norm ! j16| 34split 35norm ! j8| 36split 37norm ! j8| 38split 39norm ! j16| 40split 41norm ! j16| 42split 43norm ! j16| 44wincmd l 45 46set nowrap 47/ ^start: 48norm ! j16|3zl 49split 50norm ! j016|3zl 51split 52norm ! j016|3zl 53split 54norm ! j08|3zl 55split 56norm ! j08|3zl 57split 58norm ! j016|3zl 59split 60norm ! j016|3zl 61split 62norm ! j016|3zl 63split 64call wincol () 65mksession ! test_mks.out 66let li = filter ( readfile ( 'test_mks.out' ), 'v:val =~# "\\(^ *normal! 0\\|^ *exe ''normal!\\)"' ) 67let expected =<< trim [DATA] 68normal! 016| 69normal! 016| 70normal! 016| 71normal! 08| 72normal! 08| 73normal! 016| 74normal! 016| 75normal! 016| 76exe 'normal! ' . s:c . '|zs' . 16 . '|' 77normal! 016| 78exe 'normal! ' . s:c . '|zs' . 16 . '|' 79normal! 016| 80exe 'normal! ' . s:c . '|zs' . 16 . '|' 81normal! 016| 82exe 'normal! ' . s:c . '|zs' . 8 . '|' 83normal! 08| 84exe 'normal! ' . s:c . '|zs' . 8 . '|' 85normal! 08| 86exe 'normal! ' . s:c . '|zs' . 16 . '|' 87normal! 016| 88exe 'normal! ' . s:c . '|zs' . 16 . '|' 89normal! 016| 90exe 'normal! ' . s:c . '|zs' . 16 . '|' 91normal! 016| 92exe 'normal! ' . s:c . '|zs' . 16 . '|' 93normal! 016| 94[DATA] 95 96call assert_equal ( expected , li ) 97tabclose ! 98 99call delete ( 'test_mks.out' ) 100call delete ( tmpfile ) 101let & wrap = wrap_save 102set sessionoptions & splitbelow & fileencoding & 103endfunc 104 105func Test_session_multibyte_mappings () 106" some characters readily available on european keyboards, 107" as well as characters containing 0x80 or 0x9b bytes 108let entries = [ 109 \[ 'n' , 'ç' , 'ç' ], 110 \[ 'n' , 'º' , 'º' ], 111 \[ 'n' , '¡' , '¡' ], 112 \[ 'n' , '<M-ç>' , '<M-ç>' ], 113 \[ 'n' , '<M-º>' , '<M-º>' ], 114 \[ 'n' , '<M-¡>' , '<M-¡>' ], 115 \[ 'n' , '…' , 'ě' ], 116 \[ 'n' , 'ě' , '…' ], 117 \[ 'n' , '<M-…>' , '<M-ě>' ], 118 \[ 'n' , '<M-ě>' , '<M-…>' ], 119 \] 120for entry in entries 121exe entry [ 0 ] .. 'map ' .. entry [ 1 ] .. ' ' .. entry [ 2 ] 122endfor 123 124mkvimrc Xtestvimrc 125 126nmapclear 127 128for entry in entries 129call assert_equal ( '' , maparg ( entry [ 1 ], entry [ 0 ])) 130endfor 131 132source Xtestvimrc 133 134for entry in entries 135call assert_equal ( entry [ 2 ], maparg ( entry [ 1 ], entry [ 0 ])) 136endfor 137 138nmapclear 139 140call delete ( 'Xtestvimrc' ) 141endfunc 142 143" vim: shiftwidth=2 sts=2 expandtab