Crates.io | testaso |
lib.rs | testaso |
version | 0.1.0 |
source | src |
created_at | 2022-03-25 14:55:03.88006 |
updated_at | 2022-03-25 14:55:03.88006 |
description | Test alignment, size and offset for structs. |
homepage | https://github.com/enarx/testaso |
repository | https://github.com/enarx/testaso |
max_upload_size | |
id | 556254 |
size | 8,831 |
Macro to test alignment, size and offsets of structs
This is mostly useful for creating FFI structures.
The crucial field offset calculation was extracted from the memoffset
crate.
Kudos to Gilad Naaman and Ralf Jung and all the other contributors.
#[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
}
}
}
License: MIT