Skip to content

Commit

Permalink
Add UT and fix size_table
Browse files Browse the repository at this point in the history
  • Loading branch information
AniruddhaKanhere committed Oct 22, 2024
1 parent 6ae9093 commit 4c44952
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 4 deletions.
8 changes: 4 additions & 4 deletions docs/doxygen/include/size_table.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
</tr>
<tr>
<td>core_mqtt.c</td>
<td><center>4.9K</center></td>
<td><center>4.2K</center></td>
<td><center>5.0K</center></td>
<td><center>4.3K</center></td>
</tr>
<tr>
<td>core_mqtt_state.c</td>
Expand All @@ -24,7 +24,7 @@
</tr>
<tr>
<td><b>Total estimates</b></td>
<td><b><center>9.5K</center></b></td>
<td><b><center>7.8K</center></b></td>
<td><b><center>9.6K</center></b></td>
<td><b><center>7.9K</center></b></td>
</tr>
</table>
44 changes: 44 additions & 0 deletions test/unit-test/core_mqtt_utest.c
Original file line number Diff line number Diff line change
Expand Up @@ -7242,3 +7242,47 @@ void test_MQTT_InitStatefulQoS_callback_is_null( void )
TEST_ASSERT_EQUAL( MQTTBadParameter, mqttStatus );
}
/* ========================================================================== */

void test_MQTT_GetBytesInMQTTVec( void )
{
TransportOutVector_t pTransportArray[10] = {
{.iov_base = NULL, .iov_len = 1 },
{.iov_base = NULL, .iov_len = 2 },
{.iov_base = NULL, .iov_len = 3 },
{.iov_base = NULL, .iov_len = 4 },
{.iov_base = NULL, .iov_len = 5 },
{.iov_base = NULL, .iov_len = 6 },
{.iov_base = NULL, .iov_len = 7 },
{.iov_base = NULL, .iov_len = 8 },
{.iov_base = NULL, .iov_len = 9 },
{.iov_base = NULL, .iov_len = 10 },
};

size_t ret = MQTT_GetBytesInMQTTVec( (MQTTVec_t*)pTransportArray, 10);

TEST_ASSERT_EQUAL(55, ret);
}
/* ========================================================================== */

void test_MQTT_SerializeMQTTVec( void )
{
TransportOutVector_t pTransportArray[10] = {
{.iov_base = "T", .iov_len = 1 },
{.iov_base = "hi", .iov_len = 2 },
{.iov_base = "s i", .iov_len = 3 },
{.iov_base = "s a ", .iov_len = 4 },
{.iov_base = "coreM", .iov_len = 5 },
{.iov_base = "QTT un", .iov_len = 6 },
{.iov_base = "it test", .iov_len = 7 },
{.iov_base = " string.", .iov_len = 8 },
{.iov_base = "USER SHOU", .iov_len = 9 },
{.iov_base = "LDNT USE IT", .iov_len = 10 },
};

uint8_t array[60] = {0};
MQTT_SerializeMQTTVec(array, (MQTTVec_t*)pTransportArray, 10 );

TEST_ASSERT_EQUAL_MEMORY("This is a coreMQTT unit test string.USER SHOULDNT USE IT", array, 55);
TEST_ASSERT_EQUAL_MEMORY("\0\0\0\0\0", &array[55], 5);

}

0 comments on commit 4c44952

Please sign in to comment.