rbd/tests: add special "read 0 bytes" case

Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
Niels de Vos 2020-01-22 12:40:38 +01:00
parent a0fcd9202c
commit f170634d82
1 changed files with 7 additions and 1 deletions

View File

@ -557,8 +557,14 @@ func TestIOReaderWriter(t *testing.T) {
_, err = img.Seek(0, SeekSet)
assert.NoError(t, err)
// reading 0 bytes should succeed
nil_bytes := make([]byte, 0)
n_out, err := img.Read(nil_bytes)
assert.Equal(t, n_out, 0)
assert.NoError(t, err)
bytes_out := make([]byte, len(bytes_in))
n_out, err := img.Read(bytes_out)
n_out, err = img.Read(bytes_out)
assert.Equal(t, n_out, len(bytes_in))
assert.Equal(t, bytes_in, bytes_out)