wspr-beacon/testsuite/tests/wspr.rs

34 lines
1.2 KiB
Rust

#![no_std]
#![no_main]
use wspr_beacon as _; // memory layout + panic handler
// See https://crates.io/crates/defmt-test/0.1.0 for more documentation (e.g. about the 'state'
// feature)
#[defmt_test::tests]
mod tests {
use arrayvec::ArrayString;
use defmt::{assert, assert_eq, Debug2Format};
use wspr_beacon::wspr;
#[test]
fn test_encoding() {
let call_sign = ArrayString::<6>::from(" K1ABC").unwrap();
let loc = ArrayString::<6>::from("FN42").unwrap();
let symbols = wspr::encode_message(&call_sign, &loc, 37);
let expected_symbols: [u8; 162] = [
3, 3, 0, 0, 2, 0, 0, 0, 1, 0, 2, 0, 1, 3, 1, 2, 2, 2, 1, 0, 0, 3, 2, 3, 1, 3, 3, 2, 2,
0, 2, 0, 0, 0, 3, 2, 0, 1, 2, 3, 2, 2, 0, 0, 2, 2, 3, 2, 1, 1, 0, 2, 3, 3, 2, 1, 0, 2,
2, 1, 3, 2, 1, 2, 2, 2, 0, 3, 3, 0, 3, 0, 3, 0, 1, 2, 1, 0, 2, 1, 2, 0, 3, 2, 1, 3, 2,
0, 0, 3, 3, 2, 3, 0, 3, 2, 2, 0, 3, 0, 2, 0, 2, 0, 1, 0, 2, 3, 0, 2, 1, 1, 1, 2, 3, 3,
0, 2, 3, 1, 2, 1, 2, 2, 2, 1, 3, 3, 2, 0, 0, 0, 0, 1, 0, 3, 2, 0, 1, 3, 2, 2, 2, 2, 2,
0, 2, 3, 3, 2, 3, 2, 3, 3, 2, 0, 0, 3, 1, 2, 2, 2,
];
for i in 0..162 {
assert_eq!(expected_symbols[i], symbols[i]);
}
}
}