aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_buf_mut.rs18
-rw-r--r--tests/test_bytes.rs8
2 files changed, 26 insertions, 0 deletions
diff --git a/tests/test_buf_mut.rs b/tests/test_buf_mut.rs
index 78a76bc..53f4e86 100644
--- a/tests/test_buf_mut.rs
+++ b/tests/test_buf_mut.rs
@@ -28,6 +28,14 @@ fn test_vec_as_mut_buf() {
}
#[test]
+fn test_vec_put_bytes() {
+ let mut buf = Vec::new();
+ buf.push(17);
+ buf.put_bytes(19, 2);
+ assert_eq!([17, 19, 19], &buf[..]);
+}
+
+#[test]
fn test_put_u8() {
let mut buf = Vec::with_capacity(8);
buf.put_u8(33);
@@ -104,6 +112,16 @@ fn test_mut_slice() {
}
#[test]
+fn test_slice_put_bytes() {
+ let mut v = [0, 0, 0, 0];
+ let mut s = &mut v[..];
+ s.put_u8(17);
+ s.put_bytes(19, 2);
+ assert_eq!(1, s.remaining_mut());
+ assert_eq!(&[17, 19, 19, 0], &v[..]);
+}
+
+#[test]
fn test_deref_bufmut_forwards() {
struct Special;
diff --git a/tests/test_bytes.rs b/tests/test_bytes.rs
index 2d22fdd..0914155 100644
--- a/tests/test_bytes.rs
+++ b/tests/test_bytes.rs
@@ -986,3 +986,11 @@ fn bytes_with_capacity_but_empty() {
let vec = Vec::with_capacity(1);
let _ = Bytes::from(vec);
}
+
+#[test]
+fn bytes_put_bytes() {
+ let mut bytes = BytesMut::new();
+ bytes.put_u8(17);
+ bytes.put_bytes(19, 2);
+ assert_eq!([17, 19, 19], bytes.as_ref());
+}