summaryrefslogtreecommitdiff
path: root/t/op/pack.t
diff options
context:
space:
mode:
authorIan Phillipps <Ian.Phillipps@iname.com>1999-07-24 00:35:56 +0100
committerGurusamy Sarathy <gsar@cpan.org>1999-07-26 09:28:48 +0000
commit43192e07925c626b8d615aff545160df8bd7c3f8 (patch)
tree6fc8ce7fb7b43e513591e91fb5a635c864059f62 /t/op/pack.t
parent1f763251de9d15bd843d41adf21f5de7aa72b2ea (diff)
downloadperl-43192e07925c626b8d615aff545160df8bd7c3f8.tar.gz
(Version 2) Extending unpack to deal with counted strings
Message-ID: <19990723233556.B2435@homer.diplex.co.uk> p4raw-id: //depot/perl@3765
Diffstat (limited to 't/op/pack.t')
-rwxr-xr-xt/op/pack.t18
1 files changed, 17 insertions, 1 deletions
diff --git a/t/op/pack.t b/t/op/pack.t
index 5b727974a6..082b954756 100755
--- a/t/op/pack.t
+++ b/t/op/pack.t
@@ -6,7 +6,7 @@ BEGIN {
require Config; import Config;
}
-print "1..142\n";
+print "1..148\n";
$format = "c2 x5 C C x s d i l a6";
# Need the expression in here to force ary[5] to be numeric. This avoids
@@ -353,3 +353,19 @@ print "ok ", $test++, "\n";
print "not " unless pack("V", 0xdeadbeef) eq "\xef\xbe\xad\xde";
print "ok ", $test++, "\n";
+
+# 143..148: #
+
+my $z;
+eval { ($x) = unpack '#a*','hello' };
+print 'not ' unless $@; print "ok $test\n"; $test++;
+eval { ($z,$x,$y) = unpack 'a3#A C#a* C#Z', "003ok \003yes\004z\000abc" };
+print $@ eq '' && $z eq 'ok' ? "ok $test\n" : "not ok $test\n"; $test++;
+print $@ eq '' && $x eq 'yes' ? "ok $test\n" : "not ok $test\n"; $test++;
+print $@ eq '' && $y eq 'z' ? "ok $test\n" : "not ok $test\n"; $test++;
+
+eval { ($x) = pack '#a*','hello' };
+print 'not ' unless $@; print "ok $test\n"; $test++;
+$z = pack 'n#a* w#A*','string','etc';
+print 'not ' unless $z eq "\000\006string\003etc"; print "ok $test\n"; $test++;
+