diff options
Diffstat (limited to 'tests/test_bytes.rs')
-rw-r--r-- | tests/test_bytes.rs | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/tests/test_bytes.rs b/tests/test_bytes.rs index 106fa6f..6b106a6 100644 --- a/tests/test_bytes.rs +++ b/tests/test_bytes.rs @@ -1,4 +1,4 @@ -#![deny(warnings, rust_2018_idioms)] +#![warn(rust_2018_idioms)] use bytes::{Buf, BufMut, Bytes, BytesMut}; @@ -930,6 +930,22 @@ fn bytes_buf_mut_advance() { } #[test] +fn bytes_buf_mut_reuse_when_fully_consumed() { + use bytes::{Buf, BytesMut}; + let mut buf = BytesMut::new(); + buf.reserve(8192); + buf.extend_from_slice(&[0u8; 100][..]); + + let p = &buf[0] as *const u8; + buf.advance(100); + + buf.reserve(8192); + buf.extend_from_slice(b" "); + + assert_eq!(&buf[0] as *const u8, p); +} + +#[test] #[should_panic] fn bytes_reserve_overflow() { let mut bytes = BytesMut::with_capacity(1024); |