()
| 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] |