mirror of
https://github.com/tokio-rs/bytes.git
synced 2026-08-17 00:00:14 +02:00
added clone to ByteBuf and BytesMut along with simple clone test
This commit is contained in:
+12
-1
@@ -1,8 +1,9 @@
|
||||
extern crate bytes;
|
||||
extern crate byteorder;
|
||||
|
||||
use bytes::BufMut;
|
||||
use bytes::{Buf, BufMut, ByteBuf};
|
||||
use std::usize;
|
||||
use std::fmt::Write;
|
||||
|
||||
#[test]
|
||||
fn test_vec_as_mut_buf() {
|
||||
@@ -45,3 +46,13 @@ fn test_put_u16() {
|
||||
buf.put_u16::<byteorder::LittleEndian>(8532);
|
||||
assert_eq!(b"\x54\x21", &buf[..]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_clone() {
|
||||
let mut buf = ByteBuf::with_capacity(100);
|
||||
buf.write_str("this is a test").unwrap();
|
||||
let buf2 = buf.clone();
|
||||
|
||||
buf.write_str(" of our emergecy broadcast system").unwrap();
|
||||
assert_ne!(buf.bytes(), buf2.bytes());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user