1
0
mirror of https://github.com/php/php-src.git synced 2026-04-29 19:23:22 +02:00
Files
archived-php-src/ext/standard/tests/strings/pack64_32.phpt
T
Nikita Popov de77344de2 Promote pack/unpack format errors
Errors related to invalid format strings (unlike data mismatch
errors) should throw ValueError.

Closes GH-6185.
2020-09-22 15:12:05 +02:00

63 lines
1.4 KiB
PHP

--TEST--
64bit pack()/unpack() tests
--SKIPIF--
<?php
if (PHP_INT_SIZE > 4) {
die("skip 32bit test only");
}
?>
--FILE--
<?php
try {
var_dump(pack("Q", 0));
} catch (ValueError $e) {
echo $e->getMessage(), "\n";
}
try {
var_dump(pack("J", 0));
} catch (ValueError $e) {
echo $e->getMessage(), "\n";
}
try {
var_dump(pack("P", 0));
} catch (ValueError $e) {
echo $e->getMessage(), "\n";
}
try {
var_dump(pack("q", 0));
} catch (ValueError $e) {
echo $e->getMessage(), "\n";
}
try {
var_dump(unpack("Q", ''));
} catch (ValueError $e) {
echo $e->getMessage(), "\n";
}
try {
var_dump(unpack("J", ''));
} catch (ValueError $e) {
echo $e->getMessage(), "\n";
}
try {
var_dump(unpack("P", ''));
} catch (ValueError $e) {
echo $e->getMessage(), "\n";
}
try {
var_dump(unpack("q", ''));
} catch (ValueError $e) {
echo $e->getMessage(), "\n";
}
?>
--EXPECTF--
64-bit format codes are not available for 32-bit versions of PHP
64-bit format codes are not available for 32-bit versions of PHP
64-bit format codes are not available for 32-bit versions of PHP
64-bit format codes are not available for 32-bit versions of PHP
64-bit format codes are not available for 32-bit versions of PHP
64-bit format codes are not available for 32-bit versions of PHP
64-bit format codes are not available for 32-bit versions of PHP
64-bit format codes are not available for 32-bit versions of PHP