From 03797a73b25996315b6c6ce606a9d8724439699e Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 4 Sep 2014 21:14:17 +0200 Subject: Split GMP tests testing multiple functions Also drop dummy test --- ext/gmp/tests/001.phpt | 21 ----- ext/gmp/tests/041.phpt | 155 ------------------------------------- ext/gmp/tests/gmp_export.phpt | 80 +++++++++++++++++++ ext/gmp/tests/gmp_import.phpt | 91 ++++++++++++++++++++++ ext/gmp/tests/gmp_remroot.phpt | 106 ++++++++++++++++++++++++++ ext/gmp/tests/gmp_root.phpt | 58 ++++++++++++++ ext/gmp/tests/import-export.phpt | 161 --------------------------------------- 7 files changed, 335 insertions(+), 337 deletions(-) delete mode 100644 ext/gmp/tests/001.phpt delete mode 100644 ext/gmp/tests/041.phpt create mode 100644 ext/gmp/tests/gmp_export.phpt create mode 100644 ext/gmp/tests/gmp_import.phpt create mode 100644 ext/gmp/tests/gmp_remroot.phpt create mode 100644 ext/gmp/tests/gmp_root.phpt delete mode 100644 ext/gmp/tests/import-export.phpt diff --git a/ext/gmp/tests/001.phpt b/ext/gmp/tests/001.phpt deleted file mode 100644 index 5126f73142..0000000000 --- a/ext/gmp/tests/001.phpt +++ /dev/null @@ -1,21 +0,0 @@ ---TEST-- -Check for gmp presence ---SKIPIF-- - ---FILE-- - ---EXPECT-- -gmp extension is available diff --git a/ext/gmp/tests/041.phpt b/ext/gmp/tests/041.phpt deleted file mode 100644 index cd442b1a54..0000000000 --- a/ext/gmp/tests/041.phpt +++ /dev/null @@ -1,155 +0,0 @@ ---TEST-- -gmp_root() and gmp_rootrem() basic tests ---SKIPIF-- - ---FILE-- - ---EXPECTF-- -Warning: gmp_root() expects exactly 2 parameters, 0 given in %s on line %d -NULL - -Warning: gmp_rootrem() expects exactly 2 parameters, 0 given in %s on line %d -NULL -object(GMP)#%d (1) { - ["num"]=> - string(2) "10" -} -object(GMP)#%d (1) { - ["num"]=> - string(1) "4" -} -object(GMP)#%d (1) { - ["num"]=> - string(2) "-4" -} -object(GMP)#%d (1) { - ["num"]=> - string(1) "5" -} -object(GMP)#%d (1) { - ["num"]=> - string(1) "3" -} - -Warning: gmp_root(): Can't take even root of negative number in %s on line %d -bool(false) -object(GMP)#%d (1) { - ["num"]=> - string(1) "0" -} - -Warning: gmp_root(): The root must be positive in %s on line %d -bool(false) - -Warning: gmp_root(): The root must be positive in %s on line %d -bool(false) -array(2) { - [0]=> - object(GMP)#%d (1) { - ["num"]=> - string(2) "10" - } - [1]=> - object(GMP)#%d (1) { - ["num"]=> - string(1) "0" - } -} -array(2) { - [0]=> - object(GMP)#%d (1) { - ["num"]=> - string(1) "4" - } - [1]=> - object(GMP)#%d (1) { - ["num"]=> - string(2) "36" - } -} -array(2) { - [0]=> - object(GMP)#%d (1) { - ["num"]=> - string(2) "-4" - } - [1]=> - object(GMP)#%d (1) { - ["num"]=> - string(2) "36" - } -} -array(2) { - [0]=> - object(GMP)#%d (1) { - ["num"]=> - string(1) "5" - } - [1]=> - object(GMP)#%d (1) { - ["num"]=> - string(3) "375" - } -} -array(2) { - [0]=> - object(GMP)#%d (1) { - ["num"]=> - string(1) "3" - } - [1]=> - object(GMP)#%d (1) { - ["num"]=> - string(2) "19" - } -} - -Warning: gmp_rootrem(): Can't take even root of negative number in %s on line %d -bool(false) -array(2) { - [0]=> - object(GMP)#%d (1) { - ["num"]=> - string(1) "0" - } - [1]=> - object(GMP)#%d (1) { - ["num"]=> - string(1) "0" - } -} - -Warning: gmp_rootrem(): The root must be positive in %s on line %d -bool(false) - -Warning: gmp_rootrem(): The root must be positive in %s on line %d -bool(false) diff --git a/ext/gmp/tests/gmp_export.phpt b/ext/gmp/tests/gmp_export.phpt new file mode 100644 index 0000000000..fbc8901cfc --- /dev/null +++ b/ext/gmp/tests/gmp_export.phpt @@ -0,0 +1,80 @@ +--TEST-- +gmp_export() basic tests +--SKIPIF-- + +--FILE-- + $test) { + $gmp = gmp_init($test[0], 16); + $str = gmp_export($gmp, $test[1], $test[2]); + if (is_string($str)) { + $result = bin2hex($str); + if ($result !== $test[3]) { + echo "$k: '$result' !== '{$test[3]}'\n"; + $passed = false; + } + } else { + $type = gettype($str); + echo "$k: $type !== '{$test[3]}'\n"; + } +} + +var_dump($passed); + +// Invalid arguments (zpp failure) +var_dump(gmp_export()); + +// Invalid word sizes +var_dump(gmp_export(123, -1)); +var_dump(gmp_export(123, 0)); + +// Invalid options +var_dump(gmp_export(123, 1, GMP_MSW_FIRST | GMP_LSW_FIRST)); +var_dump(gmp_export(123, 1, GMP_BIG_ENDIAN | GMP_LITTLE_ENDIAN)); + +--EXPECTF-- +bool(true) + +Warning: gmp_export() expects at least 1 parameter, 0 given in %s on line %d +NULL + +Warning: gmp_export(): Word size must be positive, -1 given in %s on line %d +bool(false) + +Warning: gmp_export(): Word size must be positive, 0 given in %s on line %d +bool(false) + +Warning: gmp_export(): Invalid options: Conflicting word orders in %s on line %d +bool(false) + +Warning: gmp_export(): Invalid options: Conflicting word endianness in %s on line %d +bool(false) diff --git a/ext/gmp/tests/gmp_import.phpt b/ext/gmp/tests/gmp_import.phpt new file mode 100644 index 0000000000..b7ae6600ed --- /dev/null +++ b/ext/gmp/tests/gmp_import.phpt @@ -0,0 +1,91 @@ +--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) diff --git a/ext/gmp/tests/gmp_remroot.phpt b/ext/gmp/tests/gmp_remroot.phpt new file mode 100644 index 0000000000..4a3539d87c --- /dev/null +++ b/ext/gmp/tests/gmp_remroot.phpt @@ -0,0 +1,106 @@ +--TEST-- +gmp_rootrem() basic tests +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +Warning: gmp_rootrem() expects exactly 2 parameters, 0 given in %s on line %d +NULL +array(2) { + [0]=> + object(GMP)#%d (1) { + ["num"]=> + string(2) "10" + } + [1]=> + object(GMP)#%d (1) { + ["num"]=> + string(1) "0" + } +} +array(2) { + [0]=> + object(GMP)#%d (1) { + ["num"]=> + string(1) "4" + } + [1]=> + object(GMP)#%d (1) { + ["num"]=> + string(2) "36" + } +} +array(2) { + [0]=> + object(GMP)#%d (1) { + ["num"]=> + string(2) "-4" + } + [1]=> + object(GMP)#%d (1) { + ["num"]=> + string(2) "36" + } +} +array(2) { + [0]=> + object(GMP)#%d (1) { + ["num"]=> + string(1) "5" + } + [1]=> + object(GMP)#%d (1) { + ["num"]=> + string(3) "375" + } +} +array(2) { + [0]=> + object(GMP)#%d (1) { + ["num"]=> + string(1) "3" + } + [1]=> + object(GMP)#%d (1) { + ["num"]=> + string(2) "19" + } +} + +Warning: gmp_rootrem(): Can't take even root of negative number in %s on line %d +bool(false) +array(2) { + [0]=> + object(GMP)#%d (1) { + ["num"]=> + string(1) "0" + } + [1]=> + object(GMP)#%d (1) { + ["num"]=> + string(1) "0" + } +} + +Warning: gmp_rootrem(): The root must be positive in %s on line %d +bool(false) + +Warning: gmp_rootrem(): The root must be positive in %s on line %d +bool(false) diff --git a/ext/gmp/tests/gmp_root.phpt b/ext/gmp/tests/gmp_root.phpt new file mode 100644 index 0000000000..70faf27051 --- /dev/null +++ b/ext/gmp/tests/gmp_root.phpt @@ -0,0 +1,58 @@ +--TEST-- +gmp_root() basic tests +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +Warning: gmp_root() expects exactly 2 parameters, 0 given in %s on line %d +NULL +object(GMP)#%d (1) { + ["num"]=> + string(2) "10" +} +object(GMP)#%d (1) { + ["num"]=> + string(1) "4" +} +object(GMP)#%d (1) { + ["num"]=> + string(2) "-4" +} +object(GMP)#%d (1) { + ["num"]=> + string(1) "5" +} +object(GMP)#%d (1) { + ["num"]=> + string(1) "3" +} + +Warning: gmp_root(): Can't take even root of negative number in %s on line %d +bool(false) +object(GMP)#%d (1) { + ["num"]=> + string(1) "0" +} + +Warning: gmp_root(): The root must be positive in %s on line %d +bool(false) + +Warning: gmp_root(): The root must be positive in %s on line %d +bool(false) diff --git a/ext/gmp/tests/import-export.phpt b/ext/gmp/tests/import-export.phpt deleted file mode 100644 index 42000a10fc..0000000000 --- a/ext/gmp/tests/import-export.phpt +++ /dev/null @@ -1,161 +0,0 @@ ---TEST-- -Check gmp_import and gmp_export behave as intended ---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); - -echo "\nExport:\n"; -$passed = true; -foreach ($export as $k => $test) { - $gmp = gmp_init($test[0], 16); - $str = gmp_export($gmp, $test[1], $test[2]); - if (is_string($str)) { - $result = bin2hex($str); - if ($result !== $test[3]) { - echo "$k: '$result' !== '{$test[3]}'\n"; - $passed = false; - } - } else { - $type = gettype($str); - echo "$k: $type !== '{$test[3]}'\n"; - } -} - -var_dump($passed); - -// Invalid arguments (zpp failure) -var_dump(gmp_import()); -var_dump(gmp_export()); - -// Invalid word sizes -var_dump(gmp_import('a', -1)); -var_dump(gmp_import('a', 0)); -var_dump(gmp_export(123, -1)); -var_dump(gmp_export(123, 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)); - -var_dump(gmp_export(123, 1, GMP_MSW_FIRST | GMP_LSW_FIRST)); -var_dump(gmp_export(123, 1, GMP_BIG_ENDIAN | GMP_LITTLE_ENDIAN)); - ---EXPECTF-- -Import: -bool(true) - -Export: -bool(true) - -Warning: gmp_import() expects at least 1 parameter, 0 given in %s on line %d -NULL - -Warning: gmp_export() 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_export(): Word size must be positive, -1 given in %s on line %d -bool(false) - -Warning: gmp_export(): 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) - -Warning: gmp_export(): Invalid options: Conflicting word orders in %s on line %d -bool(false) - -Warning: gmp_export(): Invalid options: Conflicting word endianness in %s on line %d -bool(false) -- cgit v1.2.1