File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -40,7 +40,8 @@ fn get_repo_size(repo: &Repository) -> (String, u64) {
40
40
41
41
fn bytes_to_human_readable ( bytes : u64 ) -> String {
42
42
let byte = Byte :: from_u64 ( bytes) ;
43
- byte. get_appropriate_unit ( UnitType :: Binary ) . to_string ( )
43
+ let adjusted_byte_based = byte. get_appropriate_unit ( UnitType :: Binary ) ;
44
+ format ! ( "{adjusted_byte_based:#.2}" )
44
45
}
45
46
46
47
impl std:: fmt:: Display for SizeInfo {
@@ -115,7 +116,8 @@ mod test {
115
116
case( 1024 , "1 KiB" ) ,
116
117
case( 2048 , "2 KiB" ) ,
117
118
case( 1048576 , "1 MiB" ) ,
118
- case( 1099511627776 , "1 TiB" )
119
+ case( 1099511627776 , "1 TiB" ) ,
120
+ case( 2577152 , "2.46 MiB" )
119
121
) ]
120
122
fn test_bytes_to_human_readable ( #[ case] input : u64 , #[ case] expected : & str ) {
121
123
assert_eq ! ( bytes_to_human_readable( input) , expected) ;
You can’t perform that action at this time.
0 commit comments