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