This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Remove old MSVC++ (pre-VC12) support from Windows Makefiles
[perl5.git] / cpan / Socket / t / ip_mreq.t
CommitLineData
8bb05de3 1use v5.6.1;
3be135d8
TC
2use strict;
3use warnings;
4use Test::More;
5
6use Socket qw(
7 INADDR_ANY
8 pack_ip_mreq unpack_ip_mreq
d4ada64a 9 pack_ip_mreq_source unpack_ip_mreq_source
3be135d8
TC
10);
11
12# Check that pack/unpack_ip_mreq either croak with "Not implemented", or
13# roundtrip as identity
14
15my $packed;
16eval {
17 $packed = pack_ip_mreq "\xe0\0\0\1", INADDR_ANY;
18};
19if( !defined $packed ) {
20 plan skip_all => "No pack_ip_mreq" if $@ =~ m/ not implemented /;
21 die $@;
22}
23
d4ada64a 24plan tests => 6;
3be135d8
TC
25
26my @unpacked = unpack_ip_mreq $packed;
27
28is( $unpacked[0], "\xe0\0\0\1", 'unpack_ip_mreq multiaddr' );
29is( $unpacked[1], INADDR_ANY, 'unpack_ip_mreq interface' );
30
31is( (unpack_ip_mreq pack_ip_mreq "\xe0\0\0\1")[1], INADDR_ANY, 'pack_ip_mreq interface defaults to INADDR_ANY' );
d4ada64a
SH
32
33SKIP: {
34 my $mreq;
b43fc6a1 35 skip "No pack_ip_mreq_source", 3 unless defined eval { $mreq = pack_ip_mreq_source "\xe0\0\0\2", "\x0a\0\0\1", INADDR_ANY };
d4ada64a
SH
36
37 @unpacked = unpack_ip_mreq_source $mreq;
38
39 is( $unpacked[0], "\xe0\0\0\2", 'unpack_ip_mreq_source multiaddr' );
40 is( $unpacked[1], "\x0a\0\0\1", 'unpack_ip_mreq_source source' );
41 is( $unpacked[2], INADDR_ANY, 'unpack_ip_mreq_source interface' );
42}