Files
bytes/test/test_seq.rs
T
Carl Lerche 04e0ac75e2 Huge overhaul of bytes
* Get rid of `ByteStr` trait
* `Bytes` is not a concrete type
* Add `BlockBuf`
* Delete lots of cruft
* Performance work
2016-08-10 15:45:31 -07:00

33 lines
555 B
Rust

use bytes::{Buf, Bytes};
use super::gen_bytes;
#[test]
pub fn test_slice_round_trip() {
let mut dst = vec![];
let src = gen_bytes(2000);
let s = Bytes::from(&src);
assert_eq!(2000, s.len());
s.buf().copy_to(&mut dst);
assert_eq!(dst, src);
}
#[test]
pub fn test_index() {
let src = gen_bytes(2000);
let s = Bytes::from(&src);
for i in 0..2000 {
assert_eq!(src[i], s[i]);
}
}
#[test]
#[should_panic]
pub fn test_index_out_of_range() {
let s = Bytes::from(&gen_bytes(2000));
let _ = s[2001];
}