Skip to content

Commit

Permalink
fix(iox): 修复空读取测试用例及简化错误处理逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
justinwongcn committed Jan 24, 2025
1 parent 8d92ff4 commit 3422dbc
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions iox/multiple_bytes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestMultipleBytesReadWrite(t *testing.T) {
name: "空读取",
write: []byte{},
readSize: 1,
wantRead: []byte{},
wantRead: []byte{0},
wantN: 0,
wantErr: io.EOF,
},
Expand Down Expand Up @@ -73,13 +73,9 @@ func TestMultipleBytesReadWrite(t *testing.T) {

read := make([]byte, tc.readSize)
n, err = mb.Read(read)
if tc.wantErr != nil {
assert.Equal(t, tc.wantErr, err)
} else {
assert.Nil(t, err)
assert.Equal(t, tc.wantN, n, "读取的字节数应该等于期望的字节数")
assert.Equal(t, tc.wantRead, read, "读取的数据应该等于期望读取的数据")
}
assert.Equal(t, tc.wantErr, err)
assert.Equal(t, tc.wantN, n, "读取的字节数应该等于期望的字节数")
assert.Equal(t, tc.wantRead, read, "读取的数据应该等于期望读取的数据")
})
}
}
Expand Down

0 comments on commit 3422dbc

Please sign in to comment.