Skip to content

Commit cce7ff6

Browse files
committed
Add invalid cbor tag decode test
1 parent e74a271 commit cce7ff6

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

extras/test/src/test_command_decode.cpp

+25
Original file line numberDiff line numberDiff line change
@@ -397,4 +397,29 @@ SCENARIO("Test the decoding of command messages") {
397397
}
398398
}
399399

400+
/****************************************************************************/
401+
402+
WHEN("Decode a message with invalid CBOR tag")
403+
{
404+
CommandDown command;
405+
406+
/*
407+
DA ffffffff # invalid tag
408+
82 # array(2)
409+
1A 65DCB821 # unsigned(1708963873)
410+
1A 78ACA191 # unsigned(2024579473)
411+
*/
412+
413+
uint8_t const payload[] = {0xDA, 0xff, 0xff, 0xff, 0xff, 0x82, 0x1A, 0x65,
414+
0xDC, 0xB8, 0x21, 0x1A, 0x78, 0xAC, 0xA1, 0x91};
415+
416+
size_t payload_length = sizeof(payload) / sizeof(uint8_t);
417+
CBORMessageDecoder decoder;
418+
Decoder::Status err = decoder.decode((Message*)&command, payload, payload_length);
419+
420+
THEN("The decode is unsuccessful") {
421+
REQUIRE(err == Decoder::Status::Error);
422+
}
423+
}
424+
400425
}

0 commit comments

Comments
 (0)