Skip to content

Commit 64e2db6

Browse files
committed
patch 8.2.1651: spellfile code not completely tested
Problem: Spellfile code not completely tested. Solution: Add a few more test cases. (Yegappan Lakshmanan, closes #6918)
1 parent c1ec042 commit 64e2db6

2 files changed

Lines changed: 68 additions & 0 deletions

File tree

src/testdir/test_spellfile.vim

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,11 @@ func Spellfile_Test(content, emsg)
179179
" Add the spell file header and version (VIMspell2)
180180
let v = 0z56494D7370656C6C32 + a:content
181181
call writefile(v, splfile, 'b')
182+
183+
" 'encoding' is set before each test to clear the previously loaded suggest
184+
" file from memory.
185+
set encoding=utf-8
186+
182187
set runtimepath=./Xtest
183188
set spelllang=Xtest
184189
if a:emsg != ''
@@ -299,6 +304,9 @@ func Test_spellfile_format_error()
299304
" SN_SOFO: missing sofoto
300305
call Spellfile_Test(0z0600000000050001610000, 'E759:')
301306

307+
" SN_SOFO: empty sofofrom and sofoto
308+
call Spellfile_Test(0z06000000000400000000FF000000000000000000000000, '')
309+
302310
" SN_COMPOUND: compmax is less than 2
303311
call Spellfile_Test(0z08000000000101, 'E759:')
304312

@@ -308,6 +316,12 @@ func Test_spellfile_format_error()
308316
" SN_COMPOUND: missing compoptions
309317
call Spellfile_Test(0z080000000005040101, 'E758:')
310318

319+
" SN_COMPOUND: missing comppattern
320+
call Spellfile_Test(0z08000000000704010100000001, 'E758:')
321+
322+
" SN_COMPOUND: incorrect comppatlen
323+
call Spellfile_Test(0z080000000007040101000000020165, 'E758:')
324+
311325
" SN_INFO: missing info
312326
call Spellfile_Test(0z0F0000000005040101, '')
313327

@@ -317,6 +331,12 @@ func Test_spellfile_format_error()
317331
" SN_MAP: missing midword
318332
call Spellfile_Test(0z0700000000040102, '')
319333

334+
" SN_MAP: empty map string
335+
call Spellfile_Test(0z070000000000FF000000000000000000000000, '')
336+
337+
" SN_MAP: duplicate multibyte character
338+
call Spellfile_Test(0z070000000004DC81DC81, 'E783:')
339+
320340
" SN_SYLLABLE: missing SYLLABLE item
321341
call Spellfile_Test(0z0900000000040102, '')
322342

@@ -333,12 +353,21 @@ func Test_spellfile_format_error()
333353
" LWORDTREE: missing tree node value
334354
call Spellfile_Test(0zFF0000000402, 'E758:')
335355

356+
" LWORDTREE: incorrect sibling node count
357+
call Spellfile_Test(0zFF00000001040000000000000000, 'E759:')
358+
336359
" KWORDTREE: missing tree node
337360
call Spellfile_Test(0zFF0000000000000004, 'E758:')
338361

339362
" PREFIXTREE: missing tree node
340363
call Spellfile_Test(0zFF000000000000000000000004, 'E758:')
341364

365+
" PREFIXTREE: incorrect prefcondnr
366+
call Spellfile_Test(0zFF000000000000000000000002010200000020, 'E759:')
367+
368+
" PREFIXTREE: invalid nodeidx
369+
call Spellfile_Test(0zFF00000000000000000000000201010000, 'E759:')
370+
342371
let &rtp = save_rtp
343372
call delete('Xtest', 'rf')
344373
endfunc
@@ -506,6 +535,14 @@ func Test_wordlist_dic()
506535
let output = execute('mkspell! -ascii Xwordlist.spl Xwordlist.dic')
507536
call assert_match('Ignored 1 words with non-ASCII characters', output)
508537

538+
" keep case of a word
539+
let lines =<< trim [END]
540+
example/=
541+
[END]
542+
call writefile(lines, 'Xwordlist.dic')
543+
let output = execute('mkspell! Xwordlist.spl Xwordlist.dic')
544+
call assert_match('Compressed keep-case:', output)
545+
509546
call delete('Xwordlist.spl')
510547
call delete('Xwordlist.dic')
511548
endfunc
@@ -706,6 +743,35 @@ func Test_aff_file_format_error()
706743
let output = execute('mkspell! Xtest.spl Xtest')
707744
call assert_match('Illegal flag in Xtest.aff line 2: L', output)
708745

746+
" missing character in UPP entry. The character table is used only in a
747+
" non-utf8 encoding
748+
call writefile(['FOL abc', 'LOW abc', 'UPP A'], 'Xtest.aff')
749+
let save_encoding = &encoding
750+
set encoding=cp949
751+
call assert_fails('mkspell! Xtest.spl Xtest', 'E761:')
752+
let &encoding = save_encoding
753+
754+
" character range doesn't match between FOL and LOW entries
755+
call writefile(["FOL \u0102bc", 'LOW abc', 'UPP ABC'], 'Xtest.aff')
756+
let save_encoding = &encoding
757+
set encoding=cp949
758+
call assert_fails('mkspell! Xtest.spl Xtest', 'E762:')
759+
let &encoding = save_encoding
760+
761+
" character range doesn't match between FOL and UPP entries
762+
call writefile(["FOL \u0102bc", "LOW \u0102bc", 'UPP ABC'], 'Xtest.aff')
763+
let save_encoding = &encoding
764+
set encoding=cp949
765+
call assert_fails('mkspell! Xtest.spl Xtest', 'E762:')
766+
let &encoding = save_encoding
767+
768+
" additional characters in LOW and UPP entries
769+
call writefile(["FOL ab", "LOW abc", 'UPP ABC'], 'Xtest.aff')
770+
let save_encoding = &encoding
771+
set encoding=cp949
772+
call assert_fails('mkspell! Xtest.spl Xtest', 'E761:')
773+
let &encoding = save_encoding
774+
709775
" duplicate word in the .dic file
710776
call writefile(['2', 'good', 'good', 'good'], 'Xtest.dic')
711777
call writefile(['NAME vim'], 'Xtest.aff')

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
1651,
753755
/**/
754756
1650,
755757
/**/

0 commit comments

Comments
 (0)