Files
craft-anything/crates/formats/tests/iostore_complete_header.rs
60409b684c More format parsers keep to their declared lengths and refuse impossible values (#986)
Network captures, ZIP, Unity, Unreal, Python, pixel, tensor, Mach-O, code signature, PE, Go, .NET, ELF and DOS readers keep to their declared lengths and refuse impossible values. Trailing padding in a ZIP entry's extra field is no longer an error. Closes #974.

Co-authored-by: Afloat <ShuffleMonkey@163.com>
Co-authored-by: NetterSilver <133535268+Silvertree2010@users.noreply.github.com>
2026-11-07 00:10:42 +08:00

20 lines
812 B
Rust

use craft_anything_formats::{FormatError, unreal_iostore};
#[test]
fn all_reserved_header_bytes_must_be_present() {
let fixture = craft_anything_testkit::games::unreal_utoc(9, u32::MAX);
for len in 0..unreal_iostore::HEADER_SIZE {
assert!(matches!(unreal_iostore::header(&fixture[..len]), Err(FormatError::Truncated(_))), "a {len}-byte header is incomplete");
}
}
#[test]
fn complete_headers_read_for_each_supported_version() {
let mut fixture = craft_anything_testkit::games::unreal_utoc(9, u32::MAX);
for version in 1..=unreal_iostore::MAX_VERSION {
fixture[16] = version;
let h = unreal_iostore::header(&fixture[..unreal_iostore::HEADER_SIZE]).unwrap();
assert_eq!((h.version, h.chunk_count, h.block_count, h.block_size), (version, 3, 4, 65536));
}
}