view src/testdir/test_file_size.vim @ 33525:09dac7f0916b v9.0.2011

patch 9.0.2011: INI files not detected Commit: https://github.com/vim/vim/commit/4a82bdfaa8022402b1ca0f0000c94c47a13f1014 Author: Martin Tournoij <martin@arp242.net> Date: Wed Oct 11 21:20:06 2023 +0200 patch 9.0.2011: INI files not detected Problem: INI files not detected Solution: detect uppercase .INI as dosini files It previo~1 only worked for lower-case .ini files, but upperc~1 .INI is also somewhat common on account of DOS' old 8.3 upperc~2 only filena~1. closes: #13316 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Martin Tournoij <martin@arp242.net>
author Christian Brabandt <cb@256bit.org>
date Wed, 11 Oct 2023 21:30:07 +0200
parents 08940efa6b4e
children
line wrap: on
line source

" Inserts 2 million lines with consecutive integers starting from 1
" (essentially, the output of GNU's seq 1 2000000), writes them to Xtest
" and writes its cksum to test.out.
"
" We need 2 million lines to trigger a call to mf_hash_grow().  If it would mess
" up the lines the checksum would differ.
"
" cksum is part of POSIX and so should be available on most Unixes.
" If it isn't available then the test will be skipped.

source check.vim

func Test_File_Size()
  CheckExecutable cksum

  new
  set fileformat=unix undolevels=-1
  for i in range(1, 2000000, 100)
    call append(i, range(i, i + 99))
  endfor

  1delete
  w! Xtest
  let res = systemlist('cksum Xtest')[0]
  let res = substitute(res, "\r", "", "")
  call assert_equal('3678979763 14888896 Xtest', res)

  enew!
  call delete('Xtest')
  set fileformat& undolevels&
endfunc

" Test for writing and reading a file of over 100 Kbyte
func Test_File_Read_Write()
  enew!

  " Create a file with the following contents
  " 1 line: "This is the start"
  " 3001 lines: "This is the leader"
  " 1 line: "This is the middle"
  " 3001 lines: "This is the trailer"
  " 1 line: "This is the end"
  call append(0, "This is the start")
  call append(1, repeat(["This is the leader"], 3001))
  call append(3002, "This is the middle")
  call append(3003, repeat(["This is the trailer"], 3001))
  call append(6004, "This is the end")

  write! Xtest
  enew!
  edit! Xtest

  call assert_equal("This is the start", getline(1))
  call assert_equal("This is the middle", getline(3003))
  call assert_equal("This is the end", getline(6005))

  enew!
  call delete("Xtest")
endfunc

" vim: shiftwidth=2 sts=2 expandtab