1use warnings; 2use strict; 3use Test::More; 4 5use Net::IPv6Addr; 6 7my $w = new Net::IPv6Addr("ab:cd:ef:01:23:45:67:89"); 8is($w->to_string_preferred(), "ab:cd:ef:1:23:45:67:89"); 9is($w->to_string_compressed(), "ab:cd:ef:1:23:45:67:89"); 10is ($w->to_string_ipv4(), "ab:cd:ef:1:23:45:0.103.0.137"); 11is ($w->to_string_ipv4_compressed(), "ab:cd:ef:1:23:45:0.103.0.137"); 12 13is($w->to_string_ip6_int(), "9.8.0.0.7.6.0.0.5.4.0.0.3.2.0.0.1.0.0.0.f.e.0.0.d.c.0.0.b.a.0.0.IP6.INT."); 14 15my $x = new Net::IPv6Addr("::"); 16is($x->to_string_preferred(), "0:0:0:0:0:0:0:0"); 17is($x->to_string_compressed(), "::"); 18is($x->to_string_ipv4(), "0:0:0:0:0:0:0.0.0.0"); 19is($x->to_string_ipv4_compressed(), "::0.0.0.0"); 20is($x->to_string_ip6_int(), "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.IP6.INT."); 21 22my $y = new Net::IPv6Addr("::1"); 23is($y->to_string_preferred(), "0:0:0:0:0:0:0:1"); 24is($y->to_string_compressed(), "::1"); 25is($y->to_string_ipv4(), "0:0:0:0:0:0:0.0.0.1"); 26is($y->to_string_ipv4_compressed(), "::0.0.0.1"); 27is($y->to_string_ip6_int(), "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.IP6.INT."); 28 29my $z = new Net::IPv6Addr("abcd:ef12::3456:789a"); 30is($z->to_string_preferred(), "abcd:ef12:0:0:0:0:3456:789a"); 31is($z->to_string_compressed(), "abcd:ef12::3456:789a"); 32is ($z->to_string_ipv4, 'abcd:ef12:0:0:0:0:52.86.120.154'); 33is($z->to_string_ip6_int(), "a.9.8.7.6.5.4.3.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.1.f.e.d.c.b.a.IP6.INT."); 34is ($z->to_string_ipv4_compressed, 'abcd:ef12::52.86.120.154'); 35 36my $p = new Net::IPv6Addr("::ffff:10.0.0.1"); 37is($p->to_string_preferred(), "0:0:0:0:0:ffff:a00:1"); 38is($p->to_string_compressed(), "::ffff:a00:1"); 39is($p->to_string_ipv4(), "0:0:0:0:0:ffff:10.0.0.1"); 40is($p->to_string_ipv4_compressed(), "::ffff:10.0.0.1"); 41is($p->to_string_ip6_int(), "1.0.0.0.0.0.a.0.f.f.f.f.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.IP6.INT."); 42 43my $q; 44$q = new Net::IPv6Addr("0:0:0:0:0:0:10.0.0.1"); 45is($q->to_string_preferred(), "0:0:0:0:0:0:a00:1"); 46is($q->to_string_compressed(), "::a00:1"); 47is($q->to_string_ipv4(), "0:0:0:0:0:0:10.0.0.1"); 48is($q->to_string_ipv4_compressed(), "::10.0.0.1"); 49is($q->to_string_ip6_int(), "1.0.0.0.0.0.a.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.IP6.INT."); 50 51done_testing (); 52