Make WordPress Core

Changeset 1226 in tests


Ignore:
Timestamp:
03/01/2013 03:56:51 PM (9 years ago)
Author:
SergeyBiryukov
Message:

Add more assertions for wp_convert_bytes_to_hr(). Correct expected result for a negative number. see #23626.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/media.php

    r1220 r1226  
    152152        $mb = $kb * 1024;
    153153        $gb = $mb * 1024;
     154        $tb = $gb * 1024;
    154155
    155156        // test if boundaries are correct
     157        $this->assertEquals( '1TB', wp_convert_bytes_to_hr( $tb ) );
    156158        $this->assertEquals( '1GB', wp_convert_bytes_to_hr( $gb ) );
    157159        $this->assertEquals( '1MB', wp_convert_bytes_to_hr( $mb ) );
     
    159161
    160162        // now some values around
     163        $this->assertTrue( abs( 1.50000095367 - (float) wp_convert_bytes_to_hr( $tb + $tb / 2 + $mb ) ) < 0.0001 );
     164        $this->assertTrue( abs( 1023.99902248 - (float) wp_convert_bytes_to_hr( $tb - $mb - $kb ) ) < 0.0001 );
    161165        $this->assertTrue( abs( 1.5009765625 - (float) wp_convert_bytes_to_hr( $gb + $gb / 2 + $mb ) ) < 0.0001 );
    162166        $this->assertTrue( abs( 1022.99902344 - (float) wp_convert_bytes_to_hr( $gb - $mb - $kb ) ) < 0.0001 );
    163167
    164168        // edge
    165         $this->assertEquals( 'NANB', wp_convert_bytes_to_hr( -1 ) );
     169        $this->assertEquals( '-1B', wp_convert_bytes_to_hr( -1 ) );
    166170        $this->assertEquals( '0B', wp_convert_bytes_to_hr( 0 ) );
    167171    }
Note: See TracChangeset for help on using the changeset viewer.