MCPcopy Create free account
hub / github.com/bytesize-rs/bytesize / test_to_string_as

Function test_to_string_as

src/display.rs:339–366  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

337
338 #[test]
339 fn test_to_string_as() {
340 assert_to_string("215 B", ByteSize::b(215), Format::Iec);
341 assert_to_string("215 B", ByteSize::b(215), Format::Si);
342
343 assert_to_string("1.0 KiB", ByteSize::kib(1), Format::Iec);
344 assert_to_string("1.0 kB", ByteSize::kib(1), Format::Si);
345
346 assert_to_string("293.9 KiB", ByteSize::kb(301), Format::Iec);
347 assert_to_string("301.0 kB", ByteSize::kb(301), Format::Si);
348
349 assert_to_string("1.0 MiB", ByteSize::mib(1), Format::Iec);
350 assert_to_string("1.0 MB", ByteSize::mib(1), Format::Si);
351
352 assert_to_string("1.9 GiB", ByteSize::mib(1907), Format::Iec);
353 assert_to_string("2.0 GB", ByteSize::mib(1908), Format::Si);
354
355 assert_to_string("399.6 MiB", ByteSize::mb(419), Format::Iec);
356 assert_to_string("419.0 MB", ByteSize::mb(419), Format::Si);
357
358 assert_to_string("482.4 GiB", ByteSize::gb(518), Format::Iec);
359 assert_to_string("518.0 GB", ByteSize::gb(518), Format::Si);
360
361 assert_to_string("741.2 TiB", ByteSize::tb(815), Format::Iec);
362 assert_to_string("815.0 TB", ByteSize::tb(815), Format::Si);
363
364 assert_to_string("540.9 PiB", ByteSize::pb(609), Format::Iec);
365 assert_to_string("609.0 PB", ByteSize::pb(609), Format::Si);
366 }
367
368 #[test]
369 fn precision() {

Callers

nothing calls this directly

Calls 8

assert_to_stringFunction · 0.85
kibFunction · 0.85
kbFunction · 0.85
mibFunction · 0.85
mbFunction · 0.85
gbFunction · 0.85
tbFunction · 0.85
pbFunction · 0.85

Tested by

no test coverage detected