blob: d07dc1bffc8ffc93ecfc347fb261a2508b7e946a [file] [log] [blame]
Ed Tanouse1452be2021-10-04 17:03:52 -07001#include "async_resolve.hpp"
2
3#include <boost/asio/ip/tcp.hpp>
4
Ed Tanousf0b59af2024-03-20 13:38:04 -07005#include <gtest/gtest.h>
Ed Tanouse1452be2021-10-04 17:03:52 -07006
7TEST(AsyncResolve, ipv4Positive)
8{
9 boost::asio::ip::tcp::endpoint ep;
10 ASSERT_TRUE(async_resolve::endpointFromResolveTuple({1, 2, 3, 4}, ep));
11 EXPECT_TRUE(ep.address().is_v4());
12 EXPECT_FALSE(ep.address().is_v6());
13
14 EXPECT_EQ(ep.address().to_string(), "1.2.3.4");
15}
16
17TEST(AsyncResolve, ipv6Positive)
18{
19 boost::asio::ip::tcp::endpoint ep;
20 ASSERT_TRUE(async_resolve::endpointFromResolveTuple(
21 {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}, ep));
22 EXPECT_FALSE(ep.address().is_v4());
23 EXPECT_TRUE(ep.address().is_v6());
24 EXPECT_EQ(ep.address().to_string(), "102:304:506:708:90a:b0c:d0e:f10");
25}