summaryrefslogtreecommitdiff
path: root/test/pdf.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-15 13:21:29 -0300
committerGabriel Schneider <[email protected]>2026-09-15 17:24:42 -0300
commit2bdde8c5ec1049ea0f575c6f9165ed4cef00ea50 (patch)
tree0d7879e387223bd19d78a295bee0ba7ab3a62e00 /test/pdf.zig
parent8ec8924cd577f71953f8e420af1cd60da92f3300 (diff)
downloadpardes-2bdde8c5ec1049ea0f575c6f9165ed4cef00ea50.tar.gz
pardes-2bdde8c5ec1049ea0f575c6f9165ed4cef00ea50.zip
Align location results and configure source context
Diffstat (limited to 'test/pdf.zig')
-rw-r--r--test/pdf.zig18
1 files changed, 14 insertions, 4 deletions
diff --git a/test/pdf.zig b/test/pdf.zig
index 4c0daf34..a835c6ea 100644
--- a/test/pdf.zig
+++ b/test/pdf.zig
@@ -1408,12 +1408,22 @@ test "PDF n/N addresses and reveals distinct MuPDF hits on one page" {
defer page_hits.deinit(gpa);
try std.testing.expect(page_hits.hit_count >= 3);
+ p.locations_config.context = 2;
+ p.locations_config.tscontext = true;
try p.runSearch(0, "Pardes", .text, .top);
const results_id = pane.search_pane orelse return error.MissingPdfSearchResults;
- const rows = p.panes[results_id].?.file.?.content;
- try std.testing.expect(std.mem.indexOf(u8, rows, "design.pdf:1:1 Pardes\n") != null);
- try std.testing.expect(std.mem.indexOf(u8, rows, "design.pdf:1:2 Pardes\n") != null);
- try std.testing.expect(std.mem.indexOf(u8, rows, "design.pdf:1:3 Pardes\n") != null);
+ 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.
+ try std.testing.expectEqual(.match, row.kind);
+ 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);
// Exaggerate the cell aspect only to make the three fixture hits occupy
// distinct fit-width crops. The search/reveal math must use the same