Skip to content

Commit efc9ca2

Browse files
committed
test: verify XLSX conversion improvements from patched umya-spreadsheet
Add comprehensive tests for all 15 previously-panicking XLSX files: - 12 files now convert successfully (were: FileNotFound, ParseFloatError, unwrap on None, dataBar EOF panics) - 3 files still return clean errors via catch_unwind (arithmetic overflow and remaining unwrap on None in other code paths) All 7 previously-erroring files remain unchanged (zip-level errors). Summary: panic count reduced from 15 to 3 (80% improvement), successful conversions increased by 12 files. Related: #83 Signed-off-by: Yonghye Kwon <developer.0hye@gmail.com>
1 parent 924c31e commit efc9ca2

File tree

1 file changed

+51
-6
lines changed

1 file changed

+51
-6
lines changed

crates/office2pdf/tests/xlsx_fixtures.rs

Lines changed: 51 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -382,18 +382,32 @@ xlsx_fixture_tests!(
382382
"SH108-SimpleFormattedCell.xlsx"
383383
);
384384

385-
// --- Upstream panic safety ---------------------------------------------------
385+
// --- Upstream panic safety (patched umya-spreadsheet) ------------------------
386+
// Related: #83
386387

387-
/// Verifies that files which previously triggered upstream panics
388-
/// (umya-spreadsheet unwrap()) now convert successfully thanks to the patched
389-
/// fork (developer0hye/umya-spreadsheet fix/panic-safety-v2).
388+
/// Files that previously panicked in umya-spreadsheet now convert successfully
389+
/// after the fork fix (developer0hye/umya-spreadsheet fix/panic-safety-v2).
390+
///
391+
/// 12 of 15 previously-panicking files now produce valid PDFs.
390392
#[test]
391393
fn previously_panicking_files_now_convert() {
392394
let cases: &[&str] = &[
393-
// Previously panicked with: unwrap() on missing zip entry (FileNotFound)
395+
// FileNotFound panics (7 files — all now succeed)
394396
"libreoffice/chart_hyperlink.xlsx",
395-
// Previously panicked with: ParseFloatError on boolean cell
397+
"libreoffice/hyperlink.xlsx",
398+
"libreoffice/tdf130959.xlsx",
399+
"libreoffice/test_115192.xlsx",
400+
"poi/47504.xlsx",
401+
"poi/bug63189.xlsx",
402+
"poi/ConditionalFormattingSamples.xlsx",
403+
// ParseFloatError / boolean cell (1 file — now succeeds)
396404
"libreoffice/check-boolean.xlsx",
405+
// unwrap() on None (2 of 3 now succeed)
406+
"libreoffice/tdf100709.xlsx",
407+
"poi/sample-beta.xlsx",
408+
// dataBar end element (2 files — both now succeed)
409+
"libreoffice/tdf162948.xlsx",
410+
"poi/NewStyleConditionalFormattings.xlsx",
397411
];
398412
for name in cases {
399413
let path = fixture_path(name);
@@ -405,6 +419,37 @@ fn previously_panicking_files_now_convert() {
405419
}
406420
}
407421

422+
/// 3 previously-panicking files still fail but now return clean errors
423+
/// (no process crash). These have deeper arithmetic overflow / missing data
424+
/// issues in umya-spreadsheet that our patch does not address.
425+
#[test]
426+
fn remaining_panic_files_return_clean_errors() {
427+
let cases: &[&str] = &[
428+
// ParseIntError PosOverflow → arithmetic overflow in formula parsing
429+
"libreoffice/functions-excel-2010.xlsx",
430+
"poi/FormulaEvalTestData_Copy.xlsx",
431+
// unwrap() on None in a different code path
432+
"poi/64450.xlsx",
433+
];
434+
for name in cases {
435+
let path = fixture_path(name);
436+
if !path.exists() {
437+
eprintln!("Skipping {name}: fixture not available");
438+
continue;
439+
}
440+
let data = std::fs::read(&path).unwrap();
441+
let result = office2pdf::convert_bytes(
442+
&data,
443+
office2pdf::config::Format::Xlsx,
444+
&ConvertOptions::default(),
445+
);
446+
assert!(
447+
result.is_err(),
448+
"{name} should return Err (still has upstream issues)"
449+
);
450+
}
451+
}
452+
408453
// --- MIT: calamine (Rust) --------------------------------------------------
409454

410455
xlsx_fixture_tests!(date_1904, "date_1904.xlsx");

0 commit comments

Comments
 (0)