Skip to content

Commit

Permalink
test(gpio): assert that the GPIO types are zero cost memory-wise (ari…
Browse files Browse the repository at this point in the history
  • Loading branch information
kaspar030 authored Oct 23, 2024
2 parents 4c59c8f + 069254b commit fc65556
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ jobs:
# TODO: we'll eventually want to enable relevant features
- name: Run crate tests
run: |
cargo test --no-default-features --features i2c,no-boards -p riot-rs -p riot-rs-embassy -p riot-rs-embassy-common -p riot-rs-runqueue -p riot-rs-threads -p riot-rs-macros
cargo test --no-default-features --features external-interrupts,i2c,no-boards -p riot-rs -p riot-rs-embassy -p riot-rs-embassy-common -p riot-rs-runqueue -p riot-rs-threads -p riot-rs-macros
cargo test -p rbi -p ringbuffer -p coapcore
# We need to set `RUSTDOCFLAGS` as well in the following jobs, because it
Expand Down
13 changes: 13 additions & 0 deletions src/riot-rs-embassy/src/gpio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -477,3 +477,16 @@ macro_rules! impl_embedded_hal_output_traits {
}

impl_embedded_hal_output_traits!(Output, ArchOutput);

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn check_gpio_type_sizes() {
// Assert that the GPIO types are zero cost memory-wise.
assert_eq!(size_of::<Input>(), size_of::<()>());
assert_eq!(size_of::<IntEnabledInput>(), size_of::<()>());
assert_eq!(size_of::<Output>(), size_of::<()>());
}
}

0 comments on commit fc65556

Please sign in to comment.