diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/pdf.zig | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/pdf.zig b/test/pdf.zig index 2a18ca3c..fbd580b3 100644 --- a/test/pdf.zig +++ b/test/pdf.zig @@ -384,6 +384,29 @@ test "PdfSections on a PDF with no outline says so and opens nothing" { } } +test "Recent keeps a PDF as it keeps a file: open, then closed at its page" { + if (!pdf_enabled or platform == .web) return; + const gpa = std.testing.allocator; + var tmp = std.testing.tmpDir(.{}); + defer tmp.cleanup(); + const fixture = try pdf_impl.makeNoOutlineTestPdf(gpa); + defer gpa.free(fixture); + try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "plain.pdf", .data = fixture }); + var dir_buf: [4096]u8 = undefined; + const dir = dir_buf[0..try tmp.dir.realPath(std.testing.io, &dir_buf)]; + var path_buf: [4200]u8 = undefined; + const path = try std.fmt.bufPrint(&path_buf, "{s}/plain.pdf", .{dir}); + const p = try Pardes.init(gpa, .{ .cols = 80, .rows = 28 }); + defer p.deinit(); + pardes.look.lookAt(p, p.active, path); + p.update(.{ .resize = .{ .cols = 80, .rows = 28 } }); // an update's end announces it + var out: std.Io.Writer.Allocating = .init(gpa); + defer out.deinit(); + try panes.Output.recentText(p, &out.writer, true); + var want: [4300]u8 = undefined; + try std.testing.expect(std.mem.indexOf(u8, out.written(), try std.fmt.bufPrint(&want, "{s}:1:1 open\n", .{path})) != null); +} + test "a look at a PDF's page past its last is a miss, never the last page" { if (!pdf_enabled or platform == .web) return; const gpa = std.testing.allocator; |
