aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/testdir
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-02-28 20:12:50 +0800
committerGitHub <noreply@github.com>2023-02-28 20:12:50 +0800
commit3f381f4d04aa70829a865c82292b7d23fec29c52 (patch)
tree7198c028ad1b012b9b0710d697df0b3ea95fd76d /src/nvim/testdir
parent3b927762264c27aaeb31b83ba2e4924d5312ddcc (diff)
parent7aad75e293e3a01e292308ca2058e35083b83280 (diff)
downloadrneovim-3f381f4d04aa70829a865c82292b7d23fec29c52.tar.gz
rneovim-3f381f4d04aa70829a865c82292b7d23fec29c52.tar.bz2
rneovim-3f381f4d04aa70829a865c82292b7d23fec29c52.zip
Merge pull request #22453 from zeertzjq/vim-9.0.0795
vim-patch:9.0.{0795,0803,0810}: readblob() offset and size
Diffstat (limited to 'src/nvim/testdir')
-rw-r--r--src/nvim/testdir/test_blob.vim31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/nvim/testdir/test_blob.vim b/src/nvim/testdir/test_blob.vim
index b1859f9dfe..b01d9309fa 100644
--- a/src/nvim/testdir/test_blob.vim
+++ b/src/nvim/testdir/test_blob.vim
@@ -439,10 +439,41 @@ 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)
+
+ #" reading past end of file, empty result
+ VAR br1e = readblob('Xblob', 10000)
+ call assert_equal(0z, br1e)
+
+ #" reading too much, result is truncated
+ VAR blong = readblob('Xblob', -1000)
+ call assert_equal(b, blong)
+ LET blong = readblob('Xblob', -10, 8)
+ call assert_equal(b, blong)
+ LET blong = readblob('Xblob', 0, 10)
+ call assert_equal(b, blong)
+
call delete('Xblob')
END
call CheckLegacyAndVim9Success(lines)
+ if filereadable('/dev/random')
+ let b = readblob('/dev/random', 0, 10)
+ call assert_equal(10, len(b))
+ endif
+
+ 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