From a8199f00d0c5714e48fa89d4deabb4568a667258 Mon Sep 17 00:00:00 2001 From: Szymon Walter Date: Mon, 19 Mar 2018 13:35:00 +0100 Subject: [PATCH] add `File` `Ext2` test --- ext2.bin | Bin 0 -> 4194304 bytes src/error.rs | 14 +++++++++++++- src/fs.rs | 15 +++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 ext2.bin diff --git a/ext2.bin b/ext2.bin new file mode 100644 index 0000000000000000000000000000000000000000..939c3d1ac2af5ae801089b8652cc72f648c875e8 GIT binary patch literal 4194304 zcmeIuF;2n&7zNdGnT)e*c&pf)t*CNV!MDbm$_EqG|Xn#byo78vhh^p%JFS4uAy8GNToou(g zc~8saGxFKf%P@I;NH^DY for Error { @@ -12,4 +17,11 @@ impl From for Error { } } +#[cfg(any(test, not(feature = "no_std")))] +impl From for Error { + fn from(err: io::Error) -> Error { + Error::Io(err) + } +} + pub enum Infallible {} diff --git a/src/fs.rs b/src/fs.rs index bad1c3f..f802ded 100644 --- a/src/fs.rs +++ b/src/fs.rs @@ -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()); + } +}