Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(test): The new test case PagebufferReader5 introduced an error. #1936

Merged
merged 6 commits into from
May 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions y/y_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,21 +262,16 @@ func TestPagebufferReader4(t *testing.T) {
// Test when reading into 0 length readBuffer
func TestPagebufferReader5(t *testing.T) {
b := NewPageBuffer(32)
readerWhenEmptyPageBuffer := b.NewReaderAt(0)

readBuffer := []byte{} // Intentionally empty readBuffer.
n, err := readerWhenEmptyPageBuffer.Read(readBuffer)
require.NoError(t, err, "reading into empty buffer should return no error")
require.Equal(t, 0, n, "read into empty buffer should return 0 bytes")

var wb [20]byte
rand.Read(wb[:])
n, err = b.Write(wb[:])
n, err := b.Write(wb[:])
require.Equal(t, n, len(wb), "length of buffer and length written should be equal")
require.NoError(t, err, "unable to write bytes to buffer")

readerWhenNonEmptyPageBuffer := b.NewReaderAt(0)
n, err = readerWhenNonEmptyPageBuffer.Read(readBuffer)
reader := b.NewReaderAt(0)

readBuffer := []byte{} // Intentionally empty readBuffer.
n, err = reader.Read(readBuffer)
require.NoError(t, err, "reading into empty buffer should return no error")
require.Equal(t, 0, n, "read into empty buffer should return 0 bytes")
}
Expand Down
Loading