1" Inserts 2 million lines with consecutive integers starting from 1
2" (essentially, the output of GNU's seq 1 2000000), writes them to Xtest
3" and writes its cksum to test.out.
4"
5" We need 2 million lines to trigger a call to mf_hash_grow().  If it would mess
6" up the lines the checksum would differ.
7"
8" cksum is part of POSIX and so should be available on most Unixes.
9" If it isn't available then the test will be skipped.
10
11source check.vim
12
13func Test_File_Size()
14  CheckExecutable cksum
15
16  new
17  set fileformat=unix undolevels=-1
18  for i in range(1, 2000000, 100)
19    call append(i, range(i, i + 99))
20  endfor
21
22  1delete
23  w! Xtest
24  let res = systemlist('cksum Xtest')[0]
25  let res = substitute(res, "\r", "", "")
26  call assert_equal('3678979763 14888896 Xtest', res)
27
28  enew!
29  call delete('Xtest')
30  set fileformat& undolevels&
31endfunc
32
33" Test for writing and reading a file of over 100 Kbyte
34func Test_File_Read_Write()
35  enew!
36
37  " Create a file with the following contents
38  " 1 line: "This is the start"
39  " 3001 lines: "This is the leader"
40  " 1 line: "This is the middle"
41  " 3001 lines: "This is the trailer"
42  " 1 line: "This is the end"
43  call append(0, "This is the start")
44  call append(1, repeat(["This is the leader"], 3001))
45  call append(3002, "This is the middle")
46  call append(3003, repeat(["This is the trailer"], 3001))
47  call append(6004, "This is the end")
48
49  write! Xtest
50  enew!
51  edit! Xtest
52
53  call assert_equal("This is the start", getline(1))
54  call assert_equal("This is the middle", getline(3003))
55  call assert_equal("This is the end", getline(6005))
56
57  enew!
58  call delete("Xtest")
59endfunc
60
61" vim: shiftwidth=2 sts=2 expandtab
62