aboutsummaryrefslogtreecommitdiff
path: root/crates/rsli/src/tests.rs
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/rsli/src/tests.rs
parentefab61a45c8837d3c2aaec464d8f6243fecb7a38 (diff)
downloadfparkan-bb827c3928ee6fc56c04e503be9f39ae70efee67.tar.xz
fparkan-bb827c3928ee6fc56c04e503be9f39ae70efee67.zip
feat: Refactor code structure and enhance functionality across multiple crates
Diffstat (limited to 'crates/rsli/src/tests.rs')
-rw-r--r--crates/rsli/src/tests.rs29
1 files changed, 15 insertions, 14 deletions
diff --git a/crates/rsli/src/tests.rs b/crates/rsli/src/tests.rs
index 07807d3..ffd611d 100644
--- a/crates/rsli/src/tests.rs
+++ b/crates/rsli/src/tests.rs
@@ -1,14 +1,17 @@
use super::*;
use crate::compress::lzh::{LZH_MAX_FREQ, LZH_N_CHAR, LZH_R, LZH_T};
use crate::compress::xor::xor_stream;
+use common::collect_files_recursive;
use flate2::write::DeflateEncoder;
use flate2::write::ZlibEncoder;
use flate2::Compression;
+use proptest::prelude::*;
use std::any::Any;
use std::fs;
use std::io::Write as _;
use std::panic::{catch_unwind, AssertUnwindSafe};
use std::path::PathBuf;
+use std::sync::Arc;
#[derive(Clone, Debug)]
struct SyntheticRsliEntry {
@@ -37,20 +40,6 @@ impl Default for RsliBuildOptions {
}
}
-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 rsli_test_files() -> Vec<PathBuf> {
let root = Path::new(env!("CARGO_MANIFEST_DIR"))
.join("..")
@@ -1335,3 +1324,15 @@ fn rsli_validation_error_cases() {
}
let _ = fs::remove_file(&path);
}
+
+proptest! {
+ #![proptest_config(ProptestConfig::with_cases(64))]
+
+ #[test]
+ fn parse_library_is_panic_free_on_random_bytes(data in proptest::collection::vec(any::<u8>(), 0..4096)) {
+ let _ = crate::parse::parse_library(
+ Arc::from(data.into_boxed_slice()),
+ OpenOptions::default(),
+ );
+ }
+}