Skip to content

Commit 3a2a97b

Browse files
committed
Add corrupted ThingUpdateCmdId message decode test
1 parent 6f8e7fe commit 3a2a97b

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

extras/test/src/test_command_decode.cpp

+21
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,27 @@ SCENARIO("Test the decoding of command messages") {
5050

5151
/****************************************************************************/
5252

53+
WHEN("Decode the ThingUpdateCmdId message containing a number instead of a string")
54+
{
55+
CommandDown command;
56+
/*
57+
DA 00010400 # tag(66560)
58+
81 # array(1)
59+
1A 65DCB821 # unsigned(1708963873)
60+
*/
61+
uint8_t const payload[] = {0xDA, 0x00, 0x01, 0x04, 0x00, 0x81, 0x1A, 0x65,
62+
0xDC, 0xB8, 0x21};
63+
size_t payload_length = sizeof(payload) / sizeof(uint8_t);
64+
CBORMessageDecoder decoder;
65+
Decoder::Status err = decoder.decode((Message*)&command, payload, payload_length);
66+
67+
THEN("The decode is unsuccessful") {
68+
REQUIRE(err == Decoder::Status::Error);
69+
}
70+
}
71+
72+
/****************************************************************************/
73+
5374
WHEN("Decode the SetTimezoneCommand message")
5475
{
5576
CommandDown command;

0 commit comments

Comments
 (0)