test: remove deprecated MT_RAND_PHP and fix mt_rand() upper bound#208
test: remove deprecated MT_RAND_PHP and fix mt_rand() upper bound#208DASPRiD merged 1 commit intoBacon:mainfrom
Conversation
- Switched RNG to the default MT_RAND_MT19937 (removed deprecated MT_RAND_PHP). - Fixed off-by-one in mt_rand(0, $blockSize) — the upper bound was not hit with the previous mode, but is reached with MT_RAND_MT19937, causing OutOfBoundsException. Changed to mt_rand(0, $blockSize - 1).
|
By the way, this code is useless and looks like some sort of leftover: BaconQrCode/test/Common/BitArrayTest.php Lines 114 to 116 in bd2370d |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #208 +/- ##
=========================================
Coverage 70.58% 70.58%
Complexity 995 995
=========================================
Files 49 49
Lines 3182 3182
=========================================
Hits 2246 2246
Misses 936 936 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
You are right, looking at the source test, that line does not exist and can be removed. |
|
LGTM, you can remove that useless test code in another PR :) |
As discussed in PR Bacon#208, lines 114–116 in BitArrayTest.php are useless and appear to be leftover code. They do not exist in the source test logic and can safely be removed.
As discussed in PR #208, lines 114–116 in BitArrayTest.php are useless and appear to be leftover code. They do not exist in the source test logic and can safely be removed.
Fixes #176.
The test previously seeded error locations with:
This allowed
$errorLocationto equal$blockSize, which is out of range for an array of length$blockSize(valid indices are0 … $blockSize - 1).OutOfBoundsException.Fix: Correct the upper bound to
$blockSize - 1: