mark Superblock::find unsafe; add test
This commit is contained in:
parent
0fc2c934d9
commit
959572eca1
|
@ -145,7 +145,7 @@ pub struct Superblock {
|
|||
}
|
||||
|
||||
impl Superblock {
|
||||
pub fn find<'a, E>(
|
||||
pub unsafe fn find<'a, E>(
|
||||
haystack: &'a Buffer<u8, Error = E>,
|
||||
) -> Result<(Superblock, usize), Error>
|
||||
where
|
||||
|
@ -257,4 +257,19 @@ mod tests {
|
|||
superblock.err().unwrap_or_else(|| unreachable!()),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[allow(unused_unsafe)]
|
||||
fn superblock() {
|
||||
use std::cell::RefCell;
|
||||
use std::fs::File;
|
||||
|
||||
let file = RefCell::new(File::open("ext2.bin").unwrap());
|
||||
let superblock = Superblock::find(&file);
|
||||
assert!(
|
||||
superblock.is_ok(),
|
||||
"Err({:?})",
|
||||
superblock.err().unwrap_or_else(|| unreachable!()),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue