Skip to content

Commit a47facc

Browse files
added unit test for OtaUpdateCmdDown message decode without field url
1 parent 8404c21 commit a47facc

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

extras/test/src/test_command_decode.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,32 @@ SCENARIO("Test the decoding of command messages") {
667667
}
668668
}
669669

670+
/****************************************************************************/
671+
672+
WHEN("Decode the OtaUpdateCmdDown message without url field")
673+
{
674+
CommandDown command;
675+
676+
/*
677+
DA 00010100 # tag(65792)
678+
80 # array(1)
679+
50 # bytes(16)
680+
C73CB045F9C2434585AFFA36A307BFE7"\xC7<\xB0E\xF9\xC2CE\x85\xAF\xFA6\xA3\a\xBF\xE7"
681+
682+
*/
683+
uint8_t const payload[] = {0xda, 0x00, 0x01, 0x01, 0x00, 0x81, 0x50, 0xc7,
684+
0x3c, 0xb0, 0x45, 0xf9, 0xc2, 0x43, 0x45, 0x85,
685+
0xaf, 0xfa, 0x36, 0xa3, 0x07, 0xbf, 0xe7};
686+
687+
size_t payload_length = sizeof(payload) / sizeof(uint8_t);
688+
CBORMessageDecoder decoder;
689+
MessageDecoder::Status err = decoder.decode((Message*)&command, payload, payload_length);
690+
691+
THEN("The decode is unsuccessful") {
692+
REQUIRE(err == MessageDecoder::Status::Error);
693+
}
694+
}
695+
670696
/****************************************************************************/
671697

672698
WHEN("Decode the OtaBeginUp message")

0 commit comments

Comments
 (0)