robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
af23d17388
master
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. 10func Test_File_Size () 11if ! executable ( 'cksum' ) 12return 13endif 14 15new 16set fileformat = unixundolevels = -1 17for i in range ( 1 , 2000000 , 100 ) 18call append ( i , range ( i , i + 99 )) 19endfor 20 211 delete 22w ! Xtest 23let res = systemlist ( 'cksum Xtest' )[ 0 ] 24let res = substitute ( res , "\r" , "" , "" ) 25call assert_equal ( '3678979763 14888896 Xtest' , res ) 26 27enew ! 28call delete ( 'Xtest' ) 29set fileformat & undolevels & 30endfunc 31 32" Test for writing and reading a file of over 100 Kbyte 33func Test_File_Read_Write () 34enew ! 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" 42call append ( 0 , "This is the start" ) 43call append ( 1 , repeat ([ "This is the leader" ], 3001 )) 44call append ( 3002 , "This is the middle" ) 45call append ( 3003 , repeat ([ "This is the trailer" ], 3001 )) 46call append ( 6004 , "This is the end" ) 47 48write ! Xtest 49enew ! 50edit ! Xtest 51 52call assert_equal ( "This is the start" , getline ( 1 )) 53call assert_equal ( "This is the middle" , getline ( 3003 )) 54call assert_equal ( "This is the end" , getline ( 6005 )) 55 56enew ! 57call delete ( "Xtest" ) 58endfunc