aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_bytes.rs34
-rw-r--r--tests/test_chain.rs6
-rw-r--r--tests/test_iter.rs6
-rw-r--r--tests/test_take.rs2
4 files changed, 24 insertions, 24 deletions
diff --git a/tests/test_bytes.rs b/tests/test_bytes.rs
index 5eaedd3..e34e816 100644
--- a/tests/test_bytes.rs
+++ b/tests/test_bytes.rs
@@ -1,6 +1,6 @@
extern crate bytes;
-use bytes::{Bytes, BytesMut, BufMut, IntoBuf};
+use bytes::{Bytes, BytesMut, Buf, BufMut, IntoBuf};
const LONG: &'static [u8] = b"mary had a little lamb, little lamb, little lamb";
const SHORT: &'static [u8] = b"hello world";
@@ -175,17 +175,17 @@ fn split_off_to_loop() {
let off = bytes.split_off(i);
assert_eq!(i, bytes.len());
let mut sum = Vec::new();
- sum.extend(&bytes);
- sum.extend(&off);
+ sum.extend(bytes.iter());
+ sum.extend(off.iter());
assert_eq!(&s[..], &sum[..]);
}
{
let mut bytes = BytesMut::from(&s[..]);
- let off = bytes.split_off(i);
+ let mut off = bytes.split_off(i);
assert_eq!(i, bytes.len());
let mut sum = Vec::new();
- sum.extend(&bytes);
- sum.extend(&off);
+ sum.extend(&mut bytes);
+ sum.extend(&mut off);
assert_eq!(&s[..], &sum[..]);
}
{
@@ -193,17 +193,17 @@ fn split_off_to_loop() {
let off = bytes.split_to(i);
assert_eq!(i, off.len());
let mut sum = Vec::new();
- sum.extend(&off);
- sum.extend(&bytes);
+ sum.extend(off.iter());
+ sum.extend(bytes.iter());
assert_eq!(&s[..], &sum[..]);
}
{
let mut bytes = BytesMut::from(&s[..]);
- let off = bytes.split_to(i);
+ let mut off = bytes.split_to(i);
assert_eq!(i, off.len());
let mut sum = Vec::new();
- sum.extend(&off);
- sum.extend(&bytes);
+ sum.extend(&mut off);
+ sum.extend(&mut bytes);
assert_eq!(&s[..], &sum[..]);
}
}
@@ -344,7 +344,7 @@ fn reserve_convert() {
fn reserve_growth() {
let mut bytes = BytesMut::with_capacity(64);
bytes.put("hello world");
- let _ = bytes.take();
+ let _ = bytes.split();
bytes.reserve(65);
assert_eq!(bytes.capacity(), 128);
@@ -358,7 +358,7 @@ fn reserve_allocates_at_least_original_capacity() {
bytes.put(i as u8);
}
- let _other = bytes.take();
+ let _other = bytes.split();
bytes.reserve(16);
assert_eq!(bytes.capacity(), 1024);
@@ -374,7 +374,7 @@ fn reserve_max_original_capacity_value() {
bytes.put(0u8);
}
- let _other = bytes.take();
+ let _other = bytes.split();
bytes.reserve(16);
assert_eq!(bytes.capacity(), 64 * 1024);
@@ -398,7 +398,7 @@ fn reserve_vec_recycling() {
#[test]
fn reserve_in_arc_unique_does_not_overallocate() {
let mut bytes = BytesMut::with_capacity(1000);
- bytes.take();
+ bytes.split();
// now bytes is Arc and refcount == 1
@@ -410,7 +410,7 @@ fn reserve_in_arc_unique_does_not_overallocate() {
#[test]
fn reserve_in_arc_unique_doubles() {
let mut bytes = BytesMut::with_capacity(1000);
- bytes.take();
+ bytes.split();
// now bytes is Arc and refcount == 1
@@ -422,7 +422,7 @@ fn reserve_in_arc_unique_doubles() {
#[test]
fn reserve_in_arc_nonunique_does_not_overallocate() {
let mut bytes = BytesMut::with_capacity(1000);
- let _copy = bytes.take();
+ let _copy = bytes.split();
// now bytes is Arc and refcount == 2
diff --git a/tests/test_chain.rs b/tests/test_chain.rs
index 049a8a2..8877258 100644
--- a/tests/test_chain.rs
+++ b/tests/test_chain.rs
@@ -40,10 +40,10 @@ fn writing_chained() {
#[test]
fn iterating_two_bufs() {
- let a = Cursor::new(Bytes::from(&b"hello"[..]));
- let b = Cursor::new(Bytes::from(&b"world"[..]));
+ let a = Bytes::from(&b"hello"[..]);
+ let b = Bytes::from(&b"world"[..]);
- let res: Vec<u8> = a.chain(b).iter().collect();
+ let res: Vec<u8> = a.chain(b).into_iter().collect();
assert_eq!(res, &b"helloworld"[..]);
}
diff --git a/tests/test_iter.rs b/tests/test_iter.rs
index c16dbf6..2d2f495 100644
--- a/tests/test_iter.rs
+++ b/tests/test_iter.rs
@@ -1,10 +1,10 @@
extern crate bytes;
-use bytes::{Buf, IntoBuf, Bytes};
+use bytes::{Bytes};
#[test]
fn iter_len() {
- let buf = Bytes::from(&b"hello world"[..]).into_buf();
+ let buf = Bytes::from_static(b"hello world");
let iter = buf.iter();
assert_eq!(iter.size_hint(), (11, Some(11)));
@@ -14,7 +14,7 @@ fn iter_len() {
#[test]
fn empty_iter_len() {
- let buf = Bytes::from(&b""[..]).into_buf();
+ let buf = Bytes::from_static(b"");
let iter = buf.iter();
assert_eq!(iter.size_hint(), (0, Some(0)));
diff --git a/tests/test_take.rs b/tests/test_take.rs
index 93e0c6c..0637569 100644
--- a/tests/test_take.rs
+++ b/tests/test_take.rs
@@ -5,7 +5,7 @@ use std::io::Cursor;
#[test]
fn long_take() {
- // Tests that take with a size greater than the buffer length will not
+ // Tests that get a take with a size greater than the buffer length will not
// overrun the buffer. Regression test for #138.
let buf = Cursor::new(b"hello world").take(100);
assert_eq!(11, buf.remaining());