Skip to content

Commit

Permalink
test: add regression test for #730
Browse files Browse the repository at this point in the history
  • Loading branch information
paolobarbolini committed Aug 19, 2024
1 parent 76c8773 commit 0895f62
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/test_buf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,19 @@ fn test_get_u16() {
assert_eq!(0x5421, buf.get_u16_le());
}

#[test]
fn test_get_int() {
let mut buf = &b"\xd6zomg"[..];
assert_eq!(-42, buf.get_int(1));
let mut buf = &b"\xd6zomg"[..];
assert_eq!(-42, buf.get_int_le(1));

let mut buf = &b"\xfe\x1d\xc0zomg"[..];
assert_eq!(0xffffffffffc01dfeu64 as i64, buf.get_int_le(3));
let mut buf = &b"\xfe\x1d\xc0zomg"[..];
assert_eq!(0xfffffffffffe1dc0u64 as i64, buf.get_int(3));
}

#[test]
#[should_panic]
fn test_get_u16_buffer_underflow() {
Expand Down

0 comments on commit 0895f62

Please sign in to comment.