From d382f04e5a2005971fda802e9920ea72d932a6be Mon Sep 17 00:00:00 2001 From: Jeremy Aube Date: Sun, 21 Jun 2020 12:38:36 -0400 Subject: [PATCH] Change default comment to String::new() and fixed tests --- src/read.rs | 2 +- src/write.rs | 9 +++++---- tests/data/mimetype.zip | Bin 159 -> 153 bytes 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/read.rs b/src/read.rs index ac721533..06d2540d 100644 --- a/src/read.rs +++ b/src/read.rs @@ -714,7 +714,7 @@ mod test { let mut v = Vec::new(); v.extend_from_slice(include_bytes!("../tests/data/mimetype.zip")); let reader = ZipArchive::new(io::Cursor::new(v)).unwrap(); - assert!(reader.comment() == b"zip-rs"); + assert!(reader.comment() == b""); } #[test] diff --git a/src/write.rs b/src/write.rs index 2598f196..f1d762dd 100644 --- a/src/write.rs +++ b/src/write.rs @@ -176,7 +176,7 @@ impl ZipWriter { files: Vec::new(), stats: Default::default(), writing_to_file: false, - comment: "".into(), + comment: String::new(), } } @@ -616,7 +616,7 @@ mod test { .write(b"writing to a directory is not allowed, and will not write any data") .is_err()); let result = writer.finish().unwrap(); - assert_eq!(result.get_ref().len(), 114); + assert_eq!(result.get_ref().len(), 108); assert_eq!( *result.get_ref(), &[ @@ -624,7 +624,7 @@ mod test { 0, 0, 5, 0, 0, 0, 116, 101, 115, 116, 47, 80, 75, 1, 2, 46, 3, 20, 0, 0, 0, 0, 0, 163, 165, 15, 77, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 237, 65, 0, 0, 0, 0, 116, 101, 115, 116, 47, 80, 75, 5, 6, 0, 0, 0, 0, 1, 0, - 1, 0, 51, 0, 0, 0, 35, 0, 0, 0, 6, 0, 122, 105, 112, 45, 114, 115 + 1, 0, 51, 0, 0, 0, 35, 0, 0, 0, 0, 0, ] as &[u8] ); } @@ -642,7 +642,8 @@ mod test { .write(b"application/vnd.oasis.opendocument.text") .unwrap(); let result = writer.finish().unwrap(); - assert_eq!(result.get_ref().len(), 159); + + assert_eq!(result.get_ref().len(), 153); let mut v = Vec::new(); v.extend_from_slice(include_bytes!("../tests/data/mimetype.zip")); assert_eq!(result.get_ref(), &v); diff --git a/tests/data/mimetype.zip b/tests/data/mimetype.zip index 78f98224e8a226a235a08304f717015dfa97aef5..2d651cbeb35f66322568234766b6b933f651dadc 100644 GIT binary patch delta 9 QcmbQwIFoV0bS4G{01poWWB>pF delta 15 WcmbQqIG=ICbPhI#s>}l2qGA9hNCedY