|
@@ -3,13 +3,17 @@
|
|
|
* Company: Lynar Studios
|
|
|
* E-Mail: webmaster@lynarstudios.com
|
|
|
* Created: 2020-11-18
|
|
|
- * Changed: 2022-11-18
|
|
|
+ * Changed: 2022-12-09
|
|
|
*
|
|
|
* */
|
|
|
|
|
|
#include <gtest/gtest.h>
|
|
|
#include <ls_std/ls_std_network.hpp>
|
|
|
|
|
|
+#if defined(unix) || defined(__APPLE__)
|
|
|
+#include <sys/socket.h>
|
|
|
+#endif
|
|
|
+
|
|
|
using namespace ls::std::network;
|
|
|
|
|
|
namespace
|
|
@@ -26,6 +30,20 @@ namespace
|
|
|
|
|
|
void TearDown() override
|
|
|
{}
|
|
|
+
|
|
|
+ static SocketAddressMapperParameter createSocketAddressMapperParameter()
|
|
|
+ {
|
|
|
+ SocketAddressMapperParameter parameter{};
|
|
|
+ parameter.protocolFamilyType = ProtocolFamilyType::PROTOCOL_FAMILY_TYPE_IPV4;
|
|
|
+
|
|
|
+ SocketAddress socketAddress{};
|
|
|
+ socketAddress.port = 8080;
|
|
|
+ socketAddress.protocolType = PROTOCOL_TYPE_TCP;
|
|
|
+ socketAddress.ipAddress = "127.0.0.1";
|
|
|
+ parameter.socketAddress = socketAddress;
|
|
|
+
|
|
|
+ return parameter;
|
|
|
+ }
|
|
|
};
|
|
|
|
|
|
TEST_F(SocketAddressMapperTest, getClassName)
|
|
@@ -35,9 +53,12 @@ namespace
|
|
|
|
|
|
TEST_F(SocketAddressMapperTest, from)
|
|
|
{
|
|
|
- SocketAddressMapperParameter parameter{};
|
|
|
- parameter.protocolFamilyType = ProtocolFamilyType::PROTOCOL_FAMILY_TYPE_IPV4;
|
|
|
+ ConvertedSocketAddress convertedSocketAddress = SocketAddressMapper::from(createSocketAddressMapperParameter());
|
|
|
|
|
|
- ConvertedSocketAddress convertedSocketAddress = SocketAddressMapper::from();
|
|
|
+ #if defined(unix) || defined(__APPLE__)
|
|
|
+ ASSERT_EQ(36895, convertedSocketAddress.socketAddressUnix.sin_port); // expected: return value of htons()
|
|
|
+ ASSERT_EQ(AF_INET, convertedSocketAddress.socketAddressUnix.sin_family);
|
|
|
+ ASSERT_EQ(16777343, convertedSocketAddress.socketAddressUnix.sin_addr.s_addr); // expected: return value of inet_aton()
|
|
|
+ #endif
|
|
|
}
|
|
|
}
|