diff options
Diffstat (limited to 'third_party/rust/bytes-0.4.12/tests/test_from_buf.rs')
-rw-r--r-- | third_party/rust/bytes-0.4.12/tests/test_from_buf.rs | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/third_party/rust/bytes-0.4.12/tests/test_from_buf.rs b/third_party/rust/bytes-0.4.12/tests/test_from_buf.rs new file mode 100644 index 0000000000..216bf12328 --- /dev/null +++ b/third_party/rust/bytes-0.4.12/tests/test_from_buf.rs @@ -0,0 +1,34 @@ +extern crate bytes; + +use bytes::{Buf, Bytes, BytesMut}; +use std::io::Cursor; + +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> = Cursor::new(SHORT).collect(); + assert_eq!(buf, SHORT); + + let buf: Vec<u8> = Cursor::new(LONG).collect(); + assert_eq!(buf, LONG); +} + +#[test] +fn collect_to_bytes() { + let buf: Bytes = Cursor::new(SHORT).collect(); + assert_eq!(buf, SHORT); + + let buf: Bytes = Cursor::new(LONG).collect(); + assert_eq!(buf, LONG); +} + +#[test] +fn collect_to_bytes_mut() { + let buf: BytesMut = Cursor::new(SHORT).collect(); + assert_eq!(buf, SHORT); + + let buf: BytesMut = Cursor::new(LONG).collect(); + assert_eq!(buf, LONG); +} |