Add unit test for duplicate file names

This commit is contained in:
Chris Hennick 2023-04-29 15:05:53 -07:00
parent eaa2d26ca9
commit db9866719b
No known key found for this signature in database
GPG key ID: 25653935CC8B6C74

View file

@ -1636,6 +1636,20 @@ mod test {
assert_eq!(second_file_content, RT_TEST_TEXT);
}
#[test]
fn duplicate_filenames() {
let mut writer = ZipWriter::new(io::Cursor::new(Vec::new()));
writer
.start_file("foo/bar/test", FileOptions::default())
.unwrap();
writer
.write("The quick brown 🦊 jumps over the lazy 🐕".as_bytes())
.unwrap();
writer
.start_file("foo/bar/test", FileOptions::default())
.expect_err("Expected duplicate filename not to be allowed");
}
#[test]
fn path_to_string() {
let mut path = std::path::PathBuf::new();