本文整理汇总了C++中IPAddress::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ IPAddress::empty方法的具体用法?C++ IPAddress::empty怎么用?C++ IPAddress::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPAddress
的用法示例。
在下文中一共展示了IPAddress::empty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sizeof
// tests code example
TEST(IPAddress, CodeExample) {
EXPECT_EQ(4, sizeof(IPAddressV4));
EXPECT_EQ(20, sizeof(IPAddressV6));
EXPECT_EQ(24, sizeof(IPAddress));
IPAddress uninitaddr;
IPAddress v4addr("192.0.2.129");
IPAddress v6map("::ffff:192.0.2.129");
ASSERT_TRUE(uninitaddr.empty());
ASSERT_FALSE(v4addr.empty());
ASSERT_FALSE(v6map.empty());
EXPECT_TRUE(v4addr.inSubnet("192.0.2.0/24"));
EXPECT_TRUE(v4addr.inSubnet(IPAddress("192.0.2.0"), 24));
EXPECT_TRUE(v4addr.inSubnet("192.0.2.128/30"));
EXPECT_FALSE(v4addr.inSubnet("192.0.2.128/32"));
EXPECT_EQ(2164392128, v4addr.asV4().toLong());
EXPECT_EQ(3221226113, v4addr.asV4().toLongHBO());
ASSERT_FALSE(uninitaddr.isV4());
ASSERT_FALSE(uninitaddr.isV6());
ASSERT_TRUE(v4addr.isV4());
ASSERT_TRUE(v6map.isV6());
EXPECT_TRUE(v4addr == v6map);
ASSERT_TRUE(v6map.isIPv4Mapped());
EXPECT_TRUE(v4addr.asV4() == IPAddress::createIPv4(v6map));
EXPECT_TRUE(IPAddress::createIPv6(v4addr) == v6map.asV6());
}