| Bram Moolenaar | 4a137b4 | 2017-08-04 22:37:11 +0200 | [diff] [blame] | 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 | func Test_File_Size() |
| 11 | if !executable('cksum') |
| 12 | return |
| 13 | endif |
| Bram Moolenaar | 4a137b4 | 2017-08-04 22:37:11 +0200 | [diff] [blame] | 14 | |
| 15 | new |
| Bram Moolenaar | 67418d9 | 2017-10-15 22:07:39 +0200 | [diff] [blame] | 16 | set fileformat=unix undolevels=-1 |
| Bram Moolenaar | 4a137b4 | 2017-08-04 22:37:11 +0200 | [diff] [blame] | 17 | for i in range(1, 2000000, 100) |
| 18 | call append(i, range(i, i + 99)) |
| 19 | endfor |
| 20 | |
| 21 | 1delete |
| 22 | w! Xtest |
| Bram Moolenaar | 07c043a | 2017-08-04 22:56:39 +0200 | [diff] [blame] | 23 | let res = systemlist('cksum Xtest')[0] |
| 24 | let res = substitute(res, "\r", "", "") |
| 25 | call assert_equal('3678979763 14888896 Xtest', res) |
| Bram Moolenaar | 4a137b4 | 2017-08-04 22:37:11 +0200 | [diff] [blame] | 26 | |
| 27 | enew! |
| 28 | call delete('Xtest') |
| Bram Moolenaar | 67418d9 | 2017-10-15 22:07:39 +0200 | [diff] [blame] | 29 | set fileformat& undolevels& |
| Bram Moolenaar | 4a137b4 | 2017-08-04 22:37:11 +0200 | [diff] [blame] | 30 | endfunc |
| Bram Moolenaar | db51007 | 2017-09-28 21:52:17 +0200 | [diff] [blame] | 31 | |
| 32 | " Test for writing and reading a file of over 100 Kbyte |
| 33 | func 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") |
| 58 | endfunc |