test(property): add path validator invariants (#3541)

test(property): add path validator invariants for #3525
This commit is contained in:
houseme
2026-06-18 02:14:24 +08:00
committed by GitHub
parent bc769948ab
commit 87a3d107d6
4 changed files with 53 additions and 0 deletions
+26
View File
@@ -553,6 +553,7 @@ pub fn trim_etag(etag: &str) -> String {
#[cfg(test)]
mod tests {
use super::*;
use proptest::prelude::*;
#[test]
fn test_trim_etag() {
@@ -892,4 +893,29 @@ mod tests {
assert_eq!(bucket, "s3-test-bucket");
assert_eq!(object, "中文/日本語/한글-9cd5599a-f8eb-4e24-9df7-32ecd8d8ad1f");
}
proptest! {
#[test]
fn clean_is_idempotent(input in any::<String>()) {
let once = clean(&input);
let twice = clean(&once);
prop_assert_eq!(twice, once);
}
#[test]
fn clean_output_has_no_redundant_current_dir_or_empty_segments(input in any::<String>()) {
let cleaned = clean(&input);
prop_assert!(!cleaned.contains("//"), "clean output should not contain doubled separators");
prop_assert!(!cleaned.contains("/./"), "clean output should not contain embedded current-dir segments");
prop_assert!(!cleaned.ends_with("/."), "clean output should not end with a current-dir segment");
if cleaned != "/" {
prop_assert!(
!cleaned.ends_with('/') || cleaned.is_empty(),
"clean output should not preserve a trailing slash"
);
}
}
}
}