wp_convert_bytes_to_hr tests and NaN
|Reported by:||soulseekah||Owned by:||SergeyBiryukov|
[1218/tests] were written for the deprecated wp_convert_bytes_to_hr, these tests are broken at least on 64-bit machines, at most - on all machines.
On 64-bit PHP (PHP_INT_SIZE == 8) floating point does not match expected output (gets 1022.9990234375MB). The last digits in floating point should not be depended upon due to these inaccuracies. Rounding in PHP < 5.3 is not an option either, since rounding mode was introduced later and different systems get different results (round up vs. round down by default). So perhaps looking at error and discrepancy would be a decent solution (maybe even less error 0.00001?).
Next , in the function itself we get (int)double(NAN) result from feeding -1 and 0, which results in $power to be a huge negative number instead of 0. This results in both a Warning (undefined array index) being thrown, and the "B" missing in tests, i.e. expected "NANB" != "NAN" and expected "0B" != "0".
Change History (17)
3 years ago
- Owner set to SergeyBiryukov
- Resolution set to fixed
- Status changed from new to closed