From d74946934dd8f2076b8bf865ce7937463a9bc03b Mon Sep 17 00:00:00 2001 From: Avril Date: Fri, 10 Feb 2023 11:35:50 +0000 Subject: [PATCH] Added read+write test for `ManagedFD` & `MemoryFile`. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fortune for mapped-file's current commit: Curse − 凶 --- Cargo.toml | 2 +- src/file.rs | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 84b2673..c2f87f0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "mapped-file" description = "Construct a memory mapping over any file object" keywords = ["unix", "mmap", "generic", "file", "fd"] -version = "0.0.5" +version = "0.0.6" edition = "2021" repository="https://github.com/notflan/mapped-file" license="MIT" diff --git a/src/file.rs b/src/file.rs index 0ff5363..27aacb1 100644 --- a/src/file.rs +++ b/src/file.rs @@ -39,4 +39,13 @@ mod tests test_fileno::("STDOUT_FILENO", std::io::stdout().as_raw_fd()); test_fileno::("STDERR_FILENO", std::io::stderr().as_raw_fd()); } + + #[test] + fn test_readwrite() + { + let mut input = ManagedFD::from(memory::MemoryFile::new().unwrap()); + let mut output = memory::MemoryFile::new().unwrap(); + assert_eq!(std::io::copy(&mut input, &mut output).unwrap(), 0, "Bad read"); + + } }