Skip to content

Commit

Permalink
Test mixed endianness example
Browse files Browse the repository at this point in the history
  • Loading branch information
fwcd committed Aug 4, 2023
1 parent 66663e4 commit 9279ff5
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/pack_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,15 @@ fn fixed_endianness() {
assert_eq!(pack_vec::<BigEndian, _>(LE(45u16)), pack_vec::<LittleEndian, u16>(45));
assert_eq!(pack_vec::<LittleEndian, _>(LE(45u16)), pack_vec::<LittleEndian, u16>(45));
}

#[test]
fn mixed_endianness() {
#[derive(Size, Pack)]
struct Mixed {
le: LE<u16>,
be: BE<u16>,
}

assert_eq!(pack_vec::<BigEndian, _>(Mixed { le: LE(256), be: BE(256) }), vec![0, 1, 1, 0]);
assert_eq!(pack_vec::<LittleEndian, _>(Mixed { le: LE(256), be: BE(256) }), vec![0, 1, 1, 0]);
}

0 comments on commit 9279ff5

Please sign in to comment.