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

Function test_arithmetic_op

src/lib.rs:535–551  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

533
534 #[test]
535 fn test_arithmetic_op() {
536 let mut x = ByteSize::mb(1);
537 let y = ByteSize::kb(100);
538
539 assert_eq!((x + y).as_u64(), 1_100_000u64);
540
541 assert_eq!((x - y).as_u64(), 900_000u64);
542
543 assert_eq!((x + (100 * 1000) as u64).as_u64(), 1_100_000);
544
545 assert_eq!((x * 2u64).as_u64(), 2_000_000);
546
547 x += y;
548 assert_eq!(x.as_u64(), 1_100_000);
549 x *= 2u64;
550 assert_eq!(x.as_u64(), 2_200_000);
551 }
552
553 #[allow(clippy::unnecessary_cast)]
554 #[test]

Callers

nothing calls this directly

Calls 2

mbFunction · 0.85
kbFunction · 0.85

Tested by

no test coverage detected