--TEST-- gmp_import() basic tests --SKIPIF-- --FILE-- $test) { $gmp = gmp_import(hex2bin($test[3]), $test[1], $test[2]); if ($gmp instanceof GMP) { $result = gmp_strval($gmp, 16); if ($result !== $test[0]) { echo "$k: '$result' !== '{$test[0]}'\n"; $passed = false; } } else { $type = gettype($gmp); echo "$k: $type !== '{$test[0]}'\n"; } } var_dump($passed); // Invalid arguments (zpp failure) var_dump(gmp_import()); // Invalid word sizes var_dump(gmp_import('a', -1)); var_dump(gmp_import('a', 0)); // Invalid data lengths var_dump(gmp_import('a', 2)); var_dump(gmp_import('aa', 3)); var_dump(gmp_import(str_repeat('a', 100), 64)); // Invalid options var_dump(gmp_import('a', 1, GMP_MSW_FIRST | GMP_LSW_FIRST)); var_dump(gmp_import('a', 1, GMP_BIG_ENDIAN | GMP_LITTLE_ENDIAN)); --EXPECTF-- bool(true) Warning: gmp_import() expects at least 1 parameter, 0 given in %s on line %d NULL Warning: gmp_import(): Word size must be positive, -1 given in %s on line %d bool(false) Warning: gmp_import(): Word size must be positive, 0 given in %s on line %d bool(false) Warning: gmp_import(): Input length must be a multiple of word size in %s on line %d bool(false) Warning: gmp_import(): Input length must be a multiple of word size in %s on line %d bool(false) Warning: gmp_import(): Input length must be a multiple of word size in %s on line %d bool(false) Warning: gmp_import(): Invalid options: Conflicting word orders in %s on line %d bool(false) Warning: gmp_import(): Invalid options: Conflicting word endianness in %s on line %d bool(false)