Skip to content

Commit 4c44952

Browse files
Add UT and fix size_table
1 parent 6ae9093 commit 4c44952

File tree

2 files changed

+48
-4
lines changed

2 files changed

+48
-4
lines changed

docs/doxygen/include/size_table.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
</tr>
1010
<tr>
1111
<td>core_mqtt.c</td>
12-
<td><center>4.9K</center></td>
13-
<td><center>4.2K</center></td>
12+
<td><center>5.0K</center></td>
13+
<td><center>4.3K</center></td>
1414
</tr>
1515
<tr>
1616
<td>core_mqtt_state.c</td>
@@ -24,7 +24,7 @@
2424
</tr>
2525
<tr>
2626
<td><b>Total estimates</b></td>
27-
<td><b><center>9.5K</center></b></td>
28-
<td><b><center>7.8K</center></b></td>
27+
<td><b><center>9.6K</center></b></td>
28+
<td><b><center>7.9K</center></b></td>
2929
</tr>
3030
</table>

test/unit-test/core_mqtt_utest.c

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7242,3 +7242,47 @@ void test_MQTT_InitStatefulQoS_callback_is_null( void )
72427242
TEST_ASSERT_EQUAL( MQTTBadParameter, mqttStatus );
72437243
}
72447244
/* ========================================================================== */
7245+
7246+
void test_MQTT_GetBytesInMQTTVec( void )
7247+
{
7248+
TransportOutVector_t pTransportArray[10] = {
7249+
{.iov_base = NULL, .iov_len = 1 },
7250+
{.iov_base = NULL, .iov_len = 2 },
7251+
{.iov_base = NULL, .iov_len = 3 },
7252+
{.iov_base = NULL, .iov_len = 4 },
7253+
{.iov_base = NULL, .iov_len = 5 },
7254+
{.iov_base = NULL, .iov_len = 6 },
7255+
{.iov_base = NULL, .iov_len = 7 },
7256+
{.iov_base = NULL, .iov_len = 8 },
7257+
{.iov_base = NULL, .iov_len = 9 },
7258+
{.iov_base = NULL, .iov_len = 10 },
7259+
};
7260+
7261+
size_t ret = MQTT_GetBytesInMQTTVec( (MQTTVec_t*)pTransportArray, 10);
7262+
7263+
TEST_ASSERT_EQUAL(55, ret);
7264+
}
7265+
/* ========================================================================== */
7266+
7267+
void test_MQTT_SerializeMQTTVec( void )
7268+
{
7269+
TransportOutVector_t pTransportArray[10] = {
7270+
{.iov_base = "T", .iov_len = 1 },
7271+
{.iov_base = "hi", .iov_len = 2 },
7272+
{.iov_base = "s i", .iov_len = 3 },
7273+
{.iov_base = "s a ", .iov_len = 4 },
7274+
{.iov_base = "coreM", .iov_len = 5 },
7275+
{.iov_base = "QTT un", .iov_len = 6 },
7276+
{.iov_base = "it test", .iov_len = 7 },
7277+
{.iov_base = " string.", .iov_len = 8 },
7278+
{.iov_base = "USER SHOU", .iov_len = 9 },
7279+
{.iov_base = "LDNT USE IT", .iov_len = 10 },
7280+
};
7281+
7282+
uint8_t array[60] = {0};
7283+
MQTT_SerializeMQTTVec(array, (MQTTVec_t*)pTransportArray, 10 );
7284+
7285+
TEST_ASSERT_EQUAL_MEMORY("This is a coreMQTT unit test string.USER SHOULDNT USE IT", array, 55);
7286+
TEST_ASSERT_EQUAL_MEMORY("\0\0\0\0\0", &array[55], 5);
7287+
7288+
}

0 commit comments

Comments
 (0)