1
0
Fork 0
mirror of https://github.com/vim/vim synced 2025-03-26 11:45:22 +01:00

Add a test for loading an example undofile

This is so, that we don't unintentionally change the undofile format and
make sure we can reload an older undo file.
This commit is contained in:
Christian Brabandt 2024-11-27 22:10:52 +01:00
parent 0a850673e3
commit dcaa46d343
No known key found for this signature in database
GPG key ID: F3F92DA383FDDE09
4 changed files with 33 additions and 0 deletions

View file

@ -224,6 +224,7 @@ SRC_ALL = \
src/testdir/samples/*.vim \
src/testdir/samples/test000 \
src/testdir/samples/test.zip \
src/testdir/samples/test_undo.txt.undo \
src/testdir/samples/testa.zip \
src/testdir/color_ramp.vim \
src/testdir/silent.wav \

View file

@ -0,0 +1,3 @@
one
two
three

Binary file not shown.

View file

@ -884,4 +884,33 @@ func Test_undo_range_normal()
bwipe!
endfunc
func Test_load_existing_undofile()
CheckFeature persistent_undo
sp samples/test_undo.txt
let mess=execute(':verbose rundo samples/test_undo.txt.undo')
call assert_match('Finished reading undo file', mess)
call assert_equal(['one', 'two', 'three'], getline(1, '$'))
norm! u
call assert_equal(['one', 'two'], getline(1, '$'))
norm! u
call assert_equal(['one'], getline(1, '$'))
norm! u
call assert_equal([''], getline(1, '$'))
let mess = execute(':norm! u')
call assert_equal([''], getline(1, '$'))
call assert_match('Already at oldest change', mess)
exe ":norm! \<c-r>"
call assert_equal(['one'], getline(1, '$'))
exe ":norm! \<c-r>"
call assert_equal(['one', 'two'], getline(1, '$'))
exe ":norm! \<c-r>"
call assert_equal(['one', 'two', 'three'], getline(1, '$'))
let mess = execute(":norm! \<c-r>")
call assert_equal(['one', 'two', 'three'], getline(1, '$'))
call assert_match('Already at newest change', mess)
bw!
endfunc
" vim: shiftwidth=2 sts=2 expandtab