xref: /openbmc/bmcweb/test/include/async_resolve_test.cpp (revision 40e9b92ec19acffb46f83a6e55b18974da5d708e)
1 // SPDX-License-Identifier: Apache-2.0
2 // SPDX-FileCopyrightText: Copyright OpenBMC Authors
3 #include "async_resolve.hpp"
4 
5 #include <boost/asio/ip/tcp.hpp>
6 
7 #include <gtest/gtest.h>
8 
TEST(AsyncResolve,ipv4Positive)9 TEST(AsyncResolve, ipv4Positive)
10 {
11     boost::asio::ip::tcp::endpoint ep;
12     ASSERT_TRUE(async_resolve::endpointFromResolveTuple({1, 2, 3, 4}, ep));
13     EXPECT_TRUE(ep.address().is_v4());
14     EXPECT_FALSE(ep.address().is_v6());
15 
16     EXPECT_EQ(ep.address().to_string(), "1.2.3.4");
17 }
18 
TEST(AsyncResolve,ipv6Positive)19 TEST(AsyncResolve, ipv6Positive)
20 {
21     boost::asio::ip::tcp::endpoint ep;
22     ASSERT_TRUE(async_resolve::endpointFromResolveTuple(
23         {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}, ep));
24     EXPECT_FALSE(ep.address().is_v4());
25     EXPECT_TRUE(ep.address().is_v6());
26     EXPECT_EQ(ep.address().to_string(), "102:304:506:708:90a:b0c:d0e:f10");
27 }
28