Skip to content

Commit

Permalink
Add test for issue 485
Browse files Browse the repository at this point in the history
* This was fixed as part of this MR, not exactly sure what fixed it and
  don't have time to fully investigate
  • Loading branch information
wcampbell0x2a committed Oct 1, 2024
1 parent ae5a49f commit 62d379a
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions tests/test_attributes/test_limits/test_read_all.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,36 @@ fn test_read_all() {
let ret_write: Vec<u8> = ret_read.try_into().unwrap();
assert_eq!(test_data, ret_write);
}

#[cfg(feature = "bits")]
#[test]
fn test_485_read_all_at_end() {
#[derive(Clone, Debug, DekuWrite, DekuRead, PartialEq)]
pub struct Foo {
#[deku(bits = 40)]
pub weird_sized_thing: u64,
pub normal_sized_thing: u8,
pub other_thing: u16,
#[deku(read_all)]
pub bulk_things: Vec<u8>,
}

#[rustfmt::skip]
const INPUT_DATA_MESSAGE: [u8; 11] = [
0x01, 0x01, 0x01, 0x01, 0x01,
0x0,
0x02, 0x02,
0x00, 0x00, 0x00,
];

let foo = Foo::try_from(INPUT_DATA_MESSAGE.as_ref()).unwrap();
assert_eq!(
foo,
Foo {
weird_sized_thing: 0x101010101,
normal_sized_thing: 0x0,
other_thing: 0x0202,
bulk_things: vec![0x00, 0x00, 0x00]
}
);
}

0 comments on commit 62d379a

Please sign in to comment.