diff options
author | K.Takata <kentkt@csc.jp> | 2022-10-19 14:02:40 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-10-19 14:02:40 +0100 |
commit | 11df3aeee548b959ccd4b9a4d3c44651eab6b3ce (patch) | |
tree | 13cdeec4447038acdffe1084b3b5f91dabae038b /src/testdir/test_blob.vim | |
parent | 9f62ea01a08e69f44050f59469a0e64beddefac0 (diff) |
patch 9.0.0795: readblob() always reads the whole filev9.0.0795
Problem: readblob() always reads the whole file.
Solution: Add arguments to read part of the file. (Ken Takata,
closes #11402)
Diffstat (limited to 'src/testdir/test_blob.vim')
-rw-r--r-- | src/testdir/test_blob.vim | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/testdir/test_blob.vim b/src/testdir/test_blob.vim index ce8c3d09f7..a54cede9e8 100644 --- 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 |