From 49686b79d374cd412e86ce6298d3695b7ee85b1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Jos=C3=A9=20Pereira?= Date: Mon, 20 Nov 2023 12:48:10 -0300 Subject: [PATCH] tests: Add serialization test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Patrick José Pereira --- tests/mav_frame_tests.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/mav_frame_tests.rs b/tests/mav_frame_tests.rs index 50e900f8cd..ef20068ffe 100644 --- a/tests/mav_frame_tests.rs +++ b/tests/mav_frame_tests.rs @@ -23,7 +23,7 @@ mod mav_frame_tests { ]; #[test] - pub fn test_deser() { + pub fn test_deser_ser() { use mavlink::{common::MavMessage, MavFrame, MavlinkVersion}; let frame = MavFrame::::deser(MavlinkVersion::V2, HEARTBEAT_V2) .expect("failed to parse message"); @@ -31,6 +31,10 @@ mod mav_frame_tests { assert_eq!(frame.header, crate::test_shared::COMMON_MSG_HEADER); let heartbeat_msg = crate::test_shared::get_heartbeat_msg(); + let mut buffer = [0u8; HEARTBEAT_V2.len()]; + frame.ser(&mut buffer); + assert_eq!(buffer[..buffer.len() - 2], HEARTBEAT_V2[..buffer.len() - 2]); + let msg = match frame.msg { MavMessage::HEARTBEAT(msg) => msg, _ => panic!("Decoded wrong message type"),