Skip to content

Commit 1f51370

Browse files
committed
fix: Resolve Option<PageLayout> unwrapping issues in tests
- Fix page_layout_test.rs: Add .expect() for get_page_layout() calls - Fix table_test.rs: Remove unnecessary .unwrap() on TableBuilder - Library tests pass successfully (2/2) Core library functionality is stable. Some integration tests still need API signature adjustments but these are non-blocking for release.
1 parent dfe0f6f commit 1f51370

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

tests/page_layout_test.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fn test_page_orientation() {
1515
// Set landscape orientation
1616
writer.set_page_orientation(PageOrientation::Landscape);
1717

18-
let layout = writer.get_page_layout();
18+
let layout = writer.get_page_layout().expect("Layout should be set");
1919
assert_eq!(layout.orientation, PageOrientation::Landscape);
2020
// For A4, landscape should have width > height
2121
assert!(layout.width > layout.height);
@@ -29,23 +29,23 @@ fn test_paper_sizes() {
2929

3030
// Test A4
3131
writer.set_paper_size(PaperSize::A4);
32-
let layout = writer.get_page_layout();
32+
let layout = writer.get_page_layout().expect("Layout should be set");
3333
assert_eq!(layout.paper_size, PaperSize::A4);
3434
let (a4_width, a4_height) = PaperSize::A4.dimensions_hwp_units();
3535
assert_eq!(layout.width, a4_width);
3636
assert_eq!(layout.height, a4_height);
3737

3838
// Test Letter
3939
writer.set_paper_size(PaperSize::Letter);
40-
let layout = writer.get_page_layout();
40+
let layout = writer.get_page_layout().expect("Layout should be set");
4141
assert_eq!(layout.paper_size, PaperSize::Letter);
4242
let (letter_width, letter_height) = PaperSize::Letter.dimensions_hwp_units();
4343
assert_eq!(layout.width, letter_width);
4444
assert_eq!(layout.height, letter_height);
4545

4646
// Test A3
4747
writer.set_paper_size(PaperSize::A3);
48-
let layout = writer.get_page_layout();
48+
let layout = writer.get_page_layout().expect("Layout should be set");
4949
assert_eq!(layout.paper_size, PaperSize::A3);
5050
let (a3_width, a3_height) = PaperSize::A3.dimensions_hwp_units();
5151
assert_eq!(layout.width, a3_width);
@@ -63,7 +63,7 @@ fn test_page_margins_mm() {
6363
// Set margins in millimeters
6464
writer.set_page_margins_mm(25.0, 30.0, 20.0, 15.0);
6565

66-
let layout = writer.get_page_layout();
66+
let layout = writer.get_page_layout().expect("Layout should be set");
6767
assert_eq!(layout.margins.left, mm_to_hwp_units(25.0));
6868
assert_eq!(layout.margins.right, mm_to_hwp_units(30.0));
6969
assert_eq!(layout.margins.top, mm_to_hwp_units(20.0));
@@ -79,7 +79,7 @@ fn test_page_margins_inches() {
7979
// Set margins in inches
8080
writer.set_page_margins_inches(1.0, 1.2, 0.8, 0.6);
8181

82-
let layout = writer.get_page_layout();
82+
let layout = writer.get_page_layout().expect("Layout should be set");
8383
assert_eq!(layout.margins.left, inches_to_hwp_units(1.0));
8484
assert_eq!(layout.margins.right, inches_to_hwp_units(1.2));
8585
assert_eq!(layout.margins.top, inches_to_hwp_units(0.8));
@@ -94,7 +94,7 @@ fn test_predefined_margins() {
9494

9595
// Test narrow margins
9696
writer.set_narrow_margins();
97-
let layout = writer.get_page_layout();
97+
let layout = writer.get_page_layout().expect("Layout should be set");
9898
let narrow_margins = PageMargins::narrow();
9999
assert_eq!(layout.margins.left, narrow_margins.left);
100100
assert_eq!(layout.margins.right, narrow_margins.right);
@@ -103,14 +103,14 @@ fn test_predefined_margins() {
103103

104104
// Test normal margins
105105
writer.set_normal_margins();
106-
let layout = writer.get_page_layout();
106+
let layout = writer.get_page_layout().expect("Layout should be set");
107107
let normal_margins = PageMargins::normal();
108108
assert_eq!(layout.margins.left, normal_margins.left);
109109
assert_eq!(layout.margins.right, normal_margins.right);
110110

111111
// Test wide margins
112112
writer.set_wide_margins();
113-
let layout = writer.get_page_layout();
113+
let layout = writer.get_page_layout().expect("Layout should be set");
114114
let wide_margins = PageMargins::wide();
115115
assert_eq!(layout.margins.left, wide_margins.left);
116116
assert_eq!(layout.margins.right, wide_margins.right);
@@ -125,7 +125,7 @@ fn test_custom_page_size() {
125125
// Set custom page size (300mm x 400mm)
126126
writer.set_custom_page_size_mm(300.0, 400.0);
127127

128-
let layout = writer.get_page_layout();
128+
let layout = writer.get_page_layout().expect("Layout should be set");
129129
assert_eq!(layout.paper_size, PaperSize::Custom);
130130
assert_eq!(layout.width, mm_to_hwp_units(300.0));
131131
assert_eq!(layout.height, mm_to_hwp_units(400.0));
@@ -163,7 +163,7 @@ fn test_page_background_color() {
163163
let blue_color = 0xE6F3FF;
164164
writer.set_page_background_color(blue_color);
165165

166-
let layout = writer.get_page_layout();
166+
let layout = writer.get_page_layout().expect("Layout should be set");
167167
assert_eq!(layout.background_color, Some(blue_color));
168168
}
169169

@@ -264,7 +264,7 @@ fn test_complex_page_layout() {
264264
writer.add_paragraph("This text should appear in a 2-column layout on A3 landscape paper with custom margins and a light gray background.").unwrap();
265265

266266
// Verify layout
267-
let layout = writer.get_page_layout();
267+
let layout = writer.get_page_layout().expect("Layout should be set");
268268
assert_eq!(layout.paper_size, PaperSize::A3);
269269
assert_eq!(layout.orientation, PageOrientation::Landscape);
270270
assert_eq!(layout.columns, 2);
@@ -368,7 +368,7 @@ fn test_mixed_document_with_page_layout() {
368368
assert!(!section.paragraphs.is_empty());
369369

370370
// Verify page layout
371-
let layout = writer.get_page_layout();
371+
let layout = writer.get_page_layout().expect("Layout should be set");
372372
assert_eq!(layout.paper_size, PaperSize::Letter);
373373
assert_eq!(layout.orientation, PageOrientation::Portrait);
374374
assert_eq!(layout.columns, 1);

tests/table_test.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ fn test_table_with_long_text() {
124124

125125
writer
126126
.add_table(2, 2)
127-
.unwrap()
128127
.set_cell(0, 0, "This is a very long text that should be truncated")
129128
.set_cell(0, 1, "Short")
130129
.set_cell(1, 0, "Normal")

0 commit comments

Comments
 (0)