summaryrefslogtreecommitdiffstats
path: root/third_party/rust/bytes/tests/test_take.rs
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/rust/bytes/tests/test_take.rs')
-rw-r--r--third_party/rust/bytes/tests/test_take.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/third_party/rust/bytes/tests/test_take.rs b/third_party/rust/bytes/tests/test_take.rs
new file mode 100644
index 0000000000..b9b525b1f8
--- /dev/null
+++ b/third_party/rust/bytes/tests/test_take.rs
@@ -0,0 +1,12 @@
+#![deny(warnings, rust_2018_idioms)]
+
+use bytes::buf::{Buf, BufExt};
+
+#[test]
+fn long_take() {
+ // Tests that get a take with a size greater than the buffer length will not
+ // overrun the buffer. Regression test for #138.
+ let buf = b"hello world".take(100);
+ assert_eq!(11, buf.remaining());
+ assert_eq!(b"hello world", buf.bytes());
+}