@@ -242,28 +242,45 @@ mod tests {
242
242
use crate :: blocks:: { BlockSize , SuffixType , to_magnitude_and_suffix} ;
243
243
244
244
#[ test]
245
- fn test_to_magnitude_and_suffix_powers_of_1024 ( ) {
245
+ fn test_to_magnitude_and_suffix_add_tracing_zero ( ) {
246
246
assert_eq ! ( to_magnitude_and_suffix( 1024 , SuffixType :: Iec , true ) , "1.0K" ) ;
247
+ assert_eq ! ( to_magnitude_and_suffix( 2048 , SuffixType :: Iec , true ) , "2.0K" ) ;
247
248
assert_eq ! ( to_magnitude_and_suffix( 10240 , SuffixType :: Iec , true ) , "10K" ) ;
249
+
250
+ assert_eq ! ( to_magnitude_and_suffix( 1024 , SuffixType :: Iec , false ) , "1K" ) ;
251
+ assert_eq ! ( to_magnitude_and_suffix( 2048 , SuffixType :: Iec , false ) , "2K" ) ;
252
+ assert_eq ! (
253
+ to_magnitude_and_suffix( 10240 , SuffixType :: Iec , false ) ,
254
+ "10K"
255
+ ) ;
256
+ }
257
+
258
+ #[ test]
259
+ fn test_to_magnitude_and_suffix_powers_of_1024 ( ) {
260
+ assert_eq ! ( to_magnitude_and_suffix( 1024 , SuffixType :: Iec , false ) , "1K" ) ;
261
+ assert_eq ! (
262
+ to_magnitude_and_suffix( 10240 , SuffixType :: Iec , false ) ,
263
+ "10K"
264
+ ) ;
248
265
assert_eq ! ( to_magnitude_and_suffix( 2048 , SuffixType :: Iec , false ) , "2K" ) ;
249
266
assert_eq ! (
250
267
to_magnitude_and_suffix( 1024 * 40 , SuffixType :: Iec , false ) ,
251
268
"40K"
252
269
) ;
253
270
assert_eq ! (
254
- to_magnitude_and_suffix( 1024 * 1024 , SuffixType :: Iec , true ) ,
255
- "1.0M "
271
+ to_magnitude_and_suffix( 1024 * 1024 , SuffixType :: Iec , false ) ,
272
+ "1M "
256
273
) ;
257
274
assert_eq ! (
258
- to_magnitude_and_suffix( 2 * 1024 * 1024 , SuffixType :: Iec , true ) ,
259
- "2.0M "
275
+ to_magnitude_and_suffix( 2 * 1024 * 1024 , SuffixType :: Iec , false ) ,
276
+ "2M "
260
277
) ;
261
278
assert_eq ! (
262
- to_magnitude_and_suffix( 1024 * 1024 * 1024 , SuffixType :: Iec , true ) ,
263
- "1.0G "
279
+ to_magnitude_and_suffix( 1024 * 1024 * 1024 , SuffixType :: Iec , false ) ,
280
+ "1G "
264
281
) ;
265
282
assert_eq ! (
266
- to_magnitude_and_suffix( 34 * 1024 * 1024 * 1024 , SuffixType :: Iec , true ) ,
283
+ to_magnitude_and_suffix( 34 * 1024 * 1024 * 1024 , SuffixType :: Iec , false ) ,
267
284
"34G"
268
285
) ;
269
286
}
0 commit comments