diff options
Diffstat (limited to 'unittests/Host/SocketAddressTest.cpp')
-rw-r--r-- | unittests/Host/SocketAddressTest.cpp | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/unittests/Host/SocketAddressTest.cpp b/unittests/Host/SocketAddressTest.cpp index 3c18137ac063..17f9ccc19028 100644 --- a/unittests/Host/SocketAddressTest.cpp +++ b/unittests/Host/SocketAddressTest.cpp @@ -12,8 +12,21 @@ #include "lldb/Host/SocketAddress.h" namespace { -class SocketAddressTest : public ::testing::Test {}; -} +class SocketAddressTest : public testing::Test { +public: + static void SetUpTestCase() { +#ifdef _MSC_VER + WSADATA data; + ASSERT_EQ(0, WSAStartup(MAKEWORD(2, 2), &data)); +#endif + } + static void TearDownTestCase() { +#ifdef _MSC_VER + ASSERT_EQ(0, WSACleanup()); +#endif + } +}; +} // namespace using namespace lldb_private; @@ -34,6 +47,14 @@ TEST_F(SocketAddressTest, Set) { ASSERT_EQ(1139, sa.GetPort()); } +TEST_F(SocketAddressTest, GetAddressInfo) { + auto addr = SocketAddress::GetAddressInfo("127.0.0.1", nullptr, AF_UNSPEC, + SOCK_STREAM, IPPROTO_TCP); + ASSERT_EQ(1u, addr.size()); + EXPECT_EQ(AF_INET, addr[0].GetFamily()); + EXPECT_EQ("127.0.0.1", addr[0].GetIPAddress()); +} + #ifdef _WIN32 // we need to test our inet_ntop implementation for Windows XP |