xref: /PHP-7.1/ext/standard/tests/strings/pack64.phpt (revision 63fd9693)
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?>
35--EXPECTF--
36Array
37(
38    [1] => 281474976710654
39)
40Array
41(
42    [1] => 0
43)
44Array
45(
46    [1] => -9223372036854775808
47)
48Array
49(
50    [1] => -1
51)
52Array
53(
54    [1] => -9223372036854775808
55)
56Array
57(
58    [1] => 281474976710654
59)
60Array
61(
62    [1] => 0
63)
64Array
65(
66    [1] => -9223372036854775808
67)
68Array
69(
70    [1] => -1
71)
72Array
73(
74    [1] => -9223372036854775808
75)
76Array
77(
78    [1] => 281474976710654
79)
80Array
81(
82    [1] => 0
83)
84Array
85(
86    [1] => -9223372036854775808
87)
88Array
89(
90    [1] => -1
91)
92Array
93(
94    [1] => -9223372036854775808
95)
96Array
97(
98    [1] => 281474976710654
99)
100Array
101(
102    [1] => 0
103)
104Array
105(
106    [1] => -9223372036854775808
107)
108Array
109(
110    [1] => -1
111)
112Array
113(
114    [1] => -9223372036854775808
115)
116