com php-src: Add test files: ext/gmp/gmp.c ext/gmp/tests/gmp_ random_bits.phpt ext/gmp/tests/gmp_random_range.php t
| From: | Stanislav Malyshev | Date: | Tue, 23 Sep 2014 21:54:40 +0000 |
| Subject: | com php-src: Add test files: ext/gmp/gmp.c ext/gmp/tests/gmp_ random_bits.phpt ext/gmp/tests/gmp_random_range.php t | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-82276@lists.php.net to get a copy of this message | ||
Commit: 31e27fc89ac0403aeac5ad02f09a308e830f1f05
Author: Leigh <leight@gmail.com> Tue, 23 Sep 2014 22:54:40 +0100
Parents: 831bb9260c314290a34635d7a907673f8e9d9063
Branches: PHP-5.6
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=31e27fc89ac0403aeac5ad02f09a308e830f1f05
Log:
Add test files
Changed paths:
M ext/gmp/gmp.c
A ext/gmp/tests/gmp_random_bits.phpt
A ext/gmp/tests/gmp_random_range.phpt
Diff:
diff --git a/ext/gmp/gmp.c b/ext/gmp/gmp.c
index 36c8260..d38311a 100644
--- a/ext/gmp/gmp.c
+++ b/ext/gmp/gmp.c
@@ -1841,9 +1841,9 @@ ZEND_FUNCTION(gmp_random_bits)
return;
}
- if (bits < 0) {
+ if (bits <= 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "The number of bits must be positive");
- RETURN_FALSE;
+ return;
}
INIT_GMP_RETVAL(gmpnum_result);
diff --git a/ext/gmp/tests/gmp_random_bits.phpt b/ext/gmp/tests/gmp_random_bits.phpt
new file mode 100644
index 0000000..9046177
--- /dev/null
+++ b/ext/gmp/tests/gmp_random_bits.phpt
@@ -0,0 +1,19 @@
+--TEST--
+gmp_random_bits() basic tests
+--SKIPIF--
+<?php if (!extension_loaded("gmp")) print "skip"; ?>
+--FILE--
+<?php
+
+var_dump(gmp_random_bits(0));
+var_dump(gmp_random_bits(-1));
+
+echo "Done\n";
+?>
+--EXPECTF--
+Warning: gmp_random_bits(): The number of bits must be positive in %s on line %d
+NULL
+
+Warning: gmp_random_bits(): The number of bits must be positive in %s on line %d
+NULL
+Done
diff --git a/ext/gmp/tests/gmp_random_range.phpt b/ext/gmp/tests/gmp_random_range.phpt
new file mode 100644
index 0000000..93074f2
--- /dev/null
+++ b/ext/gmp/tests/gmp_random_range.phpt
@@ -0,0 +1,11 @@
+--TEST--
+gmp_random_range() basic tests
+--SKIPIF--
+<?php if (!extension_loaded("gmp")) print "skip"; ?>
+--FILE--
+<?php
+
+echo "Done\n";
+?>
+--EXPECTF--
+Done