From 82b73bf730d03ca491a5941ce99e21aa6652deac Mon Sep 17 00:00:00 2001 From: Louis Thiery Date: Fri, 12 Apr 2024 12:55:03 -0700 Subject: [PATCH] snr roundtrip test --- src/packet/push_data.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/packet/push_data.rs b/src/packet/push_data.rs index 302df4c..e2cc703 100644 --- a/src/packet/push_data.rs +++ b/src/packet/push_data.rs @@ -406,4 +406,13 @@ mod test { let parsed: Data = serde_json::from_str(json).expect("Error parsing push_data::Data"); check_given_snr(parsed, -3.5); } + + #[test] + fn snr_roundtrip() { + let json = "{\"rxpk\":[{\"jver\":1,\"tmst\":682631918,\"chan\":0,\"rfch\":0,\"freq\":865.062500,\"mid\": 0,\"stat\":1,\"modu\":\"LORA\",\"datr\":\"SF12BW125\",\"codr\":\"4/5\",\"rssis\":-95,\"lsnr\":6.8,\"foff\":-1300,\"rssi\":-94,\"size\":20,\"data\":\"QNbPNwABAQANyqD8ngiq26Hk4gs=\"}]}"; + let parsed: Data = serde_json::from_str(json).expect("Error parsing push_data::Data"); + let serialized = serde_json::to_string(&parsed).expect("Error serializing push_data::Data"); + let reparsed: Data = serde_json::from_str(&serialized).expect("Error parsing push_data::Data"); + check_given_snr(reparsed, 6.8); + } }