From 4c44952c805f36f62c2b3083b99a19e42c99e469 Mon Sep 17 00:00:00 2001 From: AniruddhaKanhere <60444055+AniruddhaKanhere@users.noreply.github.com> Date: Tue, 22 Oct 2024 03:26:42 +0000 Subject: [PATCH] Add UT and fix size_table --- docs/doxygen/include/size_table.md | 8 +++--- test/unit-test/core_mqtt_utest.c | 44 ++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/docs/doxygen/include/size_table.md b/docs/doxygen/include/size_table.md index 5f654632..23f7fbdc 100644 --- a/docs/doxygen/include/size_table.md +++ b/docs/doxygen/include/size_table.md @@ -9,8 +9,8 @@ core_mqtt.c -
4.9K
-
4.2K
+
5.0K
+
4.3K
core_mqtt_state.c @@ -24,7 +24,7 @@ Total estimates -
9.5K
-
7.8K
+
9.6K
+
7.9K
diff --git a/test/unit-test/core_mqtt_utest.c b/test/unit-test/core_mqtt_utest.c index 0f7f1442..97d1a024 100644 --- a/test/unit-test/core_mqtt_utest.c +++ b/test/unit-test/core_mqtt_utest.c @@ -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); + +} \ No newline at end of file