Add strerror unit test to HTTP for 100% branch, function and line coverage.
@@ -1342,4 +1342,81 @@ void test_Http_ReadHeader_Happy_Path()
TEST_ASSERT_EQUAL( headerValInRespLen, valueLen );
}
+/**
+ * @brief Test HTTPClient_strerror returns correct strings.
+ */
+void test_HTTPClient_strerror( void )
+{
+ HTTPStatus_t status;
+ const char * str = NULL;
+
+ status = HTTP_SUCCESS;
+ str = HTTPClient_strerror( status );
+ TEST_ASSERT_EQUAL_STRING( "HTTP_SUCCESS", str );
+
+ status = HTTP_INVALID_PARAMETER;
+ str = HTTPClient_strerror( status );
+ TEST_ASSERT_EQUAL_STRING( "HTTP_INVALID_PARAMETER", str );
+
+ status = HTTP_NETWORK_ERROR;
+ str = HTTPClient_strerror( status );
+ TEST_ASSERT_EQUAL_STRING( "HTTP_NETWORK_ERROR", str );
+
+ status = HTTP_PARTIAL_RESPONSE;
+ str = HTTPClient_strerror( status );
+ TEST_ASSERT_EQUAL_STRING( "HTTP_PARTIAL_RESPONSE", str );
+
+ status = HTTP_NO_RESPONSE;
+ str = HTTPClient_strerror( status );
+ TEST_ASSERT_EQUAL_STRING( "HTTP_NO_RESPONSE", str );
+
+ status = HTTP_INSUFFICIENT_MEMORY;
+ str = HTTPClient_strerror( status );
+ TEST_ASSERT_EQUAL_STRING( "HTTP_INSUFFICIENT_MEMORY", str );
+
+ status = HTTP_SECURITY_ALERT_RESPONSE_HEADERS_SIZE_LIMIT_EXCEEDED;
+ str = HTTPClient_strerror( status );
+ TEST_ASSERT_EQUAL_STRING( "HTTP_SECURITY_ALERT_RESPONSE_HEADERS_SIZE_LIMIT_EXCEEDED", str );
+
+ status = HTTP_SECURITY_ALERT_EXTRANEOUS_RESPONSE_DATA;
+ str = HTTPClient_strerror( status );
+ TEST_ASSERT_EQUAL_STRING( "HTTP_SECURITY_ALERT_EXTRANEOUS_RESPONSE_DATA", str );
+
+ status = HTTP_SECURITY_ALERT_INVALID_CHUNK_HEADER;
+ str = HTTPClient_strerror( status );
+ TEST_ASSERT_EQUAL_STRING( "HTTP_SECURITY_ALERT_INVALID_CHUNK_HEADER", str );
+
+ status = HTTP_SECURITY_ALERT_INVALID_PROTOCOL_VERSION;
+ str = HTTPClient_strerror( status );
+ TEST_ASSERT_EQUAL_STRING( "HTTP_SECURITY_ALERT_INVALID_PROTOCOL_VERSION", str );
+
+ status = HTTP_SECURITY_ALERT_INVALID_STATUS_CODE;
+ str = HTTPClient_strerror( status );
+ TEST_ASSERT_EQUAL_STRING( "HTTP_SECURITY_ALERT_INVALID_STATUS_CODE", str );
+
+ status = HTTP_SECURITY_ALERT_INVALID_CHARACTER;
+ str = HTTPClient_strerror( status );
+ TEST_ASSERT_EQUAL_STRING( "HTTP_SECURITY_ALERT_INVALID_CHARACTER", str );
+
+ status = HTTP_SECURITY_ALERT_INVALID_CONTENT_LENGTH;
+ str = HTTPClient_strerror( status );
+ TEST_ASSERT_EQUAL_STRING( "HTTP_SECURITY_ALERT_INVALID_CONTENT_LENGTH", str );
+
+ status = HTTP_PARSER_INTERNAL_ERROR;
+ str = HTTPClient_strerror( status );
+ TEST_ASSERT_EQUAL_STRING( "HTTP_PARSER_INTERNAL_ERROR", str );
+
+ status = HTTP_HEADER_NOT_FOUND;
+ str = HTTPClient_strerror( status );
+ TEST_ASSERT_EQUAL_STRING( "HTTP_HEADER_NOT_FOUND", str );
+
+ status = HTTP_INVALID_RESPONSE;
+ str = HTTPClient_strerror( status );
+ TEST_ASSERT_EQUAL_STRING( "HTTP_INVALID_RESPONSE", str );
+
+ status = HTTP_INVALID_RESPONSE + 1;
+ str = HTTPClient_strerror( status );
+ TEST_ASSERT_EQUAL_STRING( NULL, str );
+}
+
/* ========================================================================== */
