File: string.t

package info (click to toggle)
libnet-ipv6addr-perl 1.02-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 328 kB
  • sloc: perl: 598; makefile: 2
file content (51 lines) | stat: -rw-r--r-- 2,259 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
use warnings;
use strict;
use Test::More;

use Net::IPv6Addr;

my $w = new Net::IPv6Addr("ab:cd:ef:01:23:45:67:89");
is($w->to_string_preferred(), "ab:cd:ef:1:23:45:67:89");
is($w->to_string_compressed(), "ab:cd:ef:1:23:45:67:89");
is ($w->to_string_ipv4(), "ab:cd:ef:1:23:45:0.103.0.137");
is ($w->to_string_ipv4_compressed(), "ab:cd:ef:1:23:45:0.103.0.137");

is($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.");

my $x = new Net::IPv6Addr("::");
is($x->to_string_preferred(), "0:0:0:0:0:0:0:0");
is($x->to_string_compressed(), "::");
is($x->to_string_ipv4(), "0:0:0:0:0:0:0.0.0.0");
is($x->to_string_ipv4_compressed(), "::0.0.0.0");
is($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.");

my $y = new Net::IPv6Addr("::1");
is($y->to_string_preferred(), "0:0:0:0:0:0:0:1");
is($y->to_string_compressed(), "::1");
is($y->to_string_ipv4(), "0:0:0:0:0:0:0.0.0.1");
is($y->to_string_ipv4_compressed(), "::0.0.0.1");
is($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.");

my $z = new Net::IPv6Addr("abcd:ef12::3456:789a");
is($z->to_string_preferred(), "abcd:ef12:0:0:0:0:3456:789a");
is($z->to_string_compressed(), "abcd:ef12::3456:789a");
is ($z->to_string_ipv4, 'abcd:ef12:0:0:0:0:52.86.120.154');
is($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.");
is ($z->to_string_ipv4_compressed, 'abcd:ef12::52.86.120.154');

my $p = new Net::IPv6Addr("::ffff:10.0.0.1");
is($p->to_string_preferred(), "0:0:0:0:0:ffff:a00:1");
is($p->to_string_compressed(), "::ffff:a00:1");
is($p->to_string_ipv4(), "0:0:0:0:0:ffff:10.0.0.1");
is($p->to_string_ipv4_compressed(), "::ffff:10.0.0.1");
is($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.");

my $q;
$q = new Net::IPv6Addr("0:0:0:0:0:0:10.0.0.1");
is($q->to_string_preferred(), "0:0:0:0:0:0:a00:1");
is($q->to_string_compressed(), "::a00:1");
is($q->to_string_ipv4(), "0:0:0:0:0:0:10.0.0.1");
is($q->to_string_ipv4_compressed(), "::10.0.0.1");
is($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.");

done_testing ();