#[test]
fn facade_cache_module_is_deleted_and_canonical_cache_is_private() {
let root = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("src");
assert!(!root.join("cache.rs").exists());
let lib = std::fs::read_to_string(root.join("lib.rs")).expect("read lib.rs");
assert!(!lib.contains("pub mod cache"));
assert!(!lib.contains("pub use cache::"));
}
#[test]
fn canonical_replacement_does_not_round_trip_through_raw_materialization() {
let source = include_str!("../src/reader.rs").replace("\r\n", "\n");
let replace_object = source
.split("pub fn replace_object(")
.nth(1)
.and_then(|tail| tail.split("pub(crate) fn remove_object_handle").next())
.expect("canonical replace_object exists");
assert!(!replace_object.contains("promote_resolved_object_stream_members"));
assert!(!replace_object.contains("materialize"));
assert!(!replace_object.contains("lift_for_set_object"));
}
#[test]
fn encryption_dictionary_reader_route_uses_handle_accessors() {
let source = include_str!("../src/reader.rs").replace("\r\n", "\n");
let route = source
.split("fn encrypt_dictionary_handle")
.nth(1)
.and_then(|tail| tail.split("pub(crate) fn first_xref_item_offset").next())
.expect("encryption dictionary route exists");
assert!(route.contains("try_is_dictionary"));
assert!(!route.contains("materialize"));
}
#[test]
fn encryption_state_production_route_uses_handle_values() {
let source = include_str!("../src/encryption/state.rs").replace("\r\n", "\n");
let route = source
.split("pub(crate) fn parse_inspection_state")
.nth(1)
.and_then(|tail| {
tail.split("#[cfg(test)]\npub(crate) fn first_file_id")
.next()
})
.expect("encryption state production route exists");
assert!(route.contains("&ObjectHandle"));
assert!(!route.contains("&Dictionary"));
assert!(!route.contains("Object::"));
assert!(!route.contains("materialize"));
for (start, end) in [
(
"fn standard_handler_inputs_from_handle",
"fn standard_handler_r5_inputs_from_handle",
),
(
"fn standard_handler_r5_inputs_from_handle",
"fn map_uo_length_to_bad_password",
),
(
"fn required_integer_from_handle",
"/// qpdf's `/ID[0]` value",
),
(
"fn r6_perms_warning_from_handle",
"/// qpdf's `/ID[0]` value",
),
] {
let function = source
.split(start)
.nth(1)
.and_then(|tail| tail.split(end).next())
.expect("handle-native encryption helper exists");
assert!(!function.contains("Object::"));
assert!(!function.contains("materialize"));
}
}