macro_rules! testaso {
(@off $name:path=>$field:ident) => { ... };
($(struct $name:path: $align:expr, $size:expr => { $($field:ident: $offset:expr),* })+) => { ... };
}
Expand description
Macro to test alignment, size and offsets of structs
Examples
#[repr(C)]
struct Simple {
a: u32,
b: [u8; 2],
c: i64,
}
#[repr(C, packed)]
struct SimplePacked {
a: u32,
b: [u8; 2],
c: i64,
}
#[cfg(test)]
mod test {
use testaso::testaso;
use super::Simple;
use super::SimplePacked;
testaso! {
struct Simple: 8, 16 => {
a: 0,
b: 4,
c: 8
}
struct SimplePacked: 1, 14 => {
a: 0,
b: 4,
c: 6
}
}
}