From 31e27fc89ac0403aeac5ad02f09a308e830f1f05 Mon Sep 17 00:00:00 2001 From: Leigh Date: Tue, 23 Sep 2014 22:54:40 +0100 Subject: [PATCH] Add test files --- ext/gmp/gmp.c | 4 ++-- ext/gmp/tests/gmp_random_bits.phpt | 19 +++++++++++++++++++ ext/gmp/tests/gmp_random_range.phpt | 11 +++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 ext/gmp/tests/gmp_random_bits.phpt create mode 100644 ext/gmp/tests/gmp_random_range.phpt 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-- + +--FILE-- + +--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-- + +--FILE-- + +--EXPECTF-- +Done -- 2.40.0