From: Ton Hospel Date: Sat, 12 Mar 2005 18:54:29 +0000 (+0000) Subject: Re: Encoding neutral unpack X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f7f98fdfea717e6de174a9b8b95e1c18726eb5f3;p=p5sagit%2Fp5-mst-13.2.git Re: Encoding neutral unpack Message-ID: A new test. p4raw-id: //depot/perl@24031 --- diff --git a/t/op/pack.t b/t/op/pack.t index 7f6bbed..06c3a9a 100755 --- a/t/op/pack.t +++ b/t/op/pack.t @@ -12,7 +12,7 @@ my $no_endianness = $] > 5.009 ? '' : my $no_signedness = $] > 5.009 ? '' : "Signed/unsigned pack modifiers not available on this perl"; -plan tests => 14604; +plan tests => 14606; use strict; use warnings; @@ -1495,6 +1495,18 @@ is(unpack('c'), 65, "one-arg unpack (change #18751)"); # defaulting to $_ is($a[-2], "X", "[perl #15288]"); } +{ + my $warning; + local $SIG{__WARN__} = sub { + $warning = $_[0]; + }; + my $out = pack("u99", "foo" x 99); + like($warning, qr/Field too wide in 'u' format in pack at /, + "Warn about too wide uuencode"); + is($out, ("_" . "9F]O" x 21 . "\n") x 4 . "M" . "9F]O" x 15 . "\n", + "Use max width in case of too wide uuencode"); +} + # checksums { # verify that unpack advances correctly wrt a checksum