diff options
| author | Valentin Popov <valentin@popov.link> | 2026-02-19 13:09:18 +0300 |
|---|---|---|
| committer | Valentin Popov <valentin@popov.link> | 2026-02-19 13:09:18 +0300 |
| commit | bb827c3928ee6fc56c04e503be9f39ae70efee67 (patch) | |
| tree | 9d1af6595567517bcee3bddbcf7fefedce5dc5fe /crates/texm | |
| parent | efab61a45c8837d3c2aaec464d8f6243fecb7a38 (diff) | |
| download | fparkan-bb827c3928ee6fc56c04e503be9f39ae70efee67.tar.xz fparkan-bb827c3928ee6fc56c04e503be9f39ae70efee67.zip | |
feat: Refactor code structure and enhance functionality across multiple crates
Diffstat (limited to 'crates/texm')
| -rw-r--r-- | crates/texm/Cargo.toml | 2 | ||||
| -rw-r--r-- | crates/texm/src/tests.rs | 29 |
2 files changed, 17 insertions, 14 deletions
diff --git a/crates/texm/Cargo.toml b/crates/texm/Cargo.toml index 216bb44..f9c49b6 100644 --- a/crates/texm/Cargo.toml +++ b/crates/texm/Cargo.toml @@ -4,4 +4,6 @@ version = "0.1.0" edition = "2021" [dev-dependencies] +common = { path = "../common" } nres = { path = "../nres" } +proptest = "1" 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<PathBuf>) { - 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<PathBuf> { 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::<u8>(), 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); + } + } + } +} |
