Toolbox snapshot
The Reactive C++ Toolbox
Loading...
Searching...
No Matches
Resolver.ut.cpp
Go to the documentation of this file.
1// The Reactive C++ Toolbox.
2// Copyright (C) 2013-2019 Swirly Cloud Limited
3// Copyright (C) 2021 Reactive Markets Limited
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16
17#include "Resolver.hpp"
18
19#include "Endpoint.hpp"
20
23
24#include <boost/test/unit_test.hpp>
25
26using namespace std;
27using namespace toolbox;
28
30
32{
34 const auto uri1 = "tcp4://192.168.1.3:443"s;
35 const auto uri2 = "tcp6://[fe80::c8bf:7d86:cbdc:bda9]:443"s;
36 const auto uri3 = "unix:///tmp/foo.sock"s;
38 auto future2 = res.resolve(uri2, SOCK_STREAM);
39 auto future3 = res.resolve(uri3, SOCK_STREAM);
40 BOOST_CHECK(res.run());
42 BOOST_CHECK(res.run());
44 BOOST_CHECK(res.run());
46
47 auto future4 = res.resolve("bad://foo", SOCK_STREAM);
48 BOOST_CHECK(res.run());
49 BOOST_CHECK_THROW(future4.get(), invalid_argument);
50
51 auto future5 = res.resolve(uri1, SOCK_STREAM);
52 auto future6 = res.resolve(uri2, SOCK_STREAM);
53 res.clear();
54 // Broken promises.
57}
58
60{
62
64 Runner resolver_runner{res, "resolver"s};
65
66 const auto uri1 = "tcp4://192.168.1.3:443"s;
67 const auto uri2 = "tcp6://[fe80::c8bf:7d86:cbdc:bda9]:443"s;
68 const auto uri3 = "unix:///tmp/foo.sock"s;
69 auto future1 = res.resolve(uri1, SOCK_STREAM);
70 auto future2 = res.resolve(uri2, SOCK_STREAM);
71 auto future3 = res.resolve(uri3, SOCK_STREAM);
72
76}
77
BOOST_CHECK_EQUAL(v.size(), 10U)
BOOST_AUTO_TEST_CASE(ResolverCase)
AddrInfoFuture resolve(std::string uri, int type)
Schedule a URI socket name resolution.
Definition Resolver.cpp:40
STL namespace.
std::string to_string(ValueT &&val)
Definition String.hpp:54
constexpr auto bind() noexcept
Definition Slot.hpp:92
BOOST_CHECK(isnan(stod(""sv, numeric_limits< double >::quiet_NaN())))