Skip to content

Commit

Permalink
Fixed some previously ignored unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Scottapotamas committed Apr 8, 2024
1 parent 59bc1a0 commit 171c9e6
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions test/test_xsens_mti.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@
xsens_interface_t test_imu = { 0 };

uint32_t mocked_fn_override_called = 0;
bool ack_config = false;

// User-space callback overrides
void handle_ack_gotoconfig( xsens_packet_buffer_t *packet );

void handle_ack_gotoconfig( xsens_packet_buffer_t *packet )
{
ack_config = true;
}


// PRIVATE FUNCTIONS

Expand Down Expand Up @@ -47,14 +57,15 @@ void setUp(void)
memset( &test_imu, 0, sizeof(test_imu) );
test_imu.output_cb = &mock_output_function;
test_imu.event_cb = &mock_event_function;

ack_config = false;
}

void tearDown(void)
{

}

// TESTS
void test_parse_basic( void )
{
// Simulate the IMU sending a GoToConfigAck packet
Expand All @@ -64,6 +75,9 @@ void test_parse_basic( void )
// Size is 0x00
// CRC is 0xD0

// Setup userspace callback
xsens_mti_override_id_handler( MT_ACK_GOTOCONFIG, &handle_ack_gotoconfig );

uint8_t test_packet[] = { 0xFA,
0xFF,
0x31,
Expand All @@ -75,23 +89,25 @@ void test_parse_basic( void )
xsens_mti_parse( &test_imu, test_packet[i]);
}

TEST_IGNORE();
// Expect the callback to have fired
TEST_ASSERT_TRUE( ack_config );
}

void test_parse_buffer( void )
{
// Check that the buffer helper function behaves the same
// as the basic test above
// Setup userspace callback
xsens_mti_override_id_handler( MT_ACK_GOTOCONFIG, &handle_ack_gotoconfig );

uint8_t test_packet[] = { 0xFA,
0xFF,
0x31,
0x00,
0xD0 };

xsens_mti_parse_buffer( &test_imu, test_packet, sizeof(test_packet));

TEST_IGNORE();

TEST_ASSERT_TRUE( ack_config );
}

void test_handler_override( void )
Expand Down

0 comments on commit 171c9e6

Please sign in to comment.