Skip to content

Commit

Permalink
added bytes-specific get_X tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Walnut356 committed Aug 16, 2023
1 parent 74e7628 commit b49f3d1
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/test_bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

0 comments on commit b49f3d1

Please sign in to comment.