@@ -456,38 +456,38 @@ mod tests {
456456 }
457457
458458 #[ track_caller]
459- fn assert_to_string ( expected : & str , b : ByteSize , si : bool ) {
460- assert_eq ! ( expected. to_string( ) , b . to_string_as ( si ) ) ;
459+ fn assert_to_string ( expected : & str , b : ByteSize , format : Format ) {
460+ assert_eq ! ( expected. to_string( ) , to_string_format ( b . 0 , format ) ) ;
461461 }
462462
463463 #[ test]
464464 fn test_to_string_as ( ) {
465- assert_to_string ( "215 B" , ByteSize :: b ( 215 ) , false ) ;
466- assert_to_string ( "215 B" , ByteSize :: b ( 215 ) , true ) ;
465+ assert_to_string ( "215 B" , ByteSize :: b ( 215 ) , Format :: IEC ) ;
466+ assert_to_string ( "215 B" , ByteSize :: b ( 215 ) , Format :: SI ) ;
467467
468- assert_to_string ( "1.0 KiB" , ByteSize :: kib ( 1 ) , false ) ;
469- assert_to_string ( "1.0 kB" , ByteSize :: kib ( 1 ) , true ) ;
468+ assert_to_string ( "1.0 KiB" , ByteSize :: kib ( 1 ) , Format :: IEC ) ;
469+ assert_to_string ( "1.0 kB" , ByteSize :: kib ( 1 ) , Format :: SI ) ;
470470
471- assert_to_string ( "293.9 KiB" , ByteSize :: kb ( 301 ) , false ) ;
472- assert_to_string ( "301.0 kB" , ByteSize :: kb ( 301 ) , true ) ;
471+ assert_to_string ( "293.9 KiB" , ByteSize :: kb ( 301 ) , Format :: IEC ) ;
472+ assert_to_string ( "301.0 kB" , ByteSize :: kb ( 301 ) , Format :: SI ) ;
473473
474- assert_to_string ( "1024.0 KiB" , ByteSize :: mib ( 1 ) , false ) ;
475- assert_to_string ( "1.0 MB" , ByteSize :: mib ( 1 ) , true ) ;
474+ assert_to_string ( "1024.0 KiB" , ByteSize :: mib ( 1 ) , Format :: IEC ) ;
475+ assert_to_string ( "1.0 MB" , ByteSize :: mib ( 1 ) , Format :: SI ) ;
476476
477- assert_to_string ( "1.9 GiB" , ByteSize :: mib ( 1907 ) , false ) ;
478- assert_to_string ( "2.0 GB" , ByteSize :: mib ( 1908 ) , true ) ;
477+ assert_to_string ( "1.9 GiB" , ByteSize :: mib ( 1907 ) , Format :: IEC ) ;
478+ assert_to_string ( "2.0 GB" , ByteSize :: mib ( 1908 ) , Format :: SI ) ;
479479
480- assert_to_string ( "399.6 MiB" , ByteSize :: mb ( 419 ) , false ) ;
481- assert_to_string ( "419.0 MB" , ByteSize :: mb ( 419 ) , true ) ;
480+ assert_to_string ( "399.6 MiB" , ByteSize :: mb ( 419 ) , Format :: IEC ) ;
481+ assert_to_string ( "419.0 MB" , ByteSize :: mb ( 419 ) , Format :: SI ) ;
482482
483- assert_to_string ( "482.4 GiB" , ByteSize :: gb ( 518 ) , false ) ;
484- assert_to_string ( "518.0 GB" , ByteSize :: gb ( 518 ) , true ) ;
483+ assert_to_string ( "482.4 GiB" , ByteSize :: gb ( 518 ) , Format :: IEC ) ;
484+ assert_to_string ( "518.0 GB" , ByteSize :: gb ( 518 ) , Format :: SI ) ;
485485
486- assert_to_string ( "741.2 TiB" , ByteSize :: tb ( 815 ) , false ) ;
487- assert_to_string ( "815.0 TB" , ByteSize :: tb ( 815 ) , true ) ;
486+ assert_to_string ( "741.2 TiB" , ByteSize :: tb ( 815 ) , Format :: IEC ) ;
487+ assert_to_string ( "815.0 TB" , ByteSize :: tb ( 815 ) , Format :: SI ) ;
488488
489- assert_to_string ( "540.9 PiB" , ByteSize :: pb ( 609 ) , false ) ;
490- assert_to_string ( "609.0 PB" , ByteSize :: pb ( 609 ) , true ) ;
489+ assert_to_string ( "540.9 PiB" , ByteSize :: pb ( 609 ) , Format :: IEC ) ;
490+ assert_to_string ( "609.0 PB" , ByteSize :: pb ( 609 ) , Format :: SI ) ;
491491 }
492492
493493 #[ test]
@@ -497,6 +497,6 @@ mod tests {
497497
498498 #[ test]
499499 fn test_to_string ( ) {
500- assert_to_string ( "609.0 PB" , ByteSize :: pb ( 609 ) , true ) ;
500+ assert_to_string ( "609.0 PB" , ByteSize :: pb ( 609 ) , Format :: SI ) ;
501501 }
502502}
0 commit comments