Make WordPress Core

Ticket #23626: 23626.test.patch

File 23626.test.patch, 1.1 KB (added by SergeyBiryukov, 12 years ago)
  • tests/media.php

     
    151151                $kb = 1024;
    152152                $mb = $kb * 1024;
    153153                $gb = $mb * 1024;
     154                $tb = $gb * 1024;
    154155
    155156                // test if boundaries are correct
    156157                $this->assertEquals( '1GB', wp_convert_bytes_to_hr( $gb ) );
     
    158159                $this->assertEquals( '1kB', wp_convert_bytes_to_hr( $kb ) );
    159160
    160161                // now some values around
     162                $this->assertTrue( abs( 1.64926849024E+12 - (float) wp_convert_bytes_to_hr( $tb + $tb / 2 + $mb ) ) < 0.0001 );
     163                $this->assertTrue( abs( 1023.99902248 - (float) wp_convert_bytes_to_hr( $tb - $mb - $kb ) ) < 0.0001 );
    161164                $this->assertTrue( abs( 1.5009765625 - (float) wp_convert_bytes_to_hr( $gb + $gb / 2 + $mb ) ) < 0.0001 );
    162165                $this->assertTrue( abs( 1022.99902344 - (float) wp_convert_bytes_to_hr( $gb - $mb - $kb ) ) < 0.0001 );
    163166
    164167                // edge
    165                 $this->assertEquals( 'NANB', wp_convert_bytes_to_hr( -1 ) );
     168                $this->assertEquals( '-1B', wp_convert_bytes_to_hr( -1 ) );
    166169                $this->assertEquals( '0B', wp_convert_bytes_to_hr( 0 ) );
    167170        }
    168171}