patch 9.1.0893: No test that undofile format does not regress

Problem:  No test that undofile format does not regress
Solution: include a sample undofile to make sure we are always able to
          read it

This is so, that we don't unintentionally change the undofile format and
make sure we can load an undo file that has been created by an older
Vim.

closes: #16127

Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Christian Brabandt
2024-11-28 21:59:33 +01:00
parent 3d670bb191
commit 14382c8bc9
5 changed files with 35 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

View File

@ -704,6 +704,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
893,
/**/
892,
/**/