1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

os: add fn read_bytes_into with buffer argument (#6365)

This commit is contained in:
Nick Treleaven
2020-09-14 14:34:34 +01:00
committed by GitHub
parent 5c8e1c7eeb
commit b552c29bef
2 changed files with 36 additions and 7 deletions

View File

@@ -142,11 +142,19 @@ fn test_write_and_read_bytes() {
// read_bytes_at with second parameter zeroed (size, 0).
rbytes := file_read.read_bytes(5)
file_read.close()
// eprintln('rbytes: $rbytes')
// eprintln('payload: $payload')
assert rbytes == payload
// check that trying to read data from EOF doesn't error and returns 0
mut a := []byte{len: 5}
nread := file_read.read_bytes_into(5, a) or {
eprintln(err)
int(-1)
}
assert nread == 0
file_read.close()
// We finally delete the test file.
os.rm(file_name)
}