fix for out of range reads

This commit is contained in:
Chris Lu
2020-08-17 22:46:32 -07:00
parent 56fbd2c211
commit 1b68ba953b
2 changed files with 11 additions and 10 deletions

View File

@@ -77,6 +77,11 @@ func testReadAt(t *testing.T, readerAt *ChunkReadAt, offset int64, size int, exp
data := make([]byte, size)
n, err := readerAt.ReadAt(data, offset)
for _, d := range data {
fmt.Printf("%x", d)
}
fmt.Println()
if expected != n {
t.Errorf("unexpected read size: %d, expect: %d", n, expected)
}
@@ -84,10 +89,6 @@ func testReadAt(t *testing.T, readerAt *ChunkReadAt, offset int64, size int, exp
t.Errorf("unexpected read error: %v, expect: %v", err, expectedErr)
}
for _, d := range data {
fmt.Printf("%x", d)
}
fmt.Println()
}
func TestReaderAt0(t *testing.T) {
@@ -119,4 +120,6 @@ func TestReaderAt0(t *testing.T) {
testReadAt(t, readerAt, 3, 16, 7, io.EOF)
testReadAt(t, readerAt, 3, 5, 5, nil)
testReadAt(t, readerAt, 11, 5, 0, io.EOF)
}