From b49f3d1bc449a75c7e7a6e3976ce90934afcb78e Mon Sep 17 00:00:00 2001 From: Walnut <39544927+Walnut356@users.noreply.github.com> Date: Wed, 16 Aug 2023 08:21:39 -0500 Subject: [PATCH] added bytes-specific get_X tests --- tests/test_bytes.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/test_bytes.rs b/tests/test_bytes.rs index 5ec60a5b0..a12816ab5 100644 --- a/tests/test_bytes.rs +++ b/tests/test_bytes.rs @@ -1208,3 +1208,18 @@ fn test_bytes_capacity_len() { } } } + +#[test] +fn test_get_u16() { + let mut buf = Bytes::from(&b"\x21\x54zomg"[..]); + assert_eq!(0x2154, buf.get_u16()); + let mut buf = Bytes::from(&b"\x21\x54zomg"[..]); + assert_eq!(0x5421, buf.get_u16_le()); +} + +#[test] +#[should_panic] +fn test_get_u16_buffer_underflow() { + let mut buf = Bytes::from(&b"\x21"[..]); + buf.get_u16(); +} \ No newline at end of file