2020-07-10 01:12:39 +09:00
|
|
|
#![warn(rust_2018_idioms)]
|
2017-06-27 11:23:29 -07:00
|
|
|
|
2020-10-16 15:16:23 -07:00
|
|
|
use bytes::buf::Buf;
|
2017-06-27 11:23:29 -07:00
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn long_take() {
|
2018-06-01 18:05:11 -04:00
|
|
|
// Tests that get a take with a size greater than the buffer length will not
|
2017-06-27 11:23:29 -07:00
|
|
|
// overrun the buffer. Regression test for #138.
|
2019-06-07 12:31:10 -07:00
|
|
|
let buf = b"hello world".take(100);
|
2017-06-27 11:23:29 -07:00
|
|
|
assert_eq!(11, buf.remaining());
|
2020-12-18 11:04:31 -08:00
|
|
|
assert_eq!(b"hello world", buf.chunk());
|
2017-06-27 11:23:29 -07:00
|
|
|
}
|