Skip to content

Commit 717aedf

Browse files
Merge pull request #24 from developer0hye/feat/diverse-test-fixtures
test: add 121 diverse real-world Office fixture files
2 parents d507d6e + 084aa1a commit 717aedf

File tree

125 files changed

+494
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+494
-0
lines changed

crates/office2pdf/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ umya-spreadsheet = "2"
2525

2626
[dev-dependencies]
2727
criterion = { version = "0.5", features = ["html_reports"] }
28+
paste = "1"
2829

2930
[[bench]]
3031
name = "conversion"

crates/office2pdf/tests/docx_fixtures.rs

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,3 +398,74 @@ fn structure_word_tables() {
398398
let blocks = all_blocks(&pages);
399399
assert!(has_table_block(&blocks), "should have Block::Table");
400400
}
401+
402+
// ===========================================================================
403+
// Third-party fixtures — smoke tests (must not panic)
404+
// ===========================================================================
405+
406+
/// Generate a pair of smoke + basic-structure tests for a DOCX fixture.
407+
macro_rules! docx_fixture_tests {
408+
($test_name:ident, $file:expr) => {
409+
paste::paste! {
410+
#[test]
411+
fn [<smoke_ $test_name>]() {
412+
assert_produces_valid_pdf($file);
413+
}
414+
415+
#[test]
416+
fn [<structure_ $test_name>]() {
417+
let data = load_fixture($file);
418+
match DocxParser.parse(&data, &ConvertOptions::default()) {
419+
Ok((doc, _)) => {
420+
let _ = doc.pages.len();
421+
}
422+
Err(e) => {
423+
eprintln!("[WARN] {}: parse error (non-panic): {e}", $file);
424+
}
425+
}
426+
}
427+
}
428+
};
429+
}
430+
431+
// --- CC0 (Public Domain) ---------------------------------------------------
432+
433+
docx_fixture_tests!(ffc, "ffc.docx");
434+
docx_fixture_tests!(one_page, "1-page.docx");
435+
docx_fixture_tests!(three_pages, "3-pages.docx");
436+
docx_fixture_tests!(five_pages, "5-pages.docx");
437+
docx_fixture_tests!(ten_pages, "10-pages.docx");
438+
439+
// --- Apache POI (Apache 2.0) -----------------------------------------------
440+
441+
docx_fixture_tests!(bookmarks, "bookmarks.docx");
442+
docx_fixture_tests!(capitalized, "capitalized.docx");
443+
docx_fixture_tests!(chartex, "chartex.docx");
444+
docx_fixture_tests!(checkboxes, "checkboxes.docx");
445+
docx_fixture_tests!(comment, "comment.docx");
446+
docx_fixture_tests!(complex_numbered_lists, "ComplexNumberedLists.docx");
447+
docx_fixture_tests!(deep_table_cell, "deep-table-cell.docx");
448+
docx_fixture_tests!(delins, "delins.docx");
449+
docx_fixture_tests!(diff_first_page_head_foot, "DiffFirstPageHeadFoot.docx");
450+
docx_fixture_tests!(drawing, "drawing.docx");
451+
docx_fixture_tests!(embedded_document, "EmbeddedDocument.docx");
452+
docx_fixture_tests!(endnotes, "endnotes.docx");
453+
docx_fixture_tests!(fancy_foot, "FancyFoot.docx");
454+
docx_fixture_tests!(field_codes, "FieldCodes.docx");
455+
docx_fixture_tests!(header_footer_unicode, "HeaderFooterUnicode.docx");
456+
docx_fixture_tests!(heading123, "heading123.docx");
457+
docx_fixture_tests!(illustrative_cases, "IllustrativeCases.docx");
458+
docx_fixture_tests!(poi_footnotes, "poi_footnotes.docx");
459+
docx_fixture_tests!(poi_sample, "poi_sample.docx");
460+
docx_fixture_tests!(poi_styles, "poi_styles.docx");
461+
docx_fixture_tests!(various_pictures, "VariousPictures.docx");
462+
docx_fixture_tests!(with_tabs, "WithTabs.docx");
463+
docx_fixture_tests!(word_with_attachments, "WordWithAttachments.docx");
464+
465+
// --- MIT: Open-Xml-PowerTools (Microsoft) ----------------------------------
466+
467+
docx_fixture_tests!(oxp_table, "oxp_table.docx");
468+
docx_fixture_tests!(oxp_content_control, "oxp_content_control.docx");
469+
docx_fixture_tests!(oxp_lots_of_stuff, "oxp_lots_of_stuff.docx");
470+
docx_fixture_tests!(oxp_complex_table, "oxp_complex_table.docx");
471+
docx_fixture_tests!(oxp_footnote_ref, "oxp_footnote_ref.docx");

crates/office2pdf/tests/pptx_fixtures.rs

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,3 +202,81 @@ fn structure_test() {
202202
assert!(!pages.is_empty(), "should have at least one slide");
203203
assert!(has_textbox_with_content(&pages), "should have text content");
204204
}
205+
206+
// ===========================================================================
207+
// Third-party fixtures — smoke tests (must not panic)
208+
// ===========================================================================
209+
210+
/// Generate a pair of smoke + basic-structure tests for a PPTX fixture.
211+
macro_rules! pptx_fixture_tests {
212+
($test_name:ident, $file:expr) => {
213+
paste::paste! {
214+
#[test]
215+
fn [<smoke_ $test_name>]() {
216+
assert_produces_valid_pdf($file);
217+
}
218+
219+
#[test]
220+
fn [<structure_ $test_name>]() {
221+
let data = load_fixture($file);
222+
match PptxParser.parse(&data, &ConvertOptions::default()) {
223+
Ok((doc, _)) => {
224+
// Just verify parsing succeeds — slide count varies by file
225+
let _ = doc.pages.len();
226+
}
227+
Err(e) => {
228+
eprintln!("[WARN] {}: parse error (non-panic): {e}", $file);
229+
}
230+
}
231+
}
232+
}
233+
};
234+
}
235+
236+
// --- CC0 (Public Domain) ---------------------------------------------------
237+
238+
pptx_fixture_tests!(ffc, "ffc.pptx");
239+
pptx_fixture_tests!(one_slide, "1-slide.pptx");
240+
pptx_fixture_tests!(five_slides, "5-slides.pptx");
241+
pptx_fixture_tests!(ten_slides, "10-slides.pptx");
242+
243+
// --- Apache POI (Apache 2.0) -----------------------------------------------
244+
245+
pptx_fixture_tests!(bar_chart, "bar-chart.pptx");
246+
pptx_fixture_tests!(pie_chart, "pie-chart.pptx");
247+
pptx_fixture_tests!(line_chart, "line-chart.pptx");
248+
pptx_fixture_tests!(scatter_chart, "scatter-chart.pptx");
249+
pptx_fixture_tests!(radar_chart, "radar-chart.pptx");
250+
pptx_fixture_tests!(chart_picture_bg, "chart-picture-bg.pptx");
251+
pptx_fixture_tests!(table_test_poi, "table_test.pptx");
252+
pptx_fixture_tests!(table_test2, "table_test2.pptx");
253+
pptx_fixture_tests!(table_with_theme, "table-with-theme.pptx");
254+
pptx_fixture_tests!(backgrounds, "backgrounds.pptx");
255+
pptx_fixture_tests!(themes, "themes.pptx");
256+
pptx_fixture_tests!(smart_art, "SmartArt.pptx");
257+
pptx_fixture_tests!(smart_art_simple, "smartart-simple.pptx");
258+
pptx_fixture_tests!(embedded_audio, "EmbeddedAudio.pptx");
259+
pptx_fixture_tests!(embedded_video, "EmbeddedVideo.pptx");
260+
pptx_fixture_tests!(with_japanese, "with_japanese.pptx");
261+
pptx_fixture_tests!(with_master, "WithMaster.pptx");
262+
pptx_fixture_tests!(comment_45545, "45545_Comment.pptx");
263+
pptx_fixture_tests!(keyframes, "keyframes.pptx");
264+
pptx_fixture_tests!(layouts, "layouts.pptx");
265+
pptx_fixture_tests!(shapes, "shapes.pptx");
266+
pptx_fixture_tests!(custom_geo, "customGeo.pptx");
267+
pptx_fixture_tests!(highlight, "highlight-test-case.pptx");
268+
pptx_fixture_tests!(picture_transparency, "picture-transparency.pptx");
269+
pptx_fixture_tests!(poi_sample, "poi_sample.pptx");
270+
pptx_fixture_tests!(present1, "present1.pptx");
271+
pptx_fixture_tests!(rain, "rain.pptx");
272+
pptx_fixture_tests!(copy_slide_demo, "copy-slide-demo.pptx");
273+
274+
// --- MIT: Open-Xml-PowerTools (Microsoft) ----------------------------------
275+
276+
pptx_fixture_tests!(oxp_presentation, "oxp_Presentation.pptx");
277+
pptx_fixture_tests!(oxp_chart_cached, "oxp_CU018-Chart-Cached-Data-41.pptx");
278+
pptx_fixture_tests!(oxp_chart_embedded, "oxp_CU019-Chart-Embedded-Xlsx-41.pptx");
279+
pptx_fixture_tests!(oxp_pb001_input1, "oxp_PB001-Input1.pptx");
280+
pptx_fixture_tests!(oxp_pb001_input2, "oxp_PB001-Input2.pptx");
281+
pptx_fixture_tests!(oxp_pb001_input3, "oxp_PB001-Input3.pptx");
282+
pptx_fixture_tests!(oxp_videos, "oxp_PP006-Videos.pptx");

crates/office2pdf/tests/xlsx_fixtures.rs

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,3 +236,98 @@ fn structure_temperature() {
236236
assert!(!pages.is_empty(), "should have at least one sheet");
237237
assert!(total_rows(&pages) > 0, "should have data rows");
238238
}
239+
240+
// ===========================================================================
241+
// Third-party fixtures — smoke tests (must not panic)
242+
// ===========================================================================
243+
244+
/// Generate a pair of smoke + basic-structure tests for an XLSX fixture.
245+
macro_rules! xlsx_fixture_tests {
246+
($test_name:ident, $file:expr) => {
247+
paste::paste! {
248+
#[test]
249+
fn [<smoke_ $test_name>]() {
250+
assert_produces_valid_pdf($file);
251+
}
252+
253+
#[test]
254+
fn [<structure_ $test_name>]() {
255+
let data = load_fixture($file);
256+
match XlsxParser.parse(&data, &ConvertOptions::default()) {
257+
Ok((doc, _)) => {
258+
let _ = doc.pages.len();
259+
}
260+
Err(e) => {
261+
eprintln!("[WARN] {}: parse error (non-panic): {e}", $file);
262+
}
263+
}
264+
}
265+
}
266+
};
267+
}
268+
269+
// --- CC0 (Public Domain) ---------------------------------------------------
270+
271+
xlsx_fixture_tests!(ffc, "ffc.xlsx");
272+
xlsx_fixture_tests!(hundred_customers, "100-customers.xlsx");
273+
xlsx_fixture_tests!(thousand_customers, "1000-customers.xlsx");
274+
275+
// --- Apache POI (Apache 2.0) -----------------------------------------------
276+
277+
xlsx_fixture_tests!(charts_123233, "123233_charts.xlsx");
278+
xlsx_fixture_tests!(booleans, "Booleans.xlsx");
279+
xlsx_fixture_tests!(chart_sheet, "chart_sheet.xlsx");
280+
xlsx_fixture_tests!(comments, "comments.xlsx");
281+
xlsx_fixture_tests!(excel_pivot_table, "ExcelPivotTableSample.xlsx");
282+
xlsx_fixture_tests!(excel_tables, "ExcelTables.xlsx");
283+
xlsx_fixture_tests!(formatting, "Formatting.xlsx");
284+
xlsx_fixture_tests!(group_test, "GroupTest.xlsx");
285+
xlsx_fixture_tests!(header_footer_test, "headerFooterTest.xlsx");
286+
xlsx_fixture_tests!(inline_string, "InlineString.xlsx");
287+
xlsx_fixture_tests!(picture, "picture.xlsx");
288+
xlsx_fixture_tests!(right_to_left, "right-to-left.xlsx");
289+
xlsx_fixture_tests!(sample_ss, "SampleSS.xlsx");
290+
xlsx_fixture_tests!(shared_formulas, "shared_formulas.xlsx");
291+
xlsx_fixture_tests!(sheet_tab_colors, "SheetTabColors.xlsx");
292+
xlsx_fixture_tests!(simple_monthly_budget, "simple-monthly-budget.xlsx");
293+
xlsx_fixture_tests!(simple_scatter_chart, "SimpleScatterChart.xlsx");
294+
xlsx_fixture_tests!(themes, "Themes.xlsx");
295+
xlsx_fixture_tests!(with_chart, "WithChart.xlsx");
296+
xlsx_fixture_tests!(with_drawing, "WithDrawing.xlsx");
297+
xlsx_fixture_tests!(with_more_various_data, "WithMoreVariousData.xlsx");
298+
xlsx_fixture_tests!(with_text_box, "WithTextBox.xlsx");
299+
xlsx_fixture_tests!(with_various_data, "WithVariousData.xlsx");
300+
301+
// --- MIT: Open-Xml-PowerTools (Microsoft) ----------------------------------
302+
303+
xlsx_fixture_tests!(
304+
sh003_date_first_col,
305+
"SH003-TableWithDateInFirstColumn.xlsx"
306+
);
307+
xlsx_fixture_tests!(sh004_offset_location, "SH004-TableAtOffsetLocation.xlsx");
308+
xlsx_fixture_tests!(sh005_shared_strings, "SH005-Table-With-SharedStrings.xlsx");
309+
xlsx_fixture_tests!(sh006_no_shared_strings, "SH006-Table-No-SharedStrings.xlsx");
310+
xlsx_fixture_tests!(sh007_one_cell, "SH007-One-Cell-Table.xlsx");
311+
xlsx_fixture_tests!(sh008_tall_row, "SH008-Table-With-Tall-Row.xlsx");
312+
xlsx_fixture_tests!(sh101_simple_formats, "SH101-SimpleFormats.xlsx");
313+
xlsx_fixture_tests!(sh102_9x9, "SH102-9-x-9.xlsx");
314+
xlsx_fixture_tests!(sh103_no_shared_string, "SH103-No-SharedString.xlsx");
315+
xlsx_fixture_tests!(sh104_with_shared_string, "SH104-With-SharedString.xlsx");
316+
xlsx_fixture_tests!(sh105_no_shared_string2, "SH105-No-SharedString.xlsx");
317+
xlsx_fixture_tests!(sh107_formatted_table, "SH107-9-x-9-Formatted-Table.xlsx");
318+
xlsx_fixture_tests!(
319+
sh108_simple_formatted_cell,
320+
"SH108-SimpleFormattedCell.xlsx"
321+
);
322+
323+
// --- MIT: calamine (Rust) --------------------------------------------------
324+
325+
xlsx_fixture_tests!(date_1904, "date_1904.xlsx");
326+
xlsx_fixture_tests!(empty_sheet, "empty_sheet.xlsx");
327+
xlsx_fixture_tests!(errors, "errors.xlsx");
328+
xlsx_fixture_tests!(pivots, "pivots.xlsx");
329+
xlsx_fixture_tests!(richtext_namespaced, "richtext-namespaced.xlsx");
330+
xlsx_fixture_tests!(column_row_ranges, "column_row_ranges.xlsx");
331+
xlsx_fixture_tests!(table_multiple, "table-multiple.xlsx");
332+
xlsx_fixture_tests!(formula_issue, "formula.issue.xlsx");
333+
xlsx_fixture_tests!(header_row, "header-row.xlsx");

0 commit comments

Comments
 (0)