@ -21,6 +21,13 @@ static CNetAddr ResolveIP(const char* ip)
return addr ;
return addr ;
}
}
static CSubNet ResolveSubNet ( const char * subnet )
{
CSubNet ret ;
LookupSubNet ( subnet , ret ) ;
return ret ;
}
BOOST_AUTO_TEST_CASE ( netbase_networks )
BOOST_AUTO_TEST_CASE ( netbase_networks )
{
{
BOOST_CHECK ( ResolveIP ( " 127.0.0.1 " ) . GetNetwork ( ) = = NET_UNROUTABLE ) ;
BOOST_CHECK ( ResolveIP ( " 127.0.0.1 " ) . GetNetwork ( ) = = NET_UNROUTABLE ) ;
@ -119,44 +126,44 @@ BOOST_AUTO_TEST_CASE(onioncat_test)
BOOST_AUTO_TEST_CASE ( subnet_test )
BOOST_AUTO_TEST_CASE ( subnet_test )
{
{
BOOST_CHECK ( C SubNet( " 1.2.3.0/24 " ) = = C SubNet( " 1.2.3.0/255.255.255.0 " ) ) ;
BOOST_CHECK ( Resolve SubNet( " 1.2.3.0/24 " ) = = Resolve SubNet( " 1.2.3.0/255.255.255.0 " ) ) ;
BOOST_CHECK ( C SubNet( " 1.2.3.0/24 " ) ! = C SubNet( " 1.2.4.0/255.255.255.0 " ) ) ;
BOOST_CHECK ( Resolve SubNet( " 1.2.3.0/24 " ) ! = Resolve SubNet( " 1.2.4.0/255.255.255.0 " ) ) ;
BOOST_CHECK ( C SubNet( " 1.2.3.0/24 " ) . Match ( ResolveIP ( " 1.2.3.4 " ) ) ) ;
BOOST_CHECK ( Resolve SubNet( " 1.2.3.0/24 " ) . Match ( ResolveIP ( " 1.2.3.4 " ) ) ) ;
BOOST_CHECK ( ! C SubNet( " 1.2.2.0/24 " ) . Match ( ResolveIP ( " 1.2.3.4 " ) ) ) ;
BOOST_CHECK ( ! Resolve SubNet( " 1.2.2.0/24 " ) . Match ( ResolveIP ( " 1.2.3.4 " ) ) ) ;
BOOST_CHECK ( C SubNet( " 1.2.3.4 " ) . Match ( ResolveIP ( " 1.2.3.4 " ) ) ) ;
BOOST_CHECK ( Resolve SubNet( " 1.2.3.4 " ) . Match ( ResolveIP ( " 1.2.3.4 " ) ) ) ;
BOOST_CHECK ( C SubNet( " 1.2.3.4/32 " ) . Match ( ResolveIP ( " 1.2.3.4 " ) ) ) ;
BOOST_CHECK ( Resolve SubNet( " 1.2.3.4/32 " ) . Match ( ResolveIP ( " 1.2.3.4 " ) ) ) ;
BOOST_CHECK ( ! C SubNet( " 1.2.3.4 " ) . Match ( ResolveIP ( " 5.6.7.8 " ) ) ) ;
BOOST_CHECK ( ! Resolve SubNet( " 1.2.3.4 " ) . Match ( ResolveIP ( " 5.6.7.8 " ) ) ) ;
BOOST_CHECK ( ! C SubNet( " 1.2.3.4/32 " ) . Match ( ResolveIP ( " 5.6.7.8 " ) ) ) ;
BOOST_CHECK ( ! Resolve SubNet( " 1.2.3.4/32 " ) . Match ( ResolveIP ( " 5.6.7.8 " ) ) ) ;
BOOST_CHECK ( C SubNet( " ::ffff:127.0.0.1 " ) . Match ( ResolveIP ( " 127.0.0.1 " ) ) ) ;
BOOST_CHECK ( Resolve SubNet( " ::ffff:127.0.0.1 " ) . Match ( ResolveIP ( " 127.0.0.1 " ) ) ) ;
BOOST_CHECK ( C SubNet( " 1:2:3:4:5:6:7:8 " ) . Match ( ResolveIP ( " 1:2:3:4:5:6:7:8 " ) ) ) ;
BOOST_CHECK ( Resolve SubNet( " 1:2:3:4:5:6:7:8 " ) . Match ( ResolveIP ( " 1:2:3:4:5:6:7:8 " ) ) ) ;
BOOST_CHECK ( ! C SubNet( " 1:2:3:4:5:6:7:8 " ) . Match ( ResolveIP ( " 1:2:3:4:5:6:7:9 " ) ) ) ;
BOOST_CHECK ( ! Resolve SubNet( " 1:2:3:4:5:6:7:8 " ) . Match ( ResolveIP ( " 1:2:3:4:5:6:7:9 " ) ) ) ;
BOOST_CHECK ( C SubNet( " 1:2:3:4:5:6:7:0/112 " ) . Match ( ResolveIP ( " 1:2:3:4:5:6:7:1234 " ) ) ) ;
BOOST_CHECK ( Resolve SubNet( " 1:2:3:4:5:6:7:0/112 " ) . Match ( ResolveIP ( " 1:2:3:4:5:6:7:1234 " ) ) ) ;
BOOST_CHECK ( C SubNet( " 192.168.0.1/24 " ) . Match ( ResolveIP ( " 192.168.0.2 " ) ) ) ;
BOOST_CHECK ( Resolve SubNet( " 192.168.0.1/24 " ) . Match ( ResolveIP ( " 192.168.0.2 " ) ) ) ;
BOOST_CHECK ( C SubNet( " 192.168.0.20/29 " ) . Match ( ResolveIP ( " 192.168.0.18 " ) ) ) ;
BOOST_CHECK ( Resolve SubNet( " 192.168.0.20/29 " ) . Match ( ResolveIP ( " 192.168.0.18 " ) ) ) ;
BOOST_CHECK ( C SubNet( " 1.2.2.1/24 " ) . Match ( ResolveIP ( " 1.2.2.4 " ) ) ) ;
BOOST_CHECK ( Resolve SubNet( " 1.2.2.1/24 " ) . Match ( ResolveIP ( " 1.2.2.4 " ) ) ) ;
BOOST_CHECK ( C SubNet( " 1.2.2.110/31 " ) . Match ( ResolveIP ( " 1.2.2.111 " ) ) ) ;
BOOST_CHECK ( Resolve SubNet( " 1.2.2.110/31 " ) . Match ( ResolveIP ( " 1.2.2.111 " ) ) ) ;
BOOST_CHECK ( C SubNet( " 1.2.2.20/26 " ) . Match ( ResolveIP ( " 1.2.2.63 " ) ) ) ;
BOOST_CHECK ( Resolve SubNet( " 1.2.2.20/26 " ) . Match ( ResolveIP ( " 1.2.2.63 " ) ) ) ;
// All-Matching IPv6 Matches arbitrary IPv4 and IPv6
// All-Matching IPv6 Matches arbitrary IPv4 and IPv6
BOOST_CHECK ( C SubNet( " ::/0 " ) . Match ( ResolveIP ( " 1:2:3:4:5:6:7:1234 " ) ) ) ;
BOOST_CHECK ( Resolve SubNet( " ::/0 " ) . Match ( ResolveIP ( " 1:2:3:4:5:6:7:1234 " ) ) ) ;
BOOST_CHECK ( C SubNet( " ::/0 " ) . Match ( ResolveIP ( " 1.2.3.4 " ) ) ) ;
BOOST_CHECK ( Resolve SubNet( " ::/0 " ) . Match ( ResolveIP ( " 1.2.3.4 " ) ) ) ;
// All-Matching IPv4 does not Match IPv6
// All-Matching IPv4 does not Match IPv6
BOOST_CHECK ( ! C SubNet( " 0.0.0.0/0 " ) . Match ( ResolveIP ( " 1:2:3:4:5:6:7:1234 " ) ) ) ;
BOOST_CHECK ( ! Resolve SubNet( " 0.0.0.0/0 " ) . Match ( ResolveIP ( " 1:2:3:4:5:6:7:1234 " ) ) ) ;
// Invalid subnets Match nothing (not even invalid addresses)
// Invalid subnets Match nothing (not even invalid addresses)
BOOST_CHECK ( ! CSubNet ( ) . Match ( ResolveIP ( " 1.2.3.4 " ) ) ) ;
BOOST_CHECK ( ! CSubNet ( ) . Match ( ResolveIP ( " 1.2.3.4 " ) ) ) ;
BOOST_CHECK ( ! C SubNet( " " ) . Match ( ResolveIP ( " 4.5.6.7 " ) ) ) ;
BOOST_CHECK ( ! Resolve SubNet( " " ) . Match ( ResolveIP ( " 4.5.6.7 " ) ) ) ;
BOOST_CHECK ( ! C SubNet( " bloop " ) . Match ( ResolveIP ( " 0.0.0.0 " ) ) ) ;
BOOST_CHECK ( ! Resolve SubNet( " bloop " ) . Match ( ResolveIP ( " 0.0.0.0 " ) ) ) ;
BOOST_CHECK ( ! C SubNet( " bloop " ) . Match ( ResolveIP ( " hab " ) ) ) ;
BOOST_CHECK ( ! Resolve SubNet( " bloop " ) . Match ( ResolveIP ( " hab " ) ) ) ;
// Check valid/invalid
// Check valid/invalid
BOOST_CHECK ( C SubNet( " 1.2.3.0/0 " ) . IsValid ( ) ) ;
BOOST_CHECK ( Resolve SubNet( " 1.2.3.0/0 " ) . IsValid ( ) ) ;
BOOST_CHECK ( ! C SubNet( " 1.2.3.0/-1 " ) . IsValid ( ) ) ;
BOOST_CHECK ( ! Resolve SubNet( " 1.2.3.0/-1 " ) . IsValid ( ) ) ;
BOOST_CHECK ( C SubNet( " 1.2.3.0/32 " ) . IsValid ( ) ) ;
BOOST_CHECK ( Resolve SubNet( " 1.2.3.0/32 " ) . IsValid ( ) ) ;
BOOST_CHECK ( ! C SubNet( " 1.2.3.0/33 " ) . IsValid ( ) ) ;
BOOST_CHECK ( ! Resolve SubNet( " 1.2.3.0/33 " ) . IsValid ( ) ) ;
BOOST_CHECK ( C SubNet( " 1:2:3:4:5:6:7:8/0 " ) . IsValid ( ) ) ;
BOOST_CHECK ( Resolve SubNet( " 1:2:3:4:5:6:7:8/0 " ) . IsValid ( ) ) ;
BOOST_CHECK ( C SubNet( " 1:2:3:4:5:6:7:8/33 " ) . IsValid ( ) ) ;
BOOST_CHECK ( Resolve SubNet( " 1:2:3:4:5:6:7:8/33 " ) . IsValid ( ) ) ;
BOOST_CHECK ( ! C SubNet( " 1:2:3:4:5:6:7:8/-1 " ) . IsValid ( ) ) ;
BOOST_CHECK ( ! Resolve SubNet( " 1:2:3:4:5:6:7:8/-1 " ) . IsValid ( ) ) ;
BOOST_CHECK ( C SubNet( " 1:2:3:4:5:6:7:8/128 " ) . IsValid ( ) ) ;
BOOST_CHECK ( Resolve SubNet( " 1:2:3:4:5:6:7:8/128 " ) . IsValid ( ) ) ;
BOOST_CHECK ( ! C SubNet( " 1:2:3:4:5:6:7:8/129 " ) . IsValid ( ) ) ;
BOOST_CHECK ( ! Resolve SubNet( " 1:2:3:4:5:6:7:8/129 " ) . IsValid ( ) ) ;
BOOST_CHECK ( ! C SubNet( " fuzzy " ) . IsValid ( ) ) ;
BOOST_CHECK ( ! Resolve SubNet( " fuzzy " ) . IsValid ( ) ) ;
//CNetAddr constructor test
//CNetAddr constructor test
BOOST_CHECK ( CSubNet ( ResolveIP ( " 127.0.0.1 " ) ) . IsValid ( ) ) ;
BOOST_CHECK ( CSubNet ( ResolveIP ( " 127.0.0.1 " ) ) . IsValid ( ) ) ;
@ -169,82 +176,82 @@ BOOST_AUTO_TEST_CASE(subnet_test)
BOOST_CHECK ( ! CSubNet ( ResolveIP ( " 1:2:3:4:5:6:7:8 " ) ) . Match ( ResolveIP ( " 1:2:3:4:5:6:7:9 " ) ) ) ;
BOOST_CHECK ( ! CSubNet ( ResolveIP ( " 1:2:3:4:5:6:7:8 " ) ) . Match ( ResolveIP ( " 1:2:3:4:5:6:7:9 " ) ) ) ;
BOOST_CHECK ( CSubNet ( ResolveIP ( " 1:2:3:4:5:6:7:8 " ) ) . ToString ( ) = = " 1:2:3:4:5:6:7:8/128 " ) ;
BOOST_CHECK ( CSubNet ( ResolveIP ( " 1:2:3:4:5:6:7:8 " ) ) . ToString ( ) = = " 1:2:3:4:5:6:7:8/128 " ) ;
CSubNet subnet = C SubNet( " 1.2.3.4/255.255.255.255 " ) ;
CSubNet subnet = Resolve SubNet( " 1.2.3.4/255.255.255.255 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1.2.3.4/32 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1.2.3.4/32 " ) ;
subnet = C SubNet( " 1.2.3.4/255.255.255.254 " ) ;
subnet = Resolve SubNet( " 1.2.3.4/255.255.255.254 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1.2.3.4/31 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1.2.3.4/31 " ) ;
subnet = C SubNet( " 1.2.3.4/255.255.255.252 " ) ;
subnet = Resolve SubNet( " 1.2.3.4/255.255.255.252 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1.2.3.4/30 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1.2.3.4/30 " ) ;
subnet = C SubNet( " 1.2.3.4/255.255.255.248 " ) ;
subnet = Resolve SubNet( " 1.2.3.4/255.255.255.248 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1.2.3.0/29 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1.2.3.0/29 " ) ;
subnet = C SubNet( " 1.2.3.4/255.255.255.240 " ) ;
subnet = Resolve SubNet( " 1.2.3.4/255.255.255.240 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1.2.3.0/28 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1.2.3.0/28 " ) ;
subnet = C SubNet( " 1.2.3.4/255.255.255.224 " ) ;
subnet = Resolve SubNet( " 1.2.3.4/255.255.255.224 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1.2.3.0/27 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1.2.3.0/27 " ) ;
subnet = C SubNet( " 1.2.3.4/255.255.255.192 " ) ;
subnet = Resolve SubNet( " 1.2.3.4/255.255.255.192 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1.2.3.0/26 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1.2.3.0/26 " ) ;
subnet = C SubNet( " 1.2.3.4/255.255.255.128 " ) ;
subnet = Resolve SubNet( " 1.2.3.4/255.255.255.128 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1.2.3.0/25 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1.2.3.0/25 " ) ;
subnet = C SubNet( " 1.2.3.4/255.255.255.0 " ) ;
subnet = Resolve SubNet( " 1.2.3.4/255.255.255.0 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1.2.3.0/24 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1.2.3.0/24 " ) ;
subnet = C SubNet( " 1.2.3.4/255.255.254.0 " ) ;
subnet = Resolve SubNet( " 1.2.3.4/255.255.254.0 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1.2.2.0/23 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1.2.2.0/23 " ) ;
subnet = C SubNet( " 1.2.3.4/255.255.252.0 " ) ;
subnet = Resolve SubNet( " 1.2.3.4/255.255.252.0 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1.2.0.0/22 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1.2.0.0/22 " ) ;
subnet = C SubNet( " 1.2.3.4/255.255.248.0 " ) ;
subnet = Resolve SubNet( " 1.2.3.4/255.255.248.0 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1.2.0.0/21 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1.2.0.0/21 " ) ;
subnet = C SubNet( " 1.2.3.4/255.255.240.0 " ) ;
subnet = Resolve SubNet( " 1.2.3.4/255.255.240.0 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1.2.0.0/20 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1.2.0.0/20 " ) ;
subnet = C SubNet( " 1.2.3.4/255.255.224.0 " ) ;
subnet = Resolve SubNet( " 1.2.3.4/255.255.224.0 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1.2.0.0/19 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1.2.0.0/19 " ) ;
subnet = C SubNet( " 1.2.3.4/255.255.192.0 " ) ;
subnet = Resolve SubNet( " 1.2.3.4/255.255.192.0 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1.2.0.0/18 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1.2.0.0/18 " ) ;
subnet = C SubNet( " 1.2.3.4/255.255.128.0 " ) ;
subnet = Resolve SubNet( " 1.2.3.4/255.255.128.0 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1.2.0.0/17 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1.2.0.0/17 " ) ;
subnet = C SubNet( " 1.2.3.4/255.255.0.0 " ) ;
subnet = Resolve SubNet( " 1.2.3.4/255.255.0.0 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1.2.0.0/16 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1.2.0.0/16 " ) ;
subnet = C SubNet( " 1.2.3.4/255.254.0.0 " ) ;
subnet = Resolve SubNet( " 1.2.3.4/255.254.0.0 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1.2.0.0/15 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1.2.0.0/15 " ) ;
subnet = C SubNet( " 1.2.3.4/255.252.0.0 " ) ;
subnet = Resolve SubNet( " 1.2.3.4/255.252.0.0 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1.0.0.0/14 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1.0.0.0/14 " ) ;
subnet = C SubNet( " 1.2.3.4/255.248.0.0 " ) ;
subnet = Resolve SubNet( " 1.2.3.4/255.248.0.0 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1.0.0.0/13 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1.0.0.0/13 " ) ;
subnet = C SubNet( " 1.2.3.4/255.240.0.0 " ) ;
subnet = Resolve SubNet( " 1.2.3.4/255.240.0.0 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1.0.0.0/12 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1.0.0.0/12 " ) ;
subnet = C SubNet( " 1.2.3.4/255.224.0.0 " ) ;
subnet = Resolve SubNet( " 1.2.3.4/255.224.0.0 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1.0.0.0/11 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1.0.0.0/11 " ) ;
subnet = C SubNet( " 1.2.3.4/255.192.0.0 " ) ;
subnet = Resolve SubNet( " 1.2.3.4/255.192.0.0 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1.0.0.0/10 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1.0.0.0/10 " ) ;
subnet = C SubNet( " 1.2.3.4/255.128.0.0 " ) ;
subnet = Resolve SubNet( " 1.2.3.4/255.128.0.0 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1.0.0.0/9 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1.0.0.0/9 " ) ;
subnet = C SubNet( " 1.2.3.4/255.0.0.0 " ) ;
subnet = Resolve SubNet( " 1.2.3.4/255.0.0.0 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1.0.0.0/8 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1.0.0.0/8 " ) ;
subnet = C SubNet( " 1.2.3.4/254.0.0.0 " ) ;
subnet = Resolve SubNet( " 1.2.3.4/254.0.0.0 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 0.0.0.0/7 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 0.0.0.0/7 " ) ;
subnet = C SubNet( " 1.2.3.4/252.0.0.0 " ) ;
subnet = Resolve SubNet( " 1.2.3.4/252.0.0.0 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 0.0.0.0/6 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 0.0.0.0/6 " ) ;
subnet = C SubNet( " 1.2.3.4/248.0.0.0 " ) ;
subnet = Resolve SubNet( " 1.2.3.4/248.0.0.0 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 0.0.0.0/5 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 0.0.0.0/5 " ) ;
subnet = C SubNet( " 1.2.3.4/240.0.0.0 " ) ;
subnet = Resolve SubNet( " 1.2.3.4/240.0.0.0 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 0.0.0.0/4 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 0.0.0.0/4 " ) ;
subnet = C SubNet( " 1.2.3.4/224.0.0.0 " ) ;
subnet = Resolve SubNet( " 1.2.3.4/224.0.0.0 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 0.0.0.0/3 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 0.0.0.0/3 " ) ;
subnet = C SubNet( " 1.2.3.4/192.0.0.0 " ) ;
subnet = Resolve SubNet( " 1.2.3.4/192.0.0.0 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 0.0.0.0/2 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 0.0.0.0/2 " ) ;
subnet = C SubNet( " 1.2.3.4/128.0.0.0 " ) ;
subnet = Resolve SubNet( " 1.2.3.4/128.0.0.0 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 0.0.0.0/1 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 0.0.0.0/1 " ) ;
subnet = C SubNet( " 1.2.3.4/0.0.0.0 " ) ;
subnet = Resolve SubNet( " 1.2.3.4/0.0.0.0 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 0.0.0.0/0 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 0.0.0.0/0 " ) ;
subnet = C SubNet( " 1:2:3:4:5:6:7:8/ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff " ) ;
subnet = Resolve SubNet( " 1:2:3:4:5:6:7:8/ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1:2:3:4:5:6:7:8/128 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1:2:3:4:5:6:7:8/128 " ) ;
subnet = C SubNet( " 1:2:3:4:5:6:7:8/ffff:0000:0000:0000:0000:0000:0000:0000 " ) ;
subnet = Resolve SubNet( " 1:2:3:4:5:6:7:8/ffff:0000:0000:0000:0000:0000:0000:0000 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1::/16 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1::/16 " ) ;
subnet = C SubNet( " 1:2:3:4:5:6:7:8/0000:0000:0000:0000:0000:0000:0000:0000 " ) ;
subnet = Resolve SubNet( " 1:2:3:4:5:6:7:8/0000:0000:0000:0000:0000:0000:0000:0000 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " ::/0 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " ::/0 " ) ;
subnet = C SubNet( " 1.2.3.4/255.255.232.0 " ) ;
subnet = Resolve SubNet( " 1.2.3.4/255.255.232.0 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1.2.0.0/255.255.232.0 " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1.2.0.0/255.255.232.0 " ) ;
subnet = C SubNet( " 1:2:3:4:5:6:7:8/ffff:ffff:ffff:fffe:ffff:ffff:ffff:ff0f " ) ;
subnet = Resolve SubNet( " 1:2:3:4:5:6:7:8/ffff:ffff:ffff:fffe:ffff:ffff:ffff:ff0f " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1:2:3:4:5:6:7:8/ffff:ffff:ffff:fffe:ffff:ffff:ffff:ff0f " ) ;
BOOST_CHECK_EQUAL ( subnet . ToString ( ) , " 1:2:3:4:5:6:7:8/ffff:ffff:ffff:fffe:ffff:ffff:ffff:ff0f " ) ;
}
}