mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-14 01:24:27 +00:00
size_format() incorrectly included a trailing space for B values: less than 1024 bytes.
Also add a unit test to check for this, so we don't do it again. Fixes #30908. Props tillkruess. git-svn-id: https://develop.svn.wordpress.org/trunk@31052 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -39,6 +39,7 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
$this->assertEquals($ss, wp_parse_args($q));
|
||||
}
|
||||
function test_size_format() {
|
||||
$b = 1;
|
||||
$kb = 1024;
|
||||
$mb = $kb*1024;
|
||||
$gb = $mb*1024;
|
||||
@@ -47,6 +48,7 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
$this->assertEquals('1 GB', size_format($gb, 0));
|
||||
$this->assertEquals('1 MB', size_format($mb, 0));
|
||||
$this->assertEquals('1 kB', size_format($kb, 0));
|
||||
$this->assertEquals('1 B', size_format($b, 0));
|
||||
// now some values around
|
||||
// add some bytes to make sure the result isn't 1.4999999
|
||||
$this->assertEquals('1.5 TB', size_format($tb + $tb/2 + $mb, 1));
|
||||
|
||||
Reference in New Issue
Block a user