summaryrefslogtreecommitdiff
path: root/src/ninep/ctl.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/ninep/ctl.zig')
-rw-r--r--src/ninep/ctl.zig21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig
index db058ff2..be90bb6f 100644
--- a/src/ninep/ctl.zig
+++ b/src/ninep/ctl.zig
@@ -2115,6 +2115,27 @@ test "a language server question that finds nothing, cannot be answered, or is a
try testing.expectEqual(E.INVAL, wr(p, Node.of(img.serial, .body), "text\n").errno());
}
+test "a PDF's body reads its page's text layer, and takes no write" {
+ if (comptime !pardes.pdf_enabled) return;
+ const p = try withFile(testing.allocator, "x\n");
+ defer p.deinit();
+ var tmp = testing.tmpDir(.{});
+ defer tmp.cleanup();
+ const bytes = try @import("mupdf").makeLinksTestPdf(testing.allocator);
+ defer testing.allocator.free(bytes);
+ try tmp.dir.writeFile(testing.io, .{ .sub_path = "doc.pdf", .data = bytes });
+ var dir_buf: [4096]u8 = undefined;
+ const dir = dir_buf[0..try tmp.dir.realPath(testing.io, &dir_buf)];
+ var line: [4200]u8 = undefined;
+ _ = wr(p, root_look, try std.fmt.bufPrint(&line, "{s}/doc.pdf\n", .{dir}));
+ p.sync();
+ const doc = p.panes[p.active].?;
+ try testing.expect(doc.hasPdf());
+ const body = Node.of(doc.serial, .body);
+ try testing.expect(std.mem.indexOf(u8, rd(p, body, 0, 4096).bytes, "target.txt") != null);
+ try testing.expectEqual(E.INVAL, wr(p, body, "more\n").errno());
+}
+
test "every EINVAL a write gets says why, in its err record too; DEL is a control character in a line" {
const p = try withFile(testing.allocator, "x\n");
defer p.deinit();