From bb827c3928ee6fc56c04e503be9f39ae70efee67 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Thu, 19 Feb 2026 10:09:18 +0000 Subject: feat: Refactor code structure and enhance functionality across multiple crates --- crates/texm/src/tests.rs | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'crates/texm/src/tests.rs') diff --git a/crates/texm/src/tests.rs b/crates/texm/src/tests.rs index ba8aeeb..49a7100 100644 --- a/crates/texm/src/tests.rs +++ b/crates/texm/src/tests.rs @@ -1,22 +1,10 @@ use super::*; +use common::collect_files_recursive; use nres::Archive; +use proptest::prelude::*; use std::fs; use std::path::{Path, PathBuf}; -fn collect_files_recursive(root: &Path, out: &mut Vec) { - let Ok(entries) = fs::read_dir(root) else { - return; - }; - for entry in entries.flatten() { - let path = entry.path(); - if path.is_dir() { - collect_files_recursive(&path, out); - } else if path.is_file() { - out.push(path); - } - } -} - fn nres_test_files() -> Vec { let root = Path::new(env!("CARGO_MANIFEST_DIR")) .join("..") @@ -327,3 +315,16 @@ fn texm_errors_for_page_chunk_and_mip_bounds() { Err(Error::MipDataOutOfBounds { .. }) )); } + +proptest! { + #![proptest_config(ProptestConfig::with_cases(64))] + + #[test] + fn parse_texm_is_panic_free_on_random_bytes(payload in proptest::collection::vec(any::(), 0..4096)) { + if let Ok(texture) = parse_texm(&payload) { + for mip_index in 0..texture.mip_levels.len() { + let _ = decode_mip_rgba8(&texture, &payload, mip_index); + } + } + } +} -- cgit v1.2.3