mirror of
https://github.com/storytold/wordcraft.git
synced 2026-11-18 00:15:44 +00:00
* chore: cut over image codecs and zip to craft-libs, fix main test regressions * tests: store ODS mimetype and use standard ODF namespaces in mailings test * Remove unused quick-xml workspace dependency * fix: use standard ODF namespaces in file_dialogs test and preserve trailing line in markdown import_on_with_lines * fix(geom): use png_chunks for PNG dimensions and p.fits(budget) in decode_for_drawing
24 lines
1.2 KiB
Rust
24 lines
1.2 KiB
Rust
//! A ragged equation matrix doesn't make the saved `document.xml` grow with rows × widest row
|
||
//! (#3643): one wide row plus many empty rows used to be padded out to a full grid.
|
||
|
||
use wordcraft_doc::math::{MNode, MRun, Math};
|
||
use wordcraft_doc::para::InlineObject;
|
||
use wordcraft_doc::props::CharProps;
|
||
use wordcraft_doc::{Document, Paragraph, para_block};
|
||
|
||
#[test]
|
||
fn ragged_matrix_save_stays_small() {
|
||
let n = 5000;
|
||
let mut rows = vec![vec![vec![MNode::Run(MRun::new("a"))]; n]];
|
||
rows.extend(std::iter::repeat_with(Vec::new).take(n));
|
||
let math = Math { nodes: vec![MNode::Matrix { rows, col_jc: Vec::new() }], ..Default::default() };
|
||
let mut p = Paragraph::new();
|
||
p.insert_object(0, InlineObject::Equation { linear: String::new(), display: true, math }, &CharProps::default()).unwrap();
|
||
let mut doc = Document::new();
|
||
doc.body = vec![para_block(p)];
|
||
let bytes = wordcraft_docx::write(&doc).unwrap();
|
||
let mut zip = craft_zip::Archive::open(&bytes, craft_zip::Limits { max_entries: 10_000, max_total_bytes: 64 << 20 }).unwrap();
|
||
let size = zip.declared_size("word/document.xml").unwrap();
|
||
assert!(size < 1_000_000, "document.xml is {size} bytes");
|
||
}
|