]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/experimental/net/internet/address/v4/members.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" }
19 // { dg-add-options net_ts }
21 #include <experimental/internet>
22 #include <testsuite_hooks.h>
24 using std::experimental::net::ip::address_v4
;
29 bool test
__attribute__((unused
)) = false;
32 VERIFY( a
.is_unspecified() );
34 a
= address_v4::any();
35 VERIFY( a
.is_unspecified() );
37 a
= address_v4::loopback();
38 VERIFY( !a
.is_unspecified() );
40 a
= address_v4::broadcast();
41 VERIFY( !a
.is_unspecified() );
47 bool test
__attribute__((unused
)) = false;
49 auto a
= address_v4::loopback();
50 VERIFY( a
.is_loopback() );
52 a
= address_v4
{0x7F000001};
53 VERIFY( a
.is_loopback() );
55 a
= address_v4
{0x7F010203};
56 VERIFY( a
.is_loopback() );
58 a
= address_v4
{0x7FFFFFFF};
59 VERIFY( a
.is_loopback() );
61 a
= address_v4::any();
62 VERIFY( !a
.is_loopback() );
64 a
= address_v4::broadcast();
65 VERIFY( !a
.is_loopback() );
71 bool test
__attribute__((unused
)) = false;
73 auto a
= address_v4
{0xE0000001};
74 VERIFY( a
.is_multicast() );
76 a
= address_v4
{0xE0010203};
77 VERIFY( a
.is_multicast() );
79 a
= address_v4
{0xE0FFFFFF};
80 VERIFY( a
.is_multicast() );
82 a
= address_v4
{0xF0000000};
83 VERIFY( !a
.is_multicast() );
85 a
= address_v4
{0xDFFFFFFF};
86 VERIFY( !a
.is_multicast() );
92 bool test
__attribute__((unused
)) = false;
94 VERIFY( address_v4::any().to_string() == "0.0.0.0" );
95 VERIFY( address_v4::loopback().to_string() == "127.0.0.1" );
96 VERIFY( address_v4::broadcast().to_string() == "255.255.255.255" );
102 bool test
__attribute__((unused
)) = false;
104 std::ostringstream ss
;
105 ss
<< address_v4::any() << ' ' << address_v4::loopback() << ' '
106 << address_v4::broadcast();
107 VERIFY( ss
.str() == "0.0.0.0 127.0.0.1 255.255.255.255" );