mirror of
https://github.com/tokio-rs/bytes.git
synced 2026-08-26 00:00:20 +02:00
fix dropping front block in BlockBuf
This commit is contained in:
+1
-1
@@ -175,7 +175,7 @@ impl BlockBuf {
|
|||||||
|
|
||||||
block.drop(segment_n);
|
block.drop(segment_n);
|
||||||
|
|
||||||
!MutBuf::has_remaining(block)
|
block.len() == 0
|
||||||
};
|
};
|
||||||
|
|
||||||
if pop {
|
if pop {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ extern crate byteorder;
|
|||||||
|
|
||||||
// == Buf
|
// == Buf
|
||||||
mod test_append;
|
mod test_append;
|
||||||
|
mod test_block;
|
||||||
mod test_buf;
|
mod test_buf;
|
||||||
mod test_buf_fill;
|
mod test_buf_fill;
|
||||||
mod test_byte_buf;
|
mod test_byte_buf;
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
use bytes::{MutBuf, BlockBuf};
|
||||||
|
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
pub fn test_block_drop() {
|
||||||
|
let mut buf = BlockBuf::new(2, 4);
|
||||||
|
|
||||||
|
assert_eq!(buf.remaining(), 8);
|
||||||
|
|
||||||
|
buf.write_slice(b"12345");
|
||||||
|
buf.write_slice(b"678");
|
||||||
|
assert_eq!(buf.remaining(), 0);
|
||||||
|
assert_eq!(buf.len(), 8);
|
||||||
|
|
||||||
|
buf.drop(1);
|
||||||
|
assert_eq!(buf.len(), 7);
|
||||||
|
assert_eq!(buf.is_compact(), false);
|
||||||
|
|
||||||
|
buf.drop(4);
|
||||||
|
assert_eq!(buf.len(), 3);
|
||||||
|
assert_eq!(buf.is_compact(), true);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user