diff src/testdir/test_blob.vim @ 30922:ed6acfafa17e v9.0.0795

patch 9.0.0795: readblob() always reads the whole file Commit: https://github.com/vim/vim/commit/11df3aeee548b959ccd4b9a4d3c44651eab6b3ce Author: K.Takata <kentkt@csc.jp> Date: Wed Oct 19 14:02:40 2022 +0100 patch 9.0.0795: readblob() always reads the whole file Problem: readblob() always reads the whole file. Solution: Add arguments to read part of the file. (Ken Takata, closes #11402)
author Bram Moolenaar <Bram@vim.org>
date Wed, 19 Oct 2022 15:15:05 +0200
parents 029c59bf78f1
children 84f6f91ca02a
line wrap: on
line diff
--- a/src/testdir/test_blob.vim
+++ b/src/testdir/test_blob.vim
@@ -488,10 +488,29 @@ func Test_blob_read_write()
       call writefile(b, 'Xblob')
       VAR br = readfile('Xblob', 'B')
       call assert_equal(b, br)
+      VAR br2 = readblob('Xblob')
+      call assert_equal(b, br2)
+      VAR br3 = readblob('Xblob', 1)
+      call assert_equal(b[1 :], br3)
+      VAR br4 = readblob('Xblob', 1, 2)
+      call assert_equal(b[1 : 2], br4)
+      VAR br5 = readblob('Xblob', -3)
+      call assert_equal(b[-3 :], br5)
+      VAR br6 = readblob('Xblob', -3, 2)
+      call assert_equal(b[-3 : -2], br6)
+      
+      VAR br1e = readblob('Xblob', 10000)
+      call assert_equal(0z, br1e)
+      VAR br2e = readblob('Xblob', -10000)
+      call assert_equal(0z, br2e)
+
       call delete('Xblob')
   END
   call v9.CheckLegacyAndVim9Success(lines)
 
+  call assert_fails("call readblob('notexist')", 'E484:')
+  " TODO: How do we test for the E485 error?
+
   " This was crashing when calling readfile() with a directory.
   call assert_fails("call readfile('.', 'B')", 'E17: "." is a directory')
 endfunc