Skip to content

Commit b07907a

Browse files
committed
Reduce duplication
1 parent fc3a553 commit b07907a

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

src/zip_util.rs

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -151,20 +151,10 @@ impl ZipUtil {
151151
mod tests {
152152
use crate::file_util::FileUtil;
153153
use super::ZipUtil;
154-
use std::{path::MAIN_SEPARATOR, path::MAIN_SEPARATOR_STR, path::Path, fs, io};
154+
use std::{path::MAIN_SEPARATOR_STR, path::Path, fs, io};
155155
use walkdir::WalkDir;
156156
use testdir::testdir;
157157

158-
fn normalize_path(s: &str) -> String {
159-
let src_char = if MAIN_SEPARATOR == '/' {
160-
"\\"
161-
} else {
162-
"/"
163-
};
164-
165-
s.replace(src_char, MAIN_SEPARATOR_STR)
166-
}
167-
168158
#[test]
169159
fn test_unzip() -> io::Result<()> {
170160
let zipfile = "./src/test/test_zip.zip";
@@ -181,7 +171,7 @@ mod tests {
181171

182172
assert!(extracts.contains(&"foo.test.txt".into()));
183173
assert!(extracts.contains(&"empty.file".into()));
184-
assert!(extracts.contains(&normalize_path("sub/sub/[Content_Types].xml")));
174+
assert!(extracts.contains(&FileUtil::normalize_path("sub/sub/[Content_Types].xml")));
185175
assert_eq!(3, extracts.len(), "Should be only 3 files");
186176

187177
let empty_file = Path::new(&outdir).join("empty.file");
@@ -226,7 +216,7 @@ mod tests {
226216
assert_eq!(3, extracts.len());
227217
assert!(extracts.contains(&"foo.test.txt".into()));
228218
assert!(extracts.contains(&"empty.file".into()));
229-
assert!(extracts.contains(&normalize_path("sub/sub/[Content_Types].xml")));
219+
assert!(extracts.contains(&FileUtil::normalize_path("sub/sub/[Content_Types].xml")));
230220

231221
let empty_file = Path::new(&expldir).join("empty.file");
232222
assert!(empty_file.is_file());

0 commit comments

Comments
 (0)