Skip to content

Commit

Permalink
Add some tests around max sector size
Browse files Browse the repository at this point in the history
Signed-off-by: mulhern <amulhern@redhat.com>
  • Loading branch information
mulkieran committed Mar 21, 2024
1 parent 8b92c74 commit c45d3b3
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/units.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,22 @@ impl Sectors {
MetaBlocks(self / META_BLOCK_SIZE)
}
}

#[cfg(test)]
mod test {
use super::*;

#[test]
fn test_large() {
let max_sectors = Sectors(u64::MAX).bytes();
let size_sectors = max_sectors.sectors();
assert_eq!(size_sectors.bytes(), max_sectors);
}

#[test]
fn test_too_large() {
let max_bytes = Sectors(u64::MAX).bytes() + Sectors(1).bytes();
let sectors = max_bytes.sectors();
assert_eq!(sectors, Sectors(0));
}
}

0 comments on commit c45d3b3

Please sign in to comment.