Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding test suggestion #147

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions sfy-buoy/src/axl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,4 +194,29 @@ mod tests {
// This does not include the additional size used by COBS.
// assert!(AXL_POSTCARD_SZ >= AxlPacket::POSTCARD_MAX_SIZE);
}

#[test]
fn temp_not_f32_subnormal() {
// the notecard does not handle NaN f32's
let p = AxlPacketMeta::default();

let v: heapless::String<{10 * 1024}> = serde_json_core::to_string(&p).unwrap();
dbg!(&v);
assert!(v.contains("temperature"));


let mut p = AxlPacketMeta::default();
p.temperature = f32::NAN;

let v: heapless::String<{10 * 1024}> = serde_json_core::to_string(&p).unwrap();
dbg!(&v);
assert!(!v.contains("temperature"));

let mut p = AxlPacketMeta::default();
p.temperature = f32::INFINITY;

let v: heapless::String<{10 * 1024}> = serde_json_core::to_string(&p).unwrap();
dbg!(&v);
assert!(!v.contains("temperature"));
}
}