xref: /php-src/ext/standard/tests/strings/pack64.phpt (revision 524ce904)
1--TEST--
264bit pack()/unpack() tests
3--SKIPIF--
4<?php
5if (PHP_INT_SIZE < 8) {
6    die("skip 64bit test only");
7}
8?>
9--FILE--
10<?php
11print_r(unpack("Q", pack("Q", 0xfffffffffffe)));
12print_r(unpack("Q", pack("Q", 0)));
13print_r(unpack("Q", pack("Q", 0x8000000000000002)));
14print_r(unpack("Q", pack("Q", -1)));
15print_r(unpack("Q", pack("Q", 0x8000000000000000)));
16
17print_r(unpack("J", pack("J", 0xfffffffffffe)));
18print_r(unpack("J", pack("J", 0)));
19print_r(unpack("J", pack("J", 0x8000000000000002)));
20print_r(unpack("J", pack("J", -1)));
21print_r(unpack("J", pack("J", 0x8000000000000000)));
22
23print_r(unpack("P", pack("P", 0xfffffffffffe)));
24print_r(unpack("P", pack("P", 0)));
25print_r(unpack("P", pack("P", 0x8000000000000002)));
26print_r(unpack("P", pack("P", -1)));
27print_r(unpack("P", pack("P", 0x8000000000000000)));
28
29print_r(unpack("q", pack("q", 0xfffffffffffe)));
30print_r(unpack("q", pack("q", 0)));
31print_r(unpack("q", pack("q", 0x8000000000000002)));
32print_r(unpack("q", pack("q", -1)));
33print_r(unpack("q", pack("q", 0x8000000000000000)));
34
35print_r(unpack("i", pack("i",  2147483647))); // Max int32
36print_r(unpack("i", pack("i", -2147483647)));
37print_r(unpack("i", pack("i", -2147483648))); // Min int32
38print_r(unpack("I", pack("I",  4294967295))); // Max uint32
39?>
40--EXPECT--
41Array
42(
43    [1] => 281474976710654
44)
45Array
46(
47    [1] => 0
48)
49Array
50(
51    [1] => -9223372036854775808
52)
53Array
54(
55    [1] => -1
56)
57Array
58(
59    [1] => -9223372036854775808
60)
61Array
62(
63    [1] => 281474976710654
64)
65Array
66(
67    [1] => 0
68)
69Array
70(
71    [1] => -9223372036854775808
72)
73Array
74(
75    [1] => -1
76)
77Array
78(
79    [1] => -9223372036854775808
80)
81Array
82(
83    [1] => 281474976710654
84)
85Array
86(
87    [1] => 0
88)
89Array
90(
91    [1] => -9223372036854775808
92)
93Array
94(
95    [1] => -1
96)
97Array
98(
99    [1] => -9223372036854775808
100)
101Array
102(
103    [1] => 281474976710654
104)
105Array
106(
107    [1] => 0
108)
109Array
110(
111    [1] => -9223372036854775808
112)
113Array
114(
115    [1] => -1
116)
117Array
118(
119    [1] => -9223372036854775808
120)
121Array
122(
123    [1] => 2147483647
124)
125Array
126(
127    [1] => -2147483647
128)
129Array
130(
131    [1] => -2147483648
132)
133Array
134(
135    [1] => 4294967295
136)
137