From 64dd381bc4abcb24917d6b8d30f3c9d95d327ebb Mon Sep 17 00:00:00 2001 From: mtlcl410 Date: Mon, 9 Nov 2026 00:04:59 +0800 Subject: [PATCH] M1: the unlinked-update tests check the objects the update wins with (core.malformed-input-safety) The hybrid update test now checks that the update's page and catalog win and that the repair log says why, and that the linked file keeps both revisions; the save test checks that the reopened file keeps the update's page and catalog. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Pq7HyCHD1R3rywQBPCHXZA --- crates/cos/src/document/tests.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/crates/cos/src/document/tests.rs b/crates/cos/src/document/tests.rs index 6b67935e9c..1ddb0de15f 100644 --- a/crates/cos/src/document/tests.rs +++ b/crates/cos/src/document/tests.rs @@ -2215,7 +2215,11 @@ fn an_update_without_prev_is_rebuilt_with_its_page_tree_and_a_repair_note() { let saved = crate::write_incremental(&doc, &crate::SaveOptions::default()).expect("saves"); let reopened = Document::open(Arc::new(saved)).expect("the saved file opens"); - assert_eq!(page_tree_pages(&reopened).len(), 3); + let pages = page_tree_pages(&reopened); + assert_eq!(pages.len(), 3); + assert!(pages.first().is_some_and(|p| p.contains(b"Annots")), "the update's page is saved: {pages:?}"); + let catalog = reopened.get(reopened.root().expect("root")); + assert!(catalog.as_dict().is_some_and(|c| c.contains(b"Lang")), "the update's catalog is saved"); assert!(reopened.repair_log().is_empty(), "{:?}", reopened.repair_log()); // The same file with `/Prev` reads through its chain, as before. @@ -2231,11 +2235,17 @@ fn an_update_without_prev_is_rebuilt_with_its_page_tree_and_a_repair_note() { #[test] fn a_hybrid_update_without_prev_is_rebuilt_too() { let doc = Document::open(Arc::new(pdfcraft_testkit::hybrid_update_without_prev(false))).expect("the unlinked file opens"); - assert_eq!(page_tree_pages(&doc).len(), 3); + let pages = page_tree_pages(&doc); + assert_eq!(pages.len(), 3); + assert!(pages.first().is_some_and(|p| p.contains(b"Annots")), "the update's page wins: {pages:?}"); assert!(doc.rebuilt_unlinked_update(), "{:?}", doc.repair_log()); + assert!(doc.repair_log().iter().any(|l| l.contains("no /Prev")), "{:?}", doc.repair_log()); + let catalog = doc.get(doc.root().expect("root")); + assert!(catalog.as_dict().is_some_and(|c| c.contains(b"Lang")), "the update's catalog wins"); let linked = Document::open(Arc::new(pdfcraft_testkit::hybrid_update_without_prev(true))).expect("the linked file opens"); assert_eq!(page_tree_pages(&linked).len(), 3); assert!(!linked.rebuilt_unlinked_update() && linked.repair_log().is_empty(), "{:?}", linked.repair_log()); + assert_eq!(linked.revisions().len(), 2); } #[test]