Skip to content

Commit 9f67be4

Browse files
committed
Add decode test of message not starting with a tag
1 parent b6171c1 commit 9f67be4

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

extras/test/src/test_command_decode.cpp

+24
Original file line numberDiff line numberDiff line change
@@ -685,4 +685,28 @@ SCENARIO("Test the decoding of command messages") {
685685
}
686686
}
687687

688+
/****************************************************************************/
689+
690+
WHEN("Decode a message not starting with a CBOR tag")
691+
{
692+
CommandDown command;
693+
694+
/*
695+
82 # array(2)
696+
1A 65DCB821 # unsigned(1708963873)
697+
1A 78ACA191 # unsigned(2024579473)
698+
*/
699+
700+
uint8_t const payload[] = {0x82, 0x1A, 0x65, 0xDC, 0xB8, 0x21, 0x1A, 0x78,
701+
0xAC, 0xA1, 0x91};
702+
703+
size_t payload_length = sizeof(payload) / sizeof(uint8_t);
704+
CBORMessageDecoder decoder;
705+
Decoder::Status err = decoder.decode((Message*)&command, payload, payload_length);
706+
707+
THEN("The decode is unsuccessful") {
708+
REQUIRE(err == Decoder::Status::Error);
709+
}
710+
}
711+
688712
}

0 commit comments

Comments
 (0)