From fbdbeb284237f6df4b3251401787c13aa000822b Mon Sep 17 00:00:00 2001 From: Szymon Walter Date: Tue, 20 Mar 2018 12:38:22 +0100 Subject: [PATCH] fix `Address::sub` --- src/block.rs | 2 +- src/fs.rs | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/block.rs b/src/block.rs index 83af087..ad60f7a 100644 --- a/src/block.rs +++ b/src/block.rs @@ -177,7 +177,7 @@ impl Sub for Address { type Output = Address; fn sub(self, rhs: Address) -> Address { Address::new( - self.block + rhs.block, + self.block - rhs.block, self.offset as isize - rhs.offset as isize, ) } diff --git a/src/fs.rs b/src/fs.rs index 1c90de1..e100351 100644 --- a/src/fs.rs +++ b/src/fs.rs @@ -229,6 +229,11 @@ mod tests { #[test] fn file_len() { let file = RefCell::new(File::open("ext2.img").unwrap()); + assert_eq!( + Address::::from(2048_usize) + - Address::::from(1024_usize), + Address::::new(2, 0) + ); assert_eq!( unsafe { file.slice_unchecked(