diff options
author | Leigh <leight@gmail.com> | 2014-09-23 22:54:40 +0100 |
---|---|---|
committer | Leigh <leight@gmail.com> | 2014-09-23 22:54:40 +0100 |
commit | 31e27fc89ac0403aeac5ad02f09a308e830f1f05 (patch) | |
tree | d8b548aac89b425c706b76410e2b357c8fc132aa /ext/gmp | |
parent | 831bb9260c314290a34635d7a907673f8e9d9063 (diff) | |
download | php-git-31e27fc89ac0403aeac5ad02f09a308e830f1f05.tar.gz |
Add test files
Diffstat (limited to 'ext/gmp')
-rw-r--r-- | ext/gmp/gmp.c | 4 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_random_bits.phpt | 19 | ||||
-rw-r--r-- | ext/gmp/tests/gmp_random_range.phpt | 11 |
3 files changed, 32 insertions, 2 deletions
diff --git a/ext/gmp/gmp.c b/ext/gmp/gmp.c index 36c8260f5b..d38311a5be 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 0000000000..9046177e38 --- /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 0000000000..93074f2913 --- /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 |