mirror of
https://github.com/tokio-rs/bytes.git
synced 2026-08-14 00:00:13 +02:00
Create ByteBuf with MutByteBuf::with_capacity
This commit is contained in:
@@ -4,7 +4,7 @@ use std::io;
|
||||
#[test]
|
||||
pub fn test_readijng_buf_from_reader() {
|
||||
let mut reader = chunks(vec![b"foo", b"bar", b"baz"]);
|
||||
let mut buf = ByteBuf::mut_with_capacity(1024);
|
||||
let mut buf = MutByteBuf::with_capacity(1024);
|
||||
|
||||
assert_eq!(3, reader.read_buf(&mut buf).unwrap());
|
||||
assert_eq!(Bytes::from(&b"foo"), Bytes::from(buf.flip()));
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
use bytes::{Buf, MutBuf};
|
||||
use bytes::ByteBuf;
|
||||
use bytes::MutByteBuf;
|
||||
|
||||
#[test]
|
||||
pub fn test_initial_buf_empty() {
|
||||
let buf = ByteBuf::mut_with_capacity(100);
|
||||
let buf = MutByteBuf::with_capacity(100);
|
||||
|
||||
assert!(buf.capacity() == 128);
|
||||
assert!(buf.remaining() == 128);
|
||||
@@ -19,7 +19,7 @@ pub fn test_initial_buf_empty() {
|
||||
|
||||
#[test]
|
||||
pub fn test_byte_buf_bytes() {
|
||||
let mut buf = ByteBuf::mut_with_capacity(32);
|
||||
let mut buf = MutByteBuf::with_capacity(32);
|
||||
buf.copy_from(&b"hello "[..]);
|
||||
assert_eq!(&b"hello "[..], buf.bytes());
|
||||
|
||||
@@ -31,7 +31,7 @@ pub fn test_byte_buf_bytes() {
|
||||
|
||||
#[test]
|
||||
pub fn test_byte_buf_read_write() {
|
||||
let mut buf = ByteBuf::mut_with_capacity(32);
|
||||
let mut buf = MutByteBuf::with_capacity(32);
|
||||
|
||||
buf.copy_from(&b"hello world"[..]);
|
||||
assert_eq!(21, buf.remaining());
|
||||
|
||||
Reference in New Issue
Block a user