add File Ext2 test

This commit is contained in:
Szymon Walter 2018-03-19 13:35:00 +01:00
parent 55b23f4974
commit a8199f00d0
3 changed files with 28 additions and 1 deletions

BIN
ext2.bin Normal file

Binary file not shown.

View file

@ -1,9 +1,14 @@
#[cfg(any(test, not(feature = "no_std")))]
use std::io;
/// The set of all possible errors
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[derive(Debug)]
pub enum Error {
BadMagic(u16),
OutOfBounds(usize),
BadBlockGroupCount(u32, u32),
#[cfg(any(test, not(feature = "no_std")))]
Io(io::Error),
}
impl From<Infallible> for Error {
@ -12,4 +17,11 @@ impl From<Infallible> for Error {
}
}
#[cfg(any(test, not(feature = "no_std")))]
impl From<io::Error> for Error {
fn from(err: io::Error) -> Error {
Error::Io(err)
}
}
pub enum Infallible {}

View file

@ -27,3 +27,18 @@ where
}
}
}
#[cfg(test)]
mod tests {
use std::fs::File;
use std::cell::RefCell;
use super::Ext2;
#[test]
fn file() {
let file = RefCell::new(File::open("ext2.bin").unwrap());
let mut fs = Ext2::new(file);
assert!(fs.init().is_ok());
}
}