summaryrefslogtreecommitdiff
path: root/t/op/pack.t
diff options
context:
space:
mode:
authorValeriy E. Ushakov <uwe@ptc.spbu.ru>1997-06-16 07:00:31 +0400
committerGurusamy Sarathy <gsar@cpan.org>1999-02-09 13:53:28 +0000
commit5a929a98cca1fca196d5fd6d9350568e529e8825 (patch)
tree813d42d01b14295df934030c47606a561ce47d01 /t/op/pack.t
parent26ef7447c0b4d04a31bae92a55d2f6f9abf46c3c (diff)
downloadperl-5a929a98cca1fca196d5fd6d9350568e529e8825.tar.gz
a modified version of suggested patch for pack template 'Z'; added docs
Message-ID: <%lOHpzIuGV@snark.ptc.spbu.ru> Subject: lack of pack/unpack letter with useful symmetry for C null delimited strings p4raw-id: //depot/perl@2846
Diffstat (limited to 't/op/pack.t')
-rwxr-xr-xt/op/pack.t41
1 files changed, 40 insertions, 1 deletions
diff --git a/t/op/pack.t b/t/op/pack.t
index 6b4e63484b..f2f858296f 100755
--- a/t/op/pack.t
+++ b/t/op/pack.t
@@ -8,7 +8,7 @@ BEGIN {
require Config; import Config;
}
-print "1..60\n";
+print "1..72\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
@@ -209,3 +209,42 @@ print "ok ", $test++, "\n";
# binary values of the uuencoded version would not be portable between
# character sets. Uuencoding is meant for encoding binary data, not
# text data.
+
+# test the ascii template types (A, a, Z)
+
+print "not " unless pack('A*', "foo\0bar\0 ") eq "foo\0bar\0 ";
+print "ok ", $test++, "\n";
+
+print "not " unless pack('A11', "foo\0bar\0 ") eq "foo\0bar\0 ";
+print "ok ", $test++, "\n";
+
+print "not " unless unpack('A*', "foo\0bar \0") eq "foo\0bar";
+print "ok ", $test++, "\n";
+
+print "not " unless unpack('A8', "foo\0bar \0") eq "foo\0bar";
+print "ok ", $test++, "\n";
+
+print "not " unless pack('a*', "foo\0bar\0 ") eq "foo\0bar\0 ";
+print "ok ", $test++, "\n";
+
+print "not " unless pack('a11', "foo\0bar\0 ") eq "foo\0bar\0 \0\0";
+print "ok ", $test++, "\n";
+
+print "not " unless unpack('a*', "foo\0bar \0") eq "foo\0bar \0";
+print "ok ", $test++, "\n";
+
+print "not " unless unpack('a8', "foo\0bar \0") eq "foo\0bar ";
+print "ok ", $test++, "\n";
+
+print "not " unless pack('Z*', "foo\0bar\0 ") eq "foo\0bar\0 ";
+print "ok ", $test++, "\n";
+
+print "not " unless pack('Z11', "foo\0bar\0 ") eq "foo\0bar\0 \0\0";
+print "ok ", $test++, "\n";
+
+print "not " unless unpack('Z*', "foo\0bar \0") eq "foo";
+print "ok ", $test++, "\n";
+
+print "not " unless unpack('Z8', "foo\0bar \0") eq "foo";
+print "ok ", $test++, "\n";
+