32 #include <gtest/gtest.h>
46 TEST(inetaddr_test, Bad_addr)
49 ASSERT_ANY_THROW(sa.
host(
"deadbeef"));
52 TEST(inetaddr_test, init_addr)
56 ASSERT_EQ(sa.
host(),
"::");
57 ASSERT_EQ(sa.
port(), 0);
63 TEST(inetaddr_test, any_addrs)
66 sa.
host(
"::ffff:0.0.0.0");
68 ASSERT_EQ(sa.
host(),
"::ffff:0.0.0.0");
74 ASSERT_EQ(sa.
host(),
"::");
78 TEST(inetaddr_test, loop_addrs)
81 sa.
host(
"::ffff:127.0.0.1");
83 ASSERT_EQ(sa.
host(),
"::ffff:127.0.0.1");
89 ASSERT_EQ(sa.
host(),
"::1");
93 TEST(inetaddr_test, unicast_global)
96 sa.
host(
"::ffff:192.168.12.24");
98 ASSERT_EQ(sa.
host(),
"::ffff:192.168.12.24");
102 sa.
host(
"dead::beef:feed");
104 ASSERT_EQ(sa.
host(),
"dead::beef:feed");
108 TEST(inetaddr_test, unicast_link)
111 sa.
host(
"fe80::dead:beef");
113 ASSERT_EQ(sa.
host(),
"fe80::dead:beef");
117 TEST(inetaddr_test, unicast_site)
120 sa.
host(
"fd00::dead:beef");
122 ASSERT_EQ(sa.
host(),
"fd00::dead:beef");
127 TEST(inetaddr_test, multicast_ipv4)
130 sa.
host(
"::ffff:224.1.2.3");
135 sa.
host(
"::ffff:239.1.2.3");
140 sa.
host(
"::ffff:223.1.2.3");
145 sa.
host(
"::ffff:240.1.2.3");
150 TEST(inetaddr_test, multicast_ipv6)
178 sa.
host(
"ff18::dead:beef");
182 sa.
host(
"ff03::dead:beef");
bool test_flags(int f) const
Test if flags are set in this address.
unsigned port() const
Get the port.
void scope_id(uint32_t)
Set the scope id of the address.
virtual std::string host() const
Get host.
InetAddrFlag
Internet address flags.
@ unicast
Unicast address.
@ link_local
Traffic is restricted to the local link.
@ realm_local
Traffic is restricted to the local realm.
@ mcast_all_nodes
Reaches all nodes in the scope, e.g. ff0X::1.
@ global
Global traffic is allowed.
@ org_local
Traffic is restricted to the local organization.
@ mcast_all_routers
Reaches all routers in the scope, e.g. ff0X::2.
@ loopback
Loopback address.
@ if_local
Traffic is restricted to the local interface.
@ mcast_dynamic
Dynamic (temporary) address, otherwise permanent (assigned).
@ site_local
Traffic is restricted to the local site.
@ multicast
Multicast address.
@ unique_local_address
Address which can be used freely within a site: e.g. fd00::/8.
Internet tcp and udp networking.
TEST(inet_example, client_server_stream_test)
[Inet client server]