Skip to content

VectorCraft: An open-source, vector art tool written by scratch in pure Rust

PDF tests: exports compared byte for byte are dated alike

Louise Fox14663173016e
diff --git a/crates/pdf/src/tests.rs b/crates/pdf/src/tests.rs
index 6fa4da12a..6ebc0ceac 100644
--- a/crates/pdf/src/tests.rs
+++ b/crates/pdf/src/tests.rs
@@ -37,13 +37,18 @@ fn close(a: Rect, b: Rect, tol: f64) -> bool {
(a.x0 - b.x0).abs() < tol && (a.y0 - b.y0).abs() < tol && (a.x1 - b.x1).abs() < tol && (a.y1 - b.y1).abs() < tol
}
+/// `d` exported with the default options and imported back: the document a round trip through a PDF
+/// gives.
fn roundtrip(d: &Document) -> Document {
let bytes = export(d, &PdfOptions::default()).expect("export");
import(&bytes).expect("import")
}
+/// `d` exported uncompressed, dated `created: Some(0)` rather than by the clock: two exports of one
+/// document are then the same bytes, where the clock's dates, in whole seconds, differ whenever a
+/// second ticks between them.
fn uncompressed(d: &Document) -> String {
- let bytes = export(d, &PdfOptions::uncompressed()).expect("export");
+ let bytes = export(d, &PdfOptions { created: Some(0), ..PdfOptions::uncompressed() }).expect("export");
String::from_utf8_lossy(&bytes).into_owned()
}