//! Integration-style tests: round trips, hand-written fixtures, hostile input and CSV. mod array_export; mod cellmetadata; mod chart_book_names; mod chart_bool_default; mod chart_combo_kinds; mod chart_ref_offsets; mod csv_tests; mod encrypted_tests; mod fixtures; mod ink_roundtrip; mod literal_category_roundtrip; mod malformed; mod multilevel_category_roundtrip; mod note_box; mod ods_tests; mod passthrough_tests; mod phonetic_tests; mod pivot_tests; mod richdata_tests; mod roundtrip; mod shape_text_rtl; mod shared_media; mod sheet_names; mod smooth_roundtrip; mod trendline_roundtrip; mod xls_style_tests; mod xls_tests; mod xlsb_tests; mod zip_order; use std::io::Write; /// Builds a zip package from (name, content) pairs. pub fn make_zip(parts: &[(&str, &[u8])]) -> Vec { let mut z = zip::ZipWriter::new(std::io::Cursor::new(Vec::new())); for (name, data) in parts { z.start_file(*name, zip::write::SimpleFileOptions::default()).unwrap(); z.write_all(data).unwrap(); } z.finish().unwrap().into_inner() } pub const CT: &str = r#""#; pub const ROOT_RELS: &str = r#""#; /// A minimal one-sheet package with the given sheet XML body (inside ``), plus /// optional extra parts and workbook relationships. pub fn minimal(sheet_body: &str, extra_parts: &[(&str, &str)], wb_extra_rels: &str, wb_extra: &str) -> Vec { let wb = format!( r#"{wb_extra}"# ); let rels = format!( r#"{wb_extra_rels}"# ); let sheet = format!( r#"{sheet_body}"# ); let mut parts: Vec<(&str, &[u8])> = vec![ ("[Content_Types].xml", CT.as_bytes()), ("_rels/.rels", ROOT_RELS.as_bytes()), ("xl/workbook.xml", wb.as_bytes()), ("xl/_rels/workbook.xml.rels", rels.as_bytes()), ("xl/worksheets/sheet1.xml", sheet.as_bytes()), ]; for (n, c) in extra_parts { parts.push((n, c.as_bytes())); } make_zip(&parts) }