Skip to content

Commit

Permalink
add packet unit test for parsing invalid header bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
stuffmatic committed Sep 11, 2023
1 parent f4593d9 commit aafcdfa
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/ble_midi_packet_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,16 @@ void test_too_large_timestamp()
assert_payload_equals(&writer, expected_payload, sizeof(expected_payload));
}

static void test_parse_invalid_header_byte() {
printf("Parsing a packet with an invalid header byte should fail\n \n");
uint8_t payload[] = {
0x03, // invalid packet header
0x8a, 0x90, 0x69, 0x7f, // note on w timestamp
};
num_parsed_messages = 0;
assert_error_code(ble_midi_parse_packet(payload, sizeof(payload), &ble_midi_parse_cb), BLE_MIDI_ERROR_INVALID_HEADER_BYTE);
}

void test_running_status_with_one_rt()
{
midi_msg_t messages[] = {
Expand Down Expand Up @@ -555,6 +565,7 @@ int main(int argc, char *argv[])
{
test_timestamp_byte_wrapping();
test_too_large_timestamp();
test_parse_invalid_header_byte();
test_running_status_disabled();
test_running_status_with_one_rt();
test_running_status_with_two_rt();
Expand Down

0 comments on commit aafcdfa

Please sign in to comment.