]> granicus.if.org Git - php/commitdiff
Add test files
authorLeigh <leight@gmail.com>
Tue, 23 Sep 2014 21:54:40 +0000 (22:54 +0100)
committerLeigh <leight@gmail.com>
Tue, 23 Sep 2014 21:54:40 +0000 (22:54 +0100)
ext/gmp/gmp.c
ext/gmp/tests/gmp_random_bits.phpt [new file with mode: 0644]
ext/gmp/tests/gmp_random_range.phpt [new file with mode: 0644]

index 36c8260f5b7fcff5c7fe524aa5d930a1b915a20f..d38311a5beb93f1c440e390fcd9f35b932b3032a 100644 (file)
@@ -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 (file)
index 0000000..9046177
--- /dev/null
@@ -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 (file)
index 0000000..93074f2
--- /dev/null
@@ -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