blob: e97f4a46953fabe6ae0f9a987d12d75e8fb59f9a [file] [log] [blame]
Bram Moolenaarf85dae32011-06-13 21:21:22 +02001Inserts 10000 lines with text to fill the swap file with two levels of pointer
2blocks. Then recovers from the swap file and checks all text is restored.
3
4We need about 10000 lines of 100 characters to get two levels of pointer
5blocks.
6
7STARTTEST
8:so small.vim
Bram Moolenaarc3c766e2017-03-08 22:55:19 +01009:set nocp fileformat=unix undolevels=-1 viminfo+=nviminfo belloff=all
Bram Moolenaarf85dae32011-06-13 21:21:22 +020010:e! Xtest
11ggdG
12:let text = "\tabcdefghijklmnoparstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnoparstuvwxyz0123456789"
13:let i = 1
14:let linecount = 10000
15:while i <= linecount | call append(i - 1, i . text) | let i += 1 | endwhile
16:preserve
17:" get the name of the swap file
18:redir => swapname
19:swapname
20:redir END
21:let swapname = substitute(swapname, '[[:blank:][:cntrl:]]*\(.\{-}\)[[:blank:][:cntrl:]]*$', '\1', '')
22:" make a copy of the swap file in Xswap
23:set bin
24:exe 'sp ' . swapname
25:w! Xswap
26:echo swapname
27:set nobin
28:new
29:only!
30:bwipe! Xtest
31:call rename('Xswap', swapname)
32:recover Xtest
33:call delete(swapname)
34:new
35:call append(0, 'recovery start')
36:wincmd w
37:let linedollar = line('$')
38:if linedollar < linecount | exe 'wincmd w' | call append(line('$'), "expected " . linecount . " lines but found only " . linedollar) | exe 'wincmd w' | let linecount = linedollar | endif
39:let i = 1
40:while i <= linecount | if getline(i) != i . text | exe 'wincmd w' | call append(line('$'), i . ' differs') | exe 'wincmd w' | endif | let i += 1 | endwhile
41:q!
42:call append(line('$'), 'recovery end')
43:w! test.out
44:qa!
45ENDTEST
46