]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/experimental/net/internet/resolver/ops/lookup.cc
1 // Copyright (C) 2015-2018 Free Software Foundation, Inc.
3 // This file is part of the GNU ISO C++ Library. This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 3, or (at your option)
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING3. If not see
16 // <http://www.gnu.org/licenses/>.
18 // { dg-options "-std=gnu++14" }
20 #include <experimental/internet>
21 #include <testsuite_hooks.h>
23 using namespace std::experimental::net
;
28 bool test
__attribute__((unused
)) = false;
32 ip::tcp::resolver
resolv(ctx
);
33 auto addrs
= resolv
.resolve("localhost", "http", ec
);
35 VERIFY( addrs
.size() > 0 );
36 VERIFY( addrs
.begin() != addrs
.end() );
37 VERIFY( ! addrs
.empty() );
39 auto addrs2
= resolv
.resolve("localhost", "http");
40 VERIFY( addrs
== addrs2
);
46 bool test
__attribute__((unused
)) = false;
50 ip::tcp::resolver
resolv(ctx
);
51 auto flags
= ip::resolver_base::numeric_host
| ip::tcp::resolver::numeric_service
;
52 auto addrs
= resolv
.resolve("127.0.0.1", "42", flags
, ec
);
54 VERIFY( addrs
.size() > 0 );
55 VERIFY( addrs
.begin() != addrs
.end() );
57 auto addrs2
= resolv
.resolve("127.0.0.1", "42", flags
);
58 VERIFY( addrs
== addrs2
);
60 addrs
= resolv
.resolve("localhost", "42", flags
, ec
);
62 VERIFY( addrs
.empty() );
63 addrs
= resolv
.resolve("127.0.0.1", "nameserver", flags
, ec
);
65 VERIFY( addrs
.empty() );
70 resolv
.resolve("localhost", "http", flags
);
71 } catch (const std::system_error
& e
) {
73 VERIFY( e
.code() == ec
);
82 bool test
__attribute__((unused
)) = false;
86 ip::tcp::resolver
resolv(ctx
);
87 auto addrs
= resolv
.resolve("test.invalid", "http", ec
);
89 VERIFY( addrs
.size() == 0 );
90 VERIFY( addrs
.begin() == addrs
.end() );
91 VERIFY( addrs
.empty() );
95 resolv
.resolve("test.invalid", "http");
96 } catch (const std::system_error
& e
) {
98 VERIFY( e
.code() == ec
);