Make WordPress Core


Ignore:
Timestamp:
01/05/2015 01:12:06 PM (7 years ago)
Author:
pento
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/functions.php

    r30561 r31052  
    4040    }
    4141    function test_size_format() {
     42        $b  = 1;
    4243        $kb = 1024;
    4344        $mb = $kb*1024;
     
    4849        $this->assertEquals('1 MB', size_format($mb, 0));
    4950        $this->assertEquals('1 kB', size_format($kb, 0));
     51        $this->assertEquals('1 B',  size_format($b, 0));
    5052        // now some values around
    5153        // add some bytes to make sure the result isn't 1.4999999
Note: See TracChangeset for help on using the changeset viewer.