fix dropping front block in BlockBuf

This commit is contained in:
Nikolay Kim
2016-09-13 15:30:44 -07:00
parent f693e038d9
commit 1f188b5628
3 changed files with 24 additions and 1 deletions
+1 -1
View File
@@ -175,7 +175,7 @@ impl BlockBuf {
block.drop(segment_n);
!MutBuf::has_remaining(block)
block.len() == 0
};
if pop {
+1
View File
@@ -6,6 +6,7 @@ extern crate byteorder;
// == Buf
mod test_append;
mod test_block;
mod test_buf;
mod test_buf_fill;
mod test_byte_buf;
+22
View File
@@ -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);
}