Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
Signed-off-by: Xuanwo <[email protected]>
  • Loading branch information
Xuanwo committed Mar 11, 2024
1 parent 30a617b commit 4fb29a0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
24 changes: 12 additions & 12 deletions core/src/raw/oio/read/buffer_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,29 +450,29 @@ mod tests {
let mut r = Reader::new(r);

// The underlying reader buffers the b"Hello, Wor".
let bs = r.read(5).await?;
assert_eq!(bs.len(), 5);
assert_eq!(bs.as_ref(), b"Hello");
let buf = r.read(5).await?;
assert_eq!(buf.len(), 5);
assert_eq!(buf.as_ref(), b"Hello");

let pos = r.seek(SeekFrom::Start(7)).await?;
assert_eq!(pos, 7);
let bs = r.read(5).await?;
assert_eq!(&bs, &bs[7..10]);
assert_eq!(bs.len(), 3);
let buf = r.read(5).await?;
assert_eq!(&buf, &bs[7..10]);
assert_eq!(buf.len(), 3);

// Should perform a relative seek.
let pos = r.seek(SeekFrom::Start(0)).await?;
assert_eq!(pos, 0);
let bs = r.read(9).await?;
assert_eq!(&bs, &bs[0..9]);
assert_eq!(bs.len(), 9);
let buf = r.read(9).await?;
assert_eq!(&buf, &bs[0..9]);
assert_eq!(buf.len(), 9);

// Should perform a non-relative seek.
let pos = r.seek(SeekFrom::Start(11)).await?;
assert_eq!(pos, 11);
let bs = r.read(9).await?;
assert_eq!(&bs, &bs[11..13]);
assert_eq!(bs.len(), 2);
let buf = r.read(9).await?;
assert_eq!(&buf, &bs[11..13]);
assert_eq!(buf.len(), 2);

Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/types/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ impl Reader {

match self.read(read_buf.initialize_unfilled().len()).await {
Ok(bs) if bs.is_empty() => {
return Ok(bs.len() - start_len);
return Ok(buf.len() - start_len);
}
Ok(bs) => {
read_buf.initialize_unfilled()[..bs.len()].copy_from_slice(&bs);
Expand Down

0 comments on commit 4fb29a0

Please sign in to comment.