diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_buf_mut.rs | 2 | ||||
-rw-r--r-- | tests/test_bytes.rs | 12 | ||||
-rw-r--r-- | tests/test_chain.rs | 6 | ||||
-rw-r--r-- | tests/test_from_buf.rs | 33 |
4 files changed, 10 insertions, 43 deletions
diff --git a/tests/test_buf_mut.rs b/tests/test_buf_mut.rs index 2c9f1f2..d545d2b 100644 --- a/tests/test_buf_mut.rs +++ b/tests/test_buf_mut.rs @@ -32,7 +32,7 @@ fn test_vec_as_mut_buf() { #[test] fn test_put_u8() { let mut buf = Vec::with_capacity(8); - buf.put::<u8>(33); + buf.put_u8(33); assert_eq!(b"\x21", &buf[..]); } diff --git a/tests/test_bytes.rs b/tests/test_bytes.rs index 70a8205..3c51ac5 100644 --- a/tests/test_bytes.rs +++ b/tests/test_bytes.rs @@ -302,14 +302,14 @@ fn fns_defined_for_bytes_mut() { fn reserve_convert() { // Inline -> Vec let mut bytes = BytesMut::with_capacity(8); - bytes.put("hello"); + bytes.put("hello".as_bytes()); bytes.reserve(40); assert_eq!(bytes.capacity(), 45); assert_eq!(bytes, "hello"); // Inline -> Inline let mut bytes = BytesMut::with_capacity(inline_cap()); - bytes.put("abcdefghijkl"); + bytes.put("abcdefghijkl".as_bytes()); let a = bytes.split_to(10); bytes.reserve(inline_cap() - 3); @@ -336,7 +336,7 @@ fn reserve_convert() { #[test] fn reserve_growth() { let mut bytes = BytesMut::with_capacity(64); - bytes.put("hello world"); + bytes.put("hello world".as_bytes()); let _ = bytes.split(); bytes.reserve(65); @@ -348,7 +348,7 @@ fn reserve_allocates_at_least_original_capacity() { let mut bytes = BytesMut::with_capacity(1024); for i in 0..1020 { - bytes.put(i as u8); + bytes.put_u8(i as u8); } let _other = bytes.split(); @@ -364,7 +364,7 @@ fn reserve_max_original_capacity_value() { let mut bytes = BytesMut::with_capacity(SIZE); for _ in 0..SIZE { - bytes.put(0u8); + bytes.put_u8(0u8); } let _other = bytes.split(); @@ -381,7 +381,7 @@ fn reserve_max_original_capacity_value() { fn reserve_vec_recycling() { let mut bytes = BytesMut::from(Vec::with_capacity(16)); assert_eq!(bytes.capacity(), 16); - bytes.put("0123456789012345"); + bytes.put("0123456789012345".as_bytes()); bytes.advance(10); assert_eq!(bytes.capacity(), 6); bytes.reserve(8); diff --git a/tests/test_chain.rs b/tests/test_chain.rs index 6708028..2887575 100644 --- a/tests/test_chain.rs +++ b/tests/test_chain.rs @@ -9,7 +9,7 @@ fn collect_two_bufs() { let a = Bytes::from(&b"hello"[..]); let b = Bytes::from(&b"world"[..]); - let res: Vec<u8> = a.chain(b).collect(); + let res = a.chain(b).to_bytes(); assert_eq!(res, &b"helloworld"[..]); } @@ -21,8 +21,8 @@ fn writing_chained() { { let mut buf = Chain::new(&mut a, &mut b); - for i in 0..128 { - buf.put(i as u8); + for i in 0u8..128 { + buf.put_u8(i); } } diff --git a/tests/test_from_buf.rs b/tests/test_from_buf.rs deleted file mode 100644 index 5f644e1..0000000 --- a/tests/test_from_buf.rs +++ /dev/null @@ -1,33 +0,0 @@ -#![deny(warnings, rust_2018_idioms)] - -use bytes::{Buf, Bytes, BytesMut}; - -const LONG: &'static [u8] = b"mary had a little lamb, little lamb, little lamb"; -const SHORT: &'static [u8] = b"hello world"; - -#[test] -fn collect_to_vec() { - let buf: Vec<u8> = SHORT.collect(); - assert_eq!(buf, SHORT); - - let buf: Vec<u8> = LONG.collect(); - assert_eq!(buf, LONG); -} - -#[test] -fn collect_to_bytes() { - let buf: Bytes = SHORT.collect(); - assert_eq!(buf, SHORT); - - let buf: Bytes = LONG.collect(); - assert_eq!(buf, LONG); -} - -#[test] -fn collect_to_bytes_mut() { - let buf: BytesMut = SHORT.collect(); - assert_eq!(buf, SHORT); - - let buf: BytesMut = LONG.collect(); - assert_eq!(buf, LONG); -} |