com php-src: Add test for rand with inverted min and max: ext/standard/tests/math/rand_inverted_order.phpt

From: Date: Thu, 07 Sep 2017 10:07:01 +0000
Subject: com php-src: Add test for rand with inverted min and max: ext/standard/tests/math/rand_inverted_order.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-99295@lists.php.net to get a copy of this message
Commit: 141f26e9a9b6633a317742d1c0696b2cfdd8c1cf Author: João Paulo V Martins <joao.paulo@smartbox.com> Sat, 26 Aug 2017 14:18:04 +0100 Committer: Nikita Popov <nikita.ppv@gmail.com> Thu, 7 Sep 2017 12:07:01 +0200 Parents: d254a2cbcace0bdfdf2c9155c45feeb6f25c27ba Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=141f26e9a9b6633a317742d1c0696b2cfdd8c1cf Log: Add test for rand with inverted min and max Both are valid: rand($min, $max); rand($max, $min); Changed paths: A ext/standard/tests/math/rand_inverted_order.phpt Diff: diff --git a/ext/standard/tests/math/rand_inverted_order.phpt b/ext/standard/tests/math/rand_inverted_order..phpt new file mode 100644 index 0000000..ac904b2 --- /dev/null +++ b/ext/standard/tests/math/rand_inverted_order.phpt @@ -0,0 +1,20 @@ +--TEST-- +Test rand funtion when min and max are in proper or inverted order +--CREDIT-- +PHP TestFEst 2017 - PHPDublin, PHPSP - Joao P V Martins <jp.joao@gmail.com> +--FILE-- +<?php +$min_value = 10; +$max_value = 20; +$correct_order = rand($min_value, $max_value); +$incorrect_order = rand($max_value, $min_value); +var_dump($correct_order >= $min_value); +var_dump($correct_order <= $max_value); +var_dump($incorrect_order >= $min_value); +var_dump($incorrect_order <= $max_value); +?> +--EXPECT-- +bool(true) +bool(true) +bool(true) +bool(true)

« previous php.cvs (#99295) next »