Commit | Line | Data |
a687059c |
1 | #!./perl |
2 | |
a1a0e61e |
3 | BEGIN { |
4 | chdir 't' if -d 't'; |
20822f61 |
5 | @INC = '../lib'; |
a1a0e61e |
6 | require Config; import Config; |
7 | } |
8 | |
2e821511 |
9 | print "1..161\n"; |
10 | # Note: All test numbers in comments are off by 1 after the comment below.. |
a687059c |
11 | |
bbdab043 |
12 | $format = "c2 x5 C C x s d i l a6"; |
450a55e4 |
13 | # Need the expression in here to force ary[5] to be numeric. This avoids |
14 | # test2 failing because ary2 goes str->numeric->str and ary doesn't. |
15 | @ary = (1,-100,127,128,32767,987.654321098 / 100.0,12345,123456,"abcdef"); |
a687059c |
16 | $foo = pack($format,@ary); |
17 | @ary2 = unpack($format,$foo); |
18 | |
19 | print ($#ary == $#ary2 ? "ok 1\n" : "not ok 1\n"); |
20 | |
21 | $out1=join(':',@ary); |
22 | $out2=join(':',@ary2); |
ae165b0c |
23 | # Using long double NVs may introduce greater accuracy than wanted. |
658bbd66 |
24 | $out1 =~ s/:9\.87654321097999\d*:/:9.87654321098:/; |
c4ab3e64 |
25 | $out2 =~ s/:9\.87654321097999\d*:/:9.87654321098:/; |
494f3023 |
26 | print ($out1 eq $out2? "ok 2\n" : "not ok 2\n"); |
a687059c |
27 | |
28 | print ($foo =~ /def/ ? "ok 3\n" : "not ok 3\n"); |
79072805 |
29 | |
30 | # How about counting bits? |
31 | |
32 | print +($x = unpack("%32B*", "\001\002\004\010\020\040\100\200\377")) == 16 |
33 | ? "ok 4\n" : "not ok 4 $x\n"; |
34 | |
35 | print +($x = unpack("%32b69", "\001\002\004\010\020\040\100\200\017")) == 12 |
36 | ? "ok 5\n" : "not ok 5 $x\n"; |
37 | |
38 | print +($x = unpack("%32B69", "\001\002\004\010\020\040\100\200\017")) == 9 |
39 | ? "ok 6\n" : "not ok 6 $x\n"; |
40 | |
9d116dd7 |
41 | my $sum = 129; # ASCII |
a1a0e61e |
42 | $sum = 103 if ($Config{ebcdic} eq 'define'); |
9d116dd7 |
43 | |
44 | print +($x = unpack("%32B*", "Now is the time for all good blurfl")) == $sum |
79072805 |
45 | ? "ok 7\n" : "not ok 7 $x\n"; |
46 | |
95e8664e |
47 | open(BIN, "./perl") || open(BIN, "./perl.exe") || open(BIN, $^X) |
b8440792 |
48 | || die "Can't open ../perl or ../perl.exe: $!\n"; |
79072805 |
49 | sysread BIN, $foo, 8192; |
50 | close BIN; |
51 | |
52 | $sum = unpack("%32b*", $foo); |
53 | $longway = unpack("b*", $foo); |
54 | print $sum == $longway =~ tr/1/1/ ? "ok 8\n" : "not ok 8\n"; |
73a1c01a |
55 | |
56 | print +($x = unpack("I",pack("I", 0xFFFFFFFF))) == 0xFFFFFFFF |
57 | ? "ok 9\n" : "not ok 9 $x\n"; |
def98dd4 |
58 | |
59 | # check 'w' |
60 | my $test=10; |
2e821511 |
61 | my @x = (5,130,256,560,32000,3097152,268435455,1073741844, 2**33, |
55497cff |
62 | '4503599627365785','23728385234614992549757750638446'); |
def98dd4 |
63 | my $x = pack('w*', @x); |
2e821511 |
64 | my $y = pack 'H*', '0581028200843081fa0081bd8440ffffff7f8480808014A08080800087ffffffffffdb19caefe8e1eeeea0c2e1e3e8ede1ee6e'; |
def98dd4 |
65 | |
2e821511 |
66 | if ($x eq $y) { |
67 | print "ok $test\n"; |
68 | } else { |
69 | printf "not ok $test # %s\n", unpack 'H*', $x; |
70 | } |
71 | $test++; |
def98dd4 |
72 | |
73 | @y = unpack('w*', $y); |
55497cff |
74 | my $a; |
75 | while ($a = pop @x) { |
76 | my $b = pop @y; |
77 | print $a eq $b ? "ok $test\n" : "not ok $test\n$a\n$b\n"; $test++; |
78 | } |
def98dd4 |
79 | |
2e821511 |
80 | # XXX All test numbers in comments are off by 1 after this point. |
81 | |
def98dd4 |
82 | @y = unpack('w2', $x); |
83 | |
84 | print scalar(@y) == 2 ? "ok $test\n" : "not ok $test\n"; $test++; |
2e821511 |
85 | print $y[1] == 130 ? "ok $test\n" : "not ok $test # $y[1]\n"; $test++; |
def98dd4 |
86 | |
55497cff |
87 | # test exeptions |
def98dd4 |
88 | eval { $x = unpack 'w', pack 'C*', 0xff, 0xff}; |
89 | print $@ ne '' ? "ok $test\n" : "not ok $test\n"; $test++; |
90 | |
91 | eval { $x = unpack 'w', pack 'C*', 0xff, 0xff, 0xff, 0xff}; |
92 | print $@ ne '' ? "ok $test\n" : "not ok $test\n"; $test++; |
93 | |
94 | eval { $x = unpack 'w', pack 'C*', 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; |
95 | print $@ ne '' ? "ok $test\n" : "not ok $test\n"; $test++; |
96 | |
84902520 |
97 | # |
98 | # test the "p" template |
99 | |
100 | # literals |
101 | print((unpack("p",pack("p","foo")) eq "foo" ? "ok " : "not ok "),$test++,"\n"); |
102 | |
103 | # scalars |
104 | print((unpack("p",pack("p",$test)) == $test ? "ok " : "not ok "),$test++,"\n"); |
105 | |
106 | # temps |
107 | sub foo { my $a = "a"; return $a . $a++ . $a++ } |
108 | { |
9f1b1f2d |
109 | use warnings; |
84902520 |
110 | my $last = $test; |
111 | local $SIG{__WARN__} = sub { |
112 | print "ok ",$test++,"\n" if $_[0] =~ /temporary val/ |
113 | }; |
114 | my $junk = pack("p", &foo); |
115 | print "not ok ", $test++, "\n" if $last == $test; |
116 | } |
117 | |
118 | # undef should give null pointer |
119 | print((pack("p", undef) =~ /^\0+/ ? "ok " : "not ok "),$test++,"\n"); |
120 | |
20408e3c |
121 | # Check for optimizer bug (e.g. Digital Unix GEM cc with -O4 on DU V4.0B gives |
122 | # 4294967295 instead of -1) |
123 | # see #ifdef __osf__ in pp.c pp_unpack |
124 | # Test 30: |
125 | print( ((unpack("i",pack("i",-1))) == -1 ? "ok " : "not ok "),$test++,"\n"); |
126 | |
d4217c7e |
127 | # 31..36: test the pack lengths of s S i I l L |
128 | print "not " unless length(pack("s", 0)) == 2; |
129 | print "ok ", $test++, "\n"; |
c4d5f83a |
130 | |
d4217c7e |
131 | print "not " unless length(pack("S", 0)) == 2; |
132 | print "ok ", $test++, "\n"; |
c4d5f83a |
133 | |
d4217c7e |
134 | print "not " unless length(pack("i", 0)) >= 4; |
135 | print "ok ", $test++, "\n"; |
136 | |
137 | print "not " unless length(pack("I", 0)) >= 4; |
138 | print "ok ", $test++, "\n"; |
139 | |
140 | print "not " unless length(pack("l", 0)) == 4; |
141 | print "ok ", $test++, "\n"; |
142 | |
143 | print "not " unless length(pack("L", 0)) == 4; |
144 | print "ok ", $test++, "\n"; |
145 | |
146 | # 37..40: test the pack lengths of n N v V |
147 | |
148 | print "not " unless length(pack("n", 0)) == 2; |
149 | print "ok ", $test++, "\n"; |
150 | |
151 | print "not " unless length(pack("N", 0)) == 4; |
152 | print "ok ", $test++, "\n"; |
153 | |
154 | print "not " unless length(pack("v", 0)) == 2; |
155 | print "ok ", $test++, "\n"; |
156 | |
157 | print "not " unless length(pack("V", 0)) == 4; |
158 | print "ok ", $test++, "\n"; |
159 | |
160 | # 41..56: test unpack-pack lengths |
161 | |
162 | my @templates = qw(c C i I s S l L n N v V f d); |
163 | |
164 | # quads not supported everywhere: if not, retest floats/doubles |
165 | # to preserve the test count... |
166 | eval { my $q = pack("q",0) }; |
167 | push @templates, $@ !~ /Invalid type in pack/ ? qw(q Q) : qw(f d); |
168 | |
169 | foreach my $t (@templates) { |
170 | my @t = unpack("$t*", pack("$t*", 12, 34)); |
171 | print "not " |
172 | unless @t == 2 and (($t[0] == 12 and $t[1] == 34) or ($t =~ /[nv]/i)); |
173 | print "ok ", $test++, "\n"; |
174 | } |
9d116dd7 |
175 | |
eddc390b |
176 | # 57..60: uuencode/decode |
9d116dd7 |
177 | |
ef54e1a4 |
178 | # Note that first uuencoding known 'text' data and then checking the |
179 | # binary values of the uuencoded version would not be portable between |
180 | # character sets. Uuencoding is meant for encoding binary data, not |
181 | # text data. |
c4d5f83a |
182 | |
342930fb |
183 | $in = pack 'C*', 0 .. 255; |
ba1ac976 |
184 | |
185 | # just to be anal, we do some random tr/`/ / |
9d116dd7 |
186 | $uu = <<'EOUU'; |
ba1ac976 |
187 | M` $"`P0%!@<("0H+# T.#Q`1$A,4%187&!D:&QP='A\@(2(C)"4F)R@I*BLL |
9d116dd7 |
188 | M+2XO,#$R,S0U-C<X.3H[/#T^/T!!0D-$149'2$E*2TQ-3D]045)35%565UA9 |
189 | M6EM<75Y?8&%B8V1E9F=H:6IK;&UN;W!Q<G-T=79W>'EZ>WQ]?G^`@8*#A(6& |
190 | MAXB)BHN,C8Z/D)&2DY25EI>8F9J;G)V>GZ"AHJ.DI::GJ*FJJZRMKJ^PL;*S |
191 | MM+6VM[BYNKN\O;Z_P,'"P\3%QL?(R<K+S,W.S]#1TM/4U=;7V-G:V]S=WM_@ |
ba1ac976 |
192 | ?X>+CY.7FY^CIZNOL[>[O\/'R\_3U]O?X^?K[_/W^_P ` |
9d116dd7 |
193 | EOUU |
194 | |
ba1ac976 |
195 | $_ = $uu; |
196 | tr/ /`/; |
197 | print "not " unless pack('u', $in) eq $_; |
9d116dd7 |
198 | print "ok ", $test++, "\n"; |
199 | |
200 | print "not " unless unpack('u', $uu) eq $in; |
201 | print "ok ", $test++, "\n"; |
202 | |
eddc390b |
203 | $in = "\x1f\x8b\x08\x08\x58\xdc\xc4\x35\x02\x03\x4a\x41\x50\x55\x00\xf3\x2a\x2d\x2e\x51\x48\xcc\xcb\x2f\xc9\x48\x2d\x52\x08\x48\x2d\xca\x51\x28\x2d\x4d\xce\x4f\x49\x2d\xe2\x02\x00\x64\x66\x60\x5c\x1a\x00\x00\x00"; |
204 | $uu = <<'EOUU'; |
205 | M'XL("%C<Q#4"`TI!4%4`\RHM+E%(S,LOR4@M4@A(+<I1*"U-SD])+>("`&1F |
206 | &8%P:```` |
207 | EOUU |
208 | |
209 | print "not " unless unpack('u', $uu) eq $in; |
210 | print "ok ", $test++, "\n"; |
211 | |
212 | # 60 identical to 59 except that backquotes have been changed to spaces |
213 | |
214 | $uu = <<'EOUU'; |
215 | M'XL("%C<Q#4" TI!4%4 \RHM+E%(S,LOR4@M4@A(+<I1*"U-SD])+>(" &1F |
c4d5f83a |
216 | &8%P: |
eddc390b |
217 | EOUU |
218 | |
219 | print "not " unless unpack('u', $uu) eq $in; |
220 | print "ok ", $test++, "\n"; |
221 | |
2b6c5635 |
222 | # 61..73: test the ascii template types (A, a, Z) |
5a929a98 |
223 | |
224 | print "not " unless pack('A*', "foo\0bar\0 ") eq "foo\0bar\0 "; |
225 | print "ok ", $test++, "\n"; |
226 | |
227 | print "not " unless pack('A11', "foo\0bar\0 ") eq "foo\0bar\0 "; |
228 | print "ok ", $test++, "\n"; |
229 | |
230 | print "not " unless unpack('A*', "foo\0bar \0") eq "foo\0bar"; |
231 | print "ok ", $test++, "\n"; |
232 | |
233 | print "not " unless unpack('A8', "foo\0bar \0") eq "foo\0bar"; |
234 | print "ok ", $test++, "\n"; |
235 | |
236 | print "not " unless pack('a*', "foo\0bar\0 ") eq "foo\0bar\0 "; |
237 | print "ok ", $test++, "\n"; |
238 | |
239 | print "not " unless pack('a11', "foo\0bar\0 ") eq "foo\0bar\0 \0\0"; |
240 | print "ok ", $test++, "\n"; |
241 | |
242 | print "not " unless unpack('a*', "foo\0bar \0") eq "foo\0bar \0"; |
243 | print "ok ", $test++, "\n"; |
244 | |
245 | print "not " unless unpack('a8', "foo\0bar \0") eq "foo\0bar "; |
246 | print "ok ", $test++, "\n"; |
247 | |
2b6c5635 |
248 | print "not " unless pack('Z*', "foo\0bar\0 ") eq "foo\0bar\0 \0"; |
5a929a98 |
249 | print "ok ", $test++, "\n"; |
250 | |
251 | print "not " unless pack('Z11', "foo\0bar\0 ") eq "foo\0bar\0 \0\0"; |
252 | print "ok ", $test++, "\n"; |
253 | |
2b6c5635 |
254 | print "not " unless pack('Z3', "foo") eq "fo\0"; |
255 | print "ok ", $test++, "\n"; |
256 | |
5a929a98 |
257 | print "not " unless unpack('Z*', "foo\0bar \0") eq "foo"; |
258 | print "ok ", $test++, "\n"; |
259 | |
260 | print "not " unless unpack('Z8', "foo\0bar \0") eq "foo"; |
261 | print "ok ", $test++, "\n"; |
262 | |
2b6c5635 |
263 | # 74..79: packing native shorts/ints/longs |
ef54e1a4 |
264 | |
f61d411c |
265 | print "not " unless length(pack("s!", 0)) == $Config{shortsize}; |
ef54e1a4 |
266 | print "ok ", $test++, "\n"; |
267 | |
f61d411c |
268 | print "not " unless length(pack("i!", 0)) == $Config{intsize}; |
ef54e1a4 |
269 | print "ok ", $test++, "\n"; |
270 | |
f61d411c |
271 | print "not " unless length(pack("l!", 0)) == $Config{longsize}; |
ef54e1a4 |
272 | print "ok ", $test++, "\n"; |
273 | |
f61d411c |
274 | print "not " unless length(pack("s!", 0)) <= length(pack("i!", 0)); |
ef54e1a4 |
275 | print "ok ", $test++, "\n"; |
276 | |
f61d411c |
277 | print "not " unless length(pack("i!", 0)) <= length(pack("l!", 0)); |
ef54e1a4 |
278 | print "ok ", $test++, "\n"; |
279 | |
f61d411c |
280 | print "not " unless length(pack("i!", 0)) == length(pack("i", 0)); |
ef54e1a4 |
281 | print "ok ", $test++, "\n"; |
282 | |
2b6c5635 |
283 | # 80..139: pack <-> unpack bijectionism |
726ea183 |
284 | |
2b6c5635 |
285 | # 80.. 84 c |
d99ad34e |
286 | foreach my $c (-128, -1, 0, 1, 127) { |
287 | print "not " unless unpack("c", pack("c", $c)) == $c; |
288 | print "ok ", $test++, "\n"; |
289 | } |
9de70c85 |
290 | |
2b6c5635 |
291 | # 85.. 89: C |
d99ad34e |
292 | foreach my $C (0, 1, 127, 128, 255) { |
293 | print "not " unless unpack("C", pack("C", $C)) == $C; |
294 | print "ok ", $test++, "\n"; |
295 | } |
726ea183 |
296 | |
2b6c5635 |
297 | # 90.. 94: s |
d99ad34e |
298 | foreach my $s (-32768, -1, 0, 1, 32767) { |
299 | print "not " unless unpack("s", pack("s", $s)) == $s; |
300 | print "ok ", $test++, "\n"; |
301 | } |
726ea183 |
302 | |
2b6c5635 |
303 | # 95.. 99: S |
d99ad34e |
304 | foreach my $S (0, 1, 32767, 32768, 65535) { |
305 | print "not " unless unpack("S", pack("S", $S)) == $S; |
306 | print "ok ", $test++, "\n"; |
307 | } |
726ea183 |
308 | |
2b6c5635 |
309 | # 100..104: i |
d99ad34e |
310 | foreach my $i (-2147483648, -1, 0, 1, 2147483647) { |
311 | print "not " unless unpack("i", pack("i", $i)) == $i; |
312 | print "ok ", $test++, "\n"; |
313 | } |
726ea183 |
314 | |
2b6c5635 |
315 | # 105..109: I |
d99ad34e |
316 | foreach my $I (0, 1, 2147483647, 2147483648, 4294967295) { |
317 | print "not " unless unpack("I", pack("I", $I)) == $I; |
318 | print "ok ", $test++, "\n"; |
319 | } |
726ea183 |
320 | |
2b6c5635 |
321 | # 110..114: l |
d99ad34e |
322 | foreach my $l (-2147483648, -1, 0, 1, 2147483647) { |
323 | print "not " unless unpack("l", pack("l", $l)) == $l; |
324 | print "ok ", $test++, "\n"; |
325 | } |
726ea183 |
326 | |
2b6c5635 |
327 | # 115..119: L |
d99ad34e |
328 | foreach my $L (0, 1, 2147483647, 2147483648, 4294967295) { |
329 | print "not " unless unpack("L", pack("L", $L)) == $L; |
330 | print "ok ", $test++, "\n"; |
331 | } |
726ea183 |
332 | |
2b6c5635 |
333 | # 120..124: n |
d99ad34e |
334 | foreach my $n (0, 1, 32767, 32768, 65535) { |
335 | print "not " unless unpack("n", pack("n", $n)) == $n; |
336 | print "ok ", $test++, "\n"; |
337 | } |
726ea183 |
338 | |
2b6c5635 |
339 | # 125..129: v |
d99ad34e |
340 | foreach my $v (0, 1, 32767, 32768, 65535) { |
341 | print "not " unless unpack("v", pack("v", $v)) == $v; |
342 | print "ok ", $test++, "\n"; |
343 | } |
726ea183 |
344 | |
2b6c5635 |
345 | # 130..134: N |
d99ad34e |
346 | foreach my $N (0, 1, 2147483647, 2147483648, 4294967295) { |
347 | print "not " unless unpack("N", pack("N", $N)) == $N; |
348 | print "ok ", $test++, "\n"; |
349 | } |
726ea183 |
350 | |
2b6c5635 |
351 | # 135..139: V |
d99ad34e |
352 | foreach my $V (0, 1, 2147483647, 2147483648, 4294967295) { |
353 | print "not " unless unpack("V", pack("V", $V)) == $V; |
354 | print "ok ", $test++, "\n"; |
355 | } |
726ea183 |
356 | |
2b6c5635 |
357 | # 140..143: pack nvNV byteorders |
726ea183 |
358 | |
d99ad34e |
359 | print "not " unless pack("n", 0xdead) eq "\xde\xad"; |
726ea183 |
360 | print "ok ", $test++, "\n"; |
361 | |
d99ad34e |
362 | print "not " unless pack("v", 0xdead) eq "\xad\xde"; |
c67712b2 |
363 | print "ok ", $test++, "\n"; |
726ea183 |
364 | |
d99ad34e |
365 | print "not " unless pack("N", 0xdeadbeef) eq "\xde\xad\xbe\xef"; |
726ea183 |
366 | print "ok ", $test++, "\n"; |
367 | |
d99ad34e |
368 | print "not " unless pack("V", 0xdeadbeef) eq "\xef\xbe\xad\xde"; |
c67712b2 |
369 | print "ok ", $test++, "\n"; |
43192e07 |
370 | |
4b5b2118 |
371 | # 144..152: / |
43192e07 |
372 | |
2e821511 |
373 | # Using Test considered bad plan in op/*.t ? |
374 | |
375 | sub report { |
376 | my ($pass, $test, $err, $wrong) = @_; |
377 | if ($pass) { |
378 | print "ok $test\n" |
379 | } else { |
380 | if ($err) { |
381 | chomp $err; |
382 | print "not ok $test # \$\@ = $err\n"; |
383 | } else { |
384 | $wrong =~ s/([[:cntrl:]\177 ])/sprintf "\\%03o", ord $1/ge; |
385 | print "not ok $test # got $wrong\n"; |
386 | } |
387 | } |
388 | } |
389 | |
43192e07 |
390 | my $z; |
17f4a12d |
391 | eval { ($x) = unpack '/a*','hello' }; |
43192e07 |
392 | print 'not ' unless $@; print "ok $test\n"; $test++; |
17f4a12d |
393 | eval { ($z,$x,$y) = unpack 'a3/A C/a* C/Z', "003ok \003yes\004z\000abc" }; |
43192e07 |
394 | print $@ eq '' && $z eq 'ok' ? "ok $test\n" : "not ok $test\n"; $test++; |
395 | print $@ eq '' && $x eq 'yes' ? "ok $test\n" : "not ok $test\n"; $test++; |
396 | print $@ eq '' && $y eq 'z' ? "ok $test\n" : "not ok $test\n"; $test++; |
397 | |
17f4a12d |
398 | eval { ($x) = pack '/a*','hello' }; |
43192e07 |
399 | print 'not ' unless $@; print "ok $test\n"; $test++; |
3399f041 |
400 | $z = pack 'n/a* N/Z* w/A*','string','hi there ','etc'; |
2e821511 |
401 | my $expect = "\000\006string\0\0\0\012hi there \000\003etc"; |
402 | report ($z eq $expect, $test++, '', $z); |
43192e07 |
403 | |
4b5b2118 |
404 | eval { ($x) = unpack 'a/a*/a*', '212ab345678901234567' }; |
405 | print $@ eq '' && $x eq 'ab3456789012' ? "ok $test\n" : "#$x,$@\nnot ok $test\n"; |
406 | $test++; |
407 | |
408 | eval { ($x) = unpack 'a/a*/a*', '3012ab345678901234567' }; |
409 | print $@ eq '' && $x eq 'ab3456789012' ? "ok $test\n" : "not ok $test\n"; |
410 | $test++; |
411 | |
412 | eval { ($x) = unpack 'a/a*/b*', '212ab' }; |
ee50adbe |
413 | my $expected_x = '100001100100'; |
414 | if ($Config{ebcdic} eq 'define') { $expected_x = '100000010100'; } |
415 | print $@ eq '' && $x eq $expected_x ? "ok $test\n" : "#$x,$@\nnot ok $test\n"; |
4b5b2118 |
416 | $test++; |
417 | |
418 | # 153..156: / with # |
17f4a12d |
419 | |
420 | eval { ($z,$x,$y) = unpack <<EOU, "003ok \003yes\004z\000abc" }; |
421 | a3/A # Count in ASCII |
422 | C/a* # Count in a C char |
423 | C/Z # Count in a C char but skip after \0 |
424 | EOU |
425 | print $@ eq '' && $z eq 'ok' ? "ok $test\n" : "not ok $test\n"; $test++; |
426 | print $@ eq '' && $x eq 'yes' ? "ok $test\n" : "not ok $test\n"; $test++; |
427 | print $@ eq '' && $y eq 'z' ? "ok $test\n" : "not ok $test\n"; $test++; |
428 | |
429 | $z = pack <<EOP,'string','etc'; |
430 | n/a* # Count as network short |
431 | w/A* # Count a BER integer |
432 | EOP |
2e821511 |
433 | $expect = "\000\006string\003etc"; |
434 | report ($z eq $expect, $test++, '', $z); |
036b4402 |
435 | |
c4d5f83a |
436 | print 'not ' unless "1.20.300.4000" eq sprintf "%vd", pack("U*",1,20,300,4000); |
036b4402 |
437 | print "ok $test\n"; $test++; |
c4d5f83a |
438 | print 'not ' unless "1.20.300.4000" eq |
439 | sprintf "%vd", pack(" U*",1,20,300,4000); |
036b4402 |
440 | print "ok $test\n"; $test++; |
c4d5f83a |
441 | print 'not ' unless v1.20.300.4000 ne |
442 | sprintf "%vd", pack("C0U*",1,20,300,4000); |
036b4402 |
443 | print "ok $test\n"; $test++; |
444 | |
4765795a |
445 | # 160 |
c4d5f83a |
446 | print "not " unless join(" ", unpack("C*", chr(0x1e2))) |
447 | eq ((ord(A) == 193) ? "156 67" : "199 162"); |
4765795a |
448 | print "ok $test\n"; $test++; |