mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-26 00:57:26 +00:00
Consolidate related office tests
This commit is contained in:
@@ -1,19 +0,0 @@
|
||||
//! An app that embeds the writer names itself in `docProps/app.xml` (its own test binary: the
|
||||
//! name is set once per process).
|
||||
|
||||
use std::io::Read;
|
||||
|
||||
#[test]
|
||||
fn the_embedding_app_names_itself_in_app_xml() {
|
||||
assert_eq!(craft_docx::application_name(), "WordCraft", "the default");
|
||||
craft_docx::set_application_name("Example Writer");
|
||||
craft_docx::set_application_name("Other");
|
||||
assert_eq!(craft_docx::application_name(), "Example Writer", "only the first call counts");
|
||||
let mut d = craft_wordmodel::Document::new();
|
||||
d.body = vec![craft_wordmodel::para_block(craft_wordmodel::Paragraph::with_text("Text", Default::default()))];
|
||||
let bytes = craft_docx::write(&d).unwrap();
|
||||
let mut z = zip::ZipArchive::new(std::io::Cursor::new(&bytes)).unwrap();
|
||||
let mut app = String::new();
|
||||
z.by_name("docProps/app.xml").unwrap().read_to_string(&mut app).unwrap();
|
||||
assert!(app.contains("<Application>Example Writer</Application>"), "{app}");
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
//! The embedding app sets its name once per process. Exercise the setter in a fresh copy of the test binary.
|
||||
|
||||
use std::io::Read;
|
||||
|
||||
#[test]
|
||||
fn the_embedding_app_names_itself_in_app_xml() {
|
||||
const CHILD: &str = "CRAFT_DOCX_APP_NAME_CHILD";
|
||||
if std::env::var_os(CHILD).is_none() {
|
||||
let output = std::process::Command::new(std::env::current_exe().expect("DOCX test executable"))
|
||||
.args(["--exact", "application_name::the_embedding_app_names_itself_in_app_xml", "--nocapture"])
|
||||
.env(CHILD, "1")
|
||||
.output()
|
||||
.expect("run the application name test in a fresh process");
|
||||
let stdout = String::from_utf8_lossy(&output.stdout);
|
||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||
assert!(output.status.success() && stdout.contains("application name verified"), "{stdout}\n{stderr}");
|
||||
return;
|
||||
}
|
||||
assert_eq!(craft_docx::application_name(), "WordCraft", "the default");
|
||||
craft_docx::set_application_name("Example Writer");
|
||||
craft_docx::set_application_name("Other");
|
||||
assert_eq!(craft_docx::application_name(), "Example Writer", "only the first call counts");
|
||||
let mut d = craft_wordmodel::Document::new();
|
||||
d.body = vec![craft_wordmodel::para_block(craft_wordmodel::Paragraph::with_text("Text", Default::default()))];
|
||||
let bytes = craft_docx::write(&d).unwrap();
|
||||
let mut z = zip::ZipArchive::new(std::io::Cursor::new(&bytes)).unwrap();
|
||||
let mut app = String::new();
|
||||
z.by_name("docProps/app.xml").unwrap().read_to_string(&mut app).unwrap();
|
||||
assert!(app.contains("<Application>Example Writer</Application>"), "{app}");
|
||||
println!("application name verified");
|
||||
}
|
||||
@@ -58,3 +58,7 @@ mod vml_shapes;
|
||||
mod word_xml;
|
||||
mod wordml2003_write;
|
||||
mod wps_fallback;
|
||||
|
||||
mod application_name;
|
||||
mod matrix_save_size;
|
||||
mod protection;
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
//! The crate's integration tests, linked into one test binary.
|
||||
|
||||
#[path = "../common/mod.rs"]
|
||||
mod common;
|
||||
|
||||
mod objects;
|
||||
mod read;
|
||||
mod styles;
|
||||
mod validation;
|
||||
@@ -2,7 +2,7 @@
|
||||
//! from [MS-XLS] and [MS-ODRAW]; no Excel-produced file is used. Ported from
|
||||
//! storytold/gridcraft#3457, with tests for the fixes its review asked for.
|
||||
|
||||
mod common;
|
||||
use super::common;
|
||||
|
||||
use common::*;
|
||||
use craft_xls::{ClientAnchor, Color, ConditionRule, DxfFill, Operator, Pattern, Range, Workbook};
|
||||
@@ -1,6 +1,6 @@
|
||||
//! Reading BIFF8 workbooks: values, formulas, layout, names, limits and hostile input.
|
||||
|
||||
mod common;
|
||||
use super::common;
|
||||
|
||||
use common::{
|
||||
at, bof, cat, cell, compound, eof, exp, fmt, formula, ftext, num, ptg_int, ptg_ref, put32, read_limited, read_xls, rec, special, text, u16s, v,
|
||||
@@ -1,7 +1,7 @@
|
||||
//! Cell formatting: Font, XF, Palette and Style records. Every workbook is assembled here from
|
||||
//! the [MS-XLS] structures; no Excel-produced file is used.
|
||||
|
||||
mod common;
|
||||
use super::common;
|
||||
|
||||
use common::{at, bof, compound, eof, read_xls, rec, u16s, v};
|
||||
use craft_xls::{BorderLine, BorderStyle, CellFormat, Color, DEFAULT_PALETTE, Fill, HAlign, Pattern, Script, Underline, VAlign, Value, Workbook};
|
||||
@@ -2,7 +2,7 @@
|
||||
//! spec's structures; no Excel-produced file is used. The expected rules are what a
|
||||
//! SpreadsheetML reader gives for the same rule. Ported from storytold/gridcraft#3636.
|
||||
|
||||
mod common;
|
||||
use super::common;
|
||||
|
||||
use common::*;
|
||||
use craft_xls::{CellRef, DataValidation, ErrorStyle, Operator, Range, ValidationType, Workbook};
|
||||
@@ -0,0 +1,10 @@
|
||||
//! The crate's integration tests, linked into one test binary.
|
||||
|
||||
#[path = "../common/mod.rs"]
|
||||
mod common;
|
||||
|
||||
mod pivot;
|
||||
mod richdata;
|
||||
mod write;
|
||||
mod xlsb;
|
||||
mod xlsx;
|
||||
@@ -1,7 +1,7 @@
|
||||
//! Binary workbooks: BIFF12 records and packages assembled here from [MS-XLSB].
|
||||
//! Adapted from GridCraft's `crates/xlsx/src/tests/xlsb_tests.rs`.
|
||||
|
||||
mod common;
|
||||
use super::common;
|
||||
|
||||
use common::{read, read_with};
|
||||
use craft_xlsx::testing::zip;
|
||||
@@ -1,6 +1,6 @@
|
||||
//! SpreadsheetML workbooks through the part layer.
|
||||
|
||||
mod common;
|
||||
use super::common;
|
||||
|
||||
use common::{read, read_with};
|
||||
use craft_xlsx::testing::{workbook, zip};
|
||||
Reference in New Issue
Block a user