blob: 3e78a7b23c0b38fd95a20a652cfd9912c4deb871 [file] [log] [blame]
Bram Moolenaar4a137b42017-08-04 22:37:11 +02001" 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.
10func Test_File_Size()
11 if !executable('cksum')
12 return
13 endif
Bram Moolenaar4a137b42017-08-04 22:37:11 +020014
15 new
Bram Moolenaar67418d92017-10-15 22:07:39 +020016 set fileformat=unix undolevels=-1
Bram Moolenaar4a137b42017-08-04 22:37:11 +020017 for i in range(1, 2000000, 100)
18 call append(i, range(i, i + 99))
19 endfor
20
21 1delete
22 w! Xtest
Bram Moolenaar07c043a2017-08-04 22:56:39 +020023 let res = systemlist('cksum Xtest')[0]
24 let res = substitute(res, "\r", "", "")
25 call assert_equal('3678979763 14888896 Xtest', res)
Bram Moolenaar4a137b42017-08-04 22:37:11 +020026
27 enew!
28 call delete('Xtest')
Bram Moolenaar67418d92017-10-15 22:07:39 +020029 set fileformat& undolevels&
Bram Moolenaar4a137b42017-08-04 22:37:11 +020030endfunc
Bram Moolenaardb510072017-09-28 21:52:17 +020031
32" Test for writing and reading a file of over 100 Kbyte
33func Test_File_Read_Write()
34 enew!
35
36 " Create a file with the following contents
37 " 1 line: "This is the start"
38 " 3001 lines: "This is the leader"
39 " 1 line: "This is the middle"
40 " 3001 lines: "This is the trailer"
41 " 1 line: "This is the end"
42 call append(0, "This is the start")
43 call append(1, repeat(["This is the leader"], 3001))
44 call append(3002, "This is the middle")
45 call append(3003, repeat(["This is the trailer"], 3001))
46 call append(6004, "This is the end")
47
48 write! Xtest
49 enew!
50 edit! Xtest
51
52 call assert_equal("This is the start", getline(1))
53 call assert_equal("This is the middle", getline(3003))
54 call assert_equal("This is the end", getline(6005))
55
56 enew!
57 call delete("Xtest")
58endfunc