Skip to content

Commit

Permalink
tests: packer: Add message_id test
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick José Pereira <[email protected]>
  • Loading branch information
patrickelectric committed Apr 18, 2024
1 parent 6a7ddd9 commit 0609863
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tests/packer.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use ping_rs::common::{self, Messages as common_messages};
use ping_rs::message::ProtocolMessage;
use ping_rs::message::{MessageInfo, PingMessage, ProtocolMessage};

#[test]
fn test_same_packer() {
Expand All @@ -26,10 +26,15 @@ fn test_same_packer() {
);

general_request.requested_id = 1211;
packer.set_message(&common_messages::GeneralRequest(general_request));
packer.set_message(&common_messages::GeneralRequest(general_request.clone()));
packer.set_dst_device_id(0);
assert_eq!(
packer.serialized(),
[0x42, 0x52, 0x02, 0x00, 0x06, 0x00, 0x00, 0x00, 0xbb, 0x04, 0x5b, 0x01]
);

assert_eq!(
common::GeneralRequestStruct::id(),
common_messages::GeneralRequest(general_request).message_id()
);
}

0 comments on commit 0609863

Please sign in to comment.