Skip to content

Commit 3422dbc

Browse files
committed
fix(iox): 修复空读取测试用例及简化错误处理逻辑
1 parent 8d92ff4 commit 3422dbc

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

iox/multiple_bytes_test.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func TestMultipleBytesReadWrite(t *testing.T) {
3434
name: "空读取",
3535
write: []byte{},
3636
readSize: 1,
37-
wantRead: []byte{},
37+
wantRead: []byte{0},
3838
wantN: 0,
3939
wantErr: io.EOF,
4040
},
@@ -73,13 +73,9 @@ func TestMultipleBytesReadWrite(t *testing.T) {
7373

7474
read := make([]byte, tc.readSize)
7575
n, err = mb.Read(read)
76-
if tc.wantErr != nil {
77-
assert.Equal(t, tc.wantErr, err)
78-
} else {
79-
assert.Nil(t, err)
80-
assert.Equal(t, tc.wantN, n, "读取的字节数应该等于期望的字节数")
81-
assert.Equal(t, tc.wantRead, read, "读取的数据应该等于期望读取的数据")
82-
}
76+
assert.Equal(t, tc.wantErr, err)
77+
assert.Equal(t, tc.wantN, n, "读取的字节数应该等于期望的字节数")
78+
assert.Equal(t, tc.wantRead, read, "读取的数据应该等于期望读取的数据")
8379
})
8480
}
8581
}

0 commit comments

Comments
 (0)