summaryrefslogtreecommitdiff
path: root/ext/gmp/tests
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2014-04-17 11:11:51 +0200
committerOndřej Surý <ondrej@sury.org>2014-04-17 11:11:51 +0200
commit9566c3fcaf4cfaa866ea395ee5d1a480785fef0d (patch)
treed053b8b66afe080ea2250d5fbcdfc21c243d54ab /ext/gmp/tests
parent30bdcf2392ef8cc7b8b4a07b49367571ae1db286 (diff)
downloadphp-9566c3fcaf4cfaa866ea395ee5d1a480785fef0d.tar.gz
New upstream version 5.6.0~beta1+dfsgupstream/5.6.0_beta1+dfsg
Diffstat (limited to 'ext/gmp/tests')
-rw-r--r--ext/gmp/tests/041.phpt147
-rw-r--r--ext/gmp/tests/bug66872.phpt13
2 files changed, 160 insertions, 0 deletions
diff --git a/ext/gmp/tests/041.phpt b/ext/gmp/tests/041.phpt
new file mode 100644
index 000000000..6e6d95928
--- /dev/null
+++ b/ext/gmp/tests/041.phpt
@@ -0,0 +1,147 @@
+--TEST--
+gmp_root() and gmp_rootrem() basic tests
+--SKIPIF--
+<?php if (!extension_loaded("gmp")) print "skip"; ?>
+--FILE--
+<?php
+
+var_dump(gmp_root(1000, 3));
+var_dump(gmp_root(100, 3));
+var_dump(gmp_root(-100, 3));
+
+var_dump(gmp_root(1000, 4));
+var_dump(gmp_root(100, 4));
+var_dump(gmp_root(-100, 4));
+
+var_dump(gmp_root(0, 3));
+var_dump(gmp_root(100, 0));
+var_dump(gmp_root(100, -3));
+
+var_dump(gmp_rootrem(1000, 3));
+var_dump(gmp_rootrem(100, 3));
+var_dump(gmp_rootrem(-100, 3));
+
+var_dump(gmp_rootrem(1000, 4));
+var_dump(gmp_rootrem(100, 4));
+var_dump(gmp_rootrem(-100, 4));
+
+var_dump(gmp_rootrem(0, 3));
+var_dump(gmp_rootrem(100, 0));
+var_dump(gmp_rootrem(100, -3));
+
+?>
+--EXPECTF--
+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/bug66872.phpt b/ext/gmp/tests/bug66872.phpt
new file mode 100644
index 000000000..434af30b8
--- /dev/null
+++ b/ext/gmp/tests/bug66872.phpt
@@ -0,0 +1,13 @@
+--TEST--
+Bug #66872: Crash when passing string to gmp_testbit
+--SKIPIF--
+<?php if (!extension_loaded("gmp")) print "skip"; ?>
+--FILE--
+<?php
+
+var_dump(gmp_testbit("abc", 1));
+
+?>
+--EXPECTF--
+Warning: gmp_testbit(): Unable to convert variable to GMP - string is not an integer in %s on line %d
+bool(false)