This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Upgrade Socket to 2.002
[perl5.git] / cpan / Socket / t / ip_mreq.t
CommitLineData
3be135d8
TC
1use strict;
2use warnings;
3use Test::More;
4
5use Socket qw(
6 INADDR_ANY
7 pack_ip_mreq unpack_ip_mreq
8);
9
10# Check that pack/unpack_ip_mreq either croak with "Not implemented", or
11# roundtrip as identity
12
13my $packed;
14eval {
15 $packed = pack_ip_mreq "\xe0\0\0\1", INADDR_ANY;
16};
17if( !defined $packed ) {
18 plan skip_all => "No pack_ip_mreq" if $@ =~ m/ not implemented /;
19 die $@;
20}
21
22plan tests => 3;
23
24my @unpacked = unpack_ip_mreq $packed;
25
26is( $unpacked[0], "\xe0\0\0\1", 'unpack_ip_mreq multiaddr' );
27is( $unpacked[1], INADDR_ANY, 'unpack_ip_mreq interface' );
28
29is( (unpack_ip_mreq pack_ip_mreq "\xe0\0\0\1")[1], INADDR_ANY, 'pack_ip_mreq interface defaults to INADDR_ANY' );