From e962cf7b0ace704b9e47666d040e1e7c30509e41 Mon Sep 17 00:00:00 2001 From: ChanTsune <41658782+ChanTsune@users.noreply.github.com> Date: Sat, 10 Aug 2024 23:49:25 +0900 Subject: [PATCH] :white_check_mark: Example code copy_entries make testable --- lib/Cargo.toml | 3 --- lib/{examples => tests}/copy_entries.rs | 12 ++++++------ 2 files changed, 6 insertions(+), 9 deletions(-) rename lib/{examples => tests}/copy_entries.rs (63%) diff --git a/lib/Cargo.toml b/lib/Cargo.toml index 3a897cdf..d9ee02c6 100644 --- a/lib/Cargo.toml +++ b/lib/Cargo.toml @@ -49,6 +49,3 @@ required-features = ["unstable-async"] [[example]] name = "change_compression_method" - -[[example]] -name = "copy_entries" diff --git a/lib/examples/copy_entries.rs b/lib/tests/copy_entries.rs similarity index 63% rename from lib/examples/copy_entries.rs rename to lib/tests/copy_entries.rs index e4c14a00..9949c48e 100644 --- a/lib/examples/copy_entries.rs +++ b/lib/tests/copy_entries.rs @@ -12,10 +12,10 @@ fn copy_entries(r: R, w: W) -> io::Result<()> { Ok(()) } -fn main() -> io::Result<()> { - let mut dist = vec![]; - copy_entries( - include_bytes!("../../resources/test/deflate.pna").as_slice(), - &mut dist, - ) +#[test] +fn copy() { + let src = include_bytes!("../../resources/test/deflate.pna"); + let mut dist = Vec::new(); + copy_entries(src.as_slice(), &mut dist).unwrap(); + assert_eq!(src.as_slice(), dist.as_slice()); }