aboutsummaryrefslogtreecommitdiff
path: root/crates/texm/src
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-02-19 13:09:18 +0300
committerValentin Popov <valentin@popov.link>2026-02-19 13:09:18 +0300
commitbb827c3928ee6fc56c04e503be9f39ae70efee67 (patch)
tree9d1af6595567517bcee3bddbcf7fefedce5dc5fe /crates/texm/src
parentefab61a45c8837d3c2aaec464d8f6243fecb7a38 (diff)
downloadfparkan-bb827c3928ee6fc56c04e503be9f39ae70efee67.tar.xz
fparkan-bb827c3928ee6fc56c04e503be9f39ae70efee67.zip
feat: Refactor code structure and enhance functionality across multiple crates
Diffstat (limited to 'crates/texm/src')
-rw-r--r--crates/texm/src/tests.rs29
1 files changed, 15 insertions, 14 deletions
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);
+ }
+ }
+ }
+}