Add unit tests for Socket::{pack,unpack}_ipv6_mreq
authorPaul \"LeoNerd\" Evans <leonerd@leonerd.org.uk>
Thu, 20 Oct 2011 11:30:51 +0000 (12:30 +0100)
committerTony Cook <tony@develop-help.com>
Mon, 24 Oct 2011 10:30:41 +0000 (21:30 +1100)
TonyC: add new ipv6_mreq.t test script to MANIFEST

MANIFEST
ext/Socket/t/ipv6_mreq.t [new file with mode: 0644]

index 6a10d3a..07386e3 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -3811,6 +3811,7 @@ ext/Socket/Socket.pm              Socket extension Perl module
 ext/Socket/Socket.xs           Socket extension external subroutines
 ext/Socket/t/getaddrinfo.t     See if Socket::getaddrinfo works
 ext/Socket/t/getnameinfo.t     See if Socket::getnameinfo works
+ext/Socket/t/ipv6_mreq.t       See if (un)pack_ipv6_mreq work
 ext/Socket/t/socketpair.t      See if socketpair works
 ext/Socket/t/Socket.t          See if Socket works
 ext/Sys-Hostname/Hostname.pm   Sys::Hostname extension Perl module
diff --git a/ext/Socket/t/ipv6_mreq.t b/ext/Socket/t/ipv6_mreq.t
new file mode 100644 (file)
index 0000000..43fb8f8
--- /dev/null
@@ -0,0 +1,26 @@
+use strict;
+use warnings;
+use Test::More;
+
+use Socket qw(
+   pack_ipv6_mreq unpack_ipv6_mreq
+);
+
+# Check that pack/unpack_ipv6_mreq either croak with "Not implemented", or
+# roundtrip as identity
+
+my $packed;
+eval {
+   $packed = pack_ipv6_mreq "ANADDRESSIN16CHR", 123;
+};
+if( !defined $packed ) {
+   plan skip_all => "No pack_ipv6_mreq" if $@ =~ m/ not implemented /;
+   die $@;
+}
+
+plan tests => 2;
+
+my @unpacked = unpack_ipv6_mreq $packed;
+
+is( $unpacked[0], "ANADDRESSIN16CHR", 'unpack_ipv6_mreq multiaddr' );
+is( $unpacked[1], 123,                'unpack_ipv6_mreq ifindex' );