Changeset 37962
- Timestamp:
- 07/05/2016 10:35:24 AM (9 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/functions.php
r37944 r37962 263 263 'B' => 1, 264 264 ); 265 266 if ( 0 === $bytes ) { 267 return number_format_i18n( 0, $decimals ) . ' B'; 268 } 265 269 266 270 foreach ( $quant as $unit => $mag ) { -
trunk/tests/phpunit/tests/functions.php
r37718 r37962 50 50 $this->assertInternalType( 'string', $args['foo'] ); 51 51 $this->assertInternalType( 'string', $args['bar'] ); 52 }53 54 function test_size_format() {55 $b = 1;56 $kb = 1024;57 $mb = $kb*1024;58 $gb = $mb*1024;59 $tb = $gb*1024;60 // test if boundaries are correct61 $this->assertEquals('1 GB', size_format($gb, 0));62 $this->assertEquals('1 MB', size_format($mb, 0));63 $this->assertEquals('1 KB', size_format($kb, 0));64 $this->assertEquals('1 B', size_format($b, 0));65 // now some values around66 // add some bytes to make sure the result isn't 1.499999967 $this->assertEquals('1.5 TB', size_format($tb + $tb/2 + $mb, 1));68 $this->assertEquals('1,023.999 GB', size_format($tb-$mb-$kb, 3));69 // edge70 $this->assertFalse(size_format(-1));71 $this->assertFalse(size_format(0));72 $this->assertFalse(size_format('baba'));73 $this->assertFalse(size_format(array()));74 52 } 75 53
Note: See TracChangeset
for help on using the changeset viewer.