This commit is contained in:
Dominik Werder
2021-04-26 12:28:04 +02:00
parent 01f5244c21
commit 98d3fe8321

View File

@@ -132,8 +132,19 @@ async fn get_cached_0_inner() -> Result<(), Error> {
#[test]
fn bufs() {
use bytes::{Buf, BufMut};
let mut buf = BytesMut::with_capacity(1024);
assert!(buf.as_mut().len() == 0);
buf.put_u32_le(123);
assert!(buf.as_mut().len() == 4);
let mut b2 = buf.split_to(4);
assert!(b2.capacity() == 4);
b2.advance(2);
assert!(b2.capacity() == 2);
b2.advance(2);
assert!(b2.capacity() == 0);
assert!(buf.capacity() == 1020);
assert!(buf.remaining() == 0);
assert!(buf.remaining_mut() >= 1020);
assert!(buf.capacity() == 1020);
}