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.zig22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig
index be90bb6f..978ce707 100644
--- a/src/ninep/ctl.zig
+++ b/src/ninep/ctl.zig
@@ -2115,6 +2115,28 @@ 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 corrupt image fails its look with an err, and no pane is made" {
+ pardes.image.start(testing.io, testing.allocator);
+ defer pardes.image.stop();
+ const p = try withFile(testing.allocator, "x\n");
+ defer p.deinit();
+ var tmp = testing.tmpDir(.{});
+ defer tmp.cleanup();
+ try tmp.dir.writeFile(testing.io, .{ .sub_path = "bad.png", .data = "\x89PNG not really" });
+ var dir_buf: [4096]u8 = undefined;
+ const dir = dir_buf[0..try tmp.dir.realPath(testing.io, &dir_buf)];
+ var line: [4200]u8 = undefined;
+ var count: usize = 0;
+ for (p.panes) |slot| count += @intFromBool(slot != null);
+ const r = wr(p, root_look, try std.fmt.bufPrint(&line, "{s}/bad.png\n", .{dir}));
+ try testing.expectEqual(E.IO, r.errno());
+ try testing.expect(std.mem.endsWith(u8, r.reply.ename, "bad.png: not an image pardes can read"));
+ p.sync();
+ var after: usize = 0;
+ for (p.panes) |slot| after += @intFromBool(slot != null);
+ try testing.expectEqual(count, after);
+}
+
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");