summaryrefslogtreecommitdiff
path: root/test/pdf.zig
diff options
context:
space:
mode:
Diffstat (limited to 'test/pdf.zig')
-rw-r--r--test/pdf.zig17
1 files changed, 14 insertions, 3 deletions
diff --git a/test/pdf.zig b/test/pdf.zig
index 04b2e8b9..113ed8b9 100644
--- a/test/pdf.zig
+++ b/test/pdf.zig
@@ -1576,12 +1576,20 @@ test "PDF n/N addresses and reveals distinct MuPDF hits on one page" {
const results = p.panes[results_id].?.file.?;
var found: [3]bool = @splat(false);
for (results.location_rows, 0..) |row, index| {
- // PDF locations address page/hit pairs, not binary file lines.
+ // PDF locations address page/hit pairs, not binary file lines. Each
+ // address owns one snippet, which must not add a navigation stop.
+ if (index % 2 == 1) {
+ try std.testing.expectEqual(.preview, row.kind);
+ try std.testing.expectEqual(results.location_rows[index - 1].at, row.at);
+ try std.testing.expectEqual(@as(usize, 0), row.code_start);
+ try std.testing.expectEqualStrings("Pardes", pardes.modal.lineSlice(results.content, index));
+ continue;
+ }
try std.testing.expectEqual(.match, row.kind);
+ const line = pardes.modal.lineSlice(results.content, index);
+ try std.testing.expectEqual(line.len, row.code_start);
if (!std.mem.endsWith(u8, row.path, "design.pdf") or row.at.line != 1) continue;
if (row.at.col < 1 or row.at.col > found.len) continue;
- const line = pardes.modal.lineSlice(results.content, index);
- try std.testing.expectEqualStrings("Pardes", line[row.code_start..]);
found[row.at.col - 1] = true;
}
for (found) |present| try std.testing.expect(present);
@@ -1599,6 +1607,7 @@ test "PDF n/N addresses and reveals distinct MuPDF hits on one page" {
defer frame.deinit();
try std.testing.expect(pardes.test_api.searchStep(p, 0, 1));
try std.testing.expectEqual(@as(usize, 0), pv.search_hit);
+ try std.testing.expectEqual(@as(usize, 0), pane.search_row.?);
const first = try p.render(frame.allocator());
const revision = first.images[0].?.native.revision;
const raster = panes.Pdf.rasterForPage(pv, pv.page).?;
@@ -1617,12 +1626,14 @@ test "PDF n/N addresses and reveals distinct MuPDF hits on one page" {
try std.testing.expect(pardes.test_api.searchStep(p, 0, 1));
try std.testing.expectEqual(@as(usize, 1), pv.search_hit);
+ try std.testing.expectEqual(@as(usize, 2), pane.search_row.?);
_ = frame.reset(.retain_capacity);
const second = try p.render(frame.allocator());
try std.testing.expectEqual(revision, second.images[0].?.native.revision);
try std.testing.expect(pardes.test_api.searchStep(p, 0, 1));
try std.testing.expectEqual(@as(usize, 2), pv.search_hit);
+ try std.testing.expectEqual(@as(usize, 4), pane.search_row.?);
_ = frame.reset(.retain_capacity);
const third = try p.render(frame.allocator());
try std.testing.expectEqual(revision, third.images[0].?.native.revision);