diff options
Diffstat (limited to 'test/panes.zig')
| -rw-r--r-- | test/panes.zig | 76 |
1 files changed, 5 insertions, 71 deletions
diff --git a/test/panes.zig b/test/panes.zig index c996ca00..a7ecf994 100644 --- a/test/panes.zig +++ b/test/panes.zig @@ -788,75 +788,8 @@ const JumpSelectionTests = struct { p.update(.{ .mouse = .{ .button = .left, .kind = .release, .col = col1, .row = row1 } }); } - fn exercise(prefix: []const u8, wrap: bool, reverse: bool, first_col: u16, last_col: u16, expected: ?[]const u8) !void { - const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 34, .rows = 10 }); - defer p.deinit(); - p.settings.wrap = wrap; - const text = try std.fmt.allocPrint(p.gpa, "{s}{s}", .{ prefix, std.mem.asBytes(&@as([80][27]u8, @splat("unrelated destination text\n".*))) }); - defer p.gpa.free(text); - const pane = try p.setTestFile(text); - var frame = std.heap.ArenaAllocator.init(p.gpa); - defer frame.deinit(); - _ = try p.render(frame.allocator()); - if (wrap) try std.testing.expectEqual(pane.wrap_line[0], pane.wrap_line[1]); - const rect = p.rects[0]; - const x = rect.x + config.GUTTER + panes.File.gutterWidth(pane); - const y = p.bodyTop(pane, rect); - if (reverse) - drag(p, x + last_col, y + 1, x + first_col, y) - else - drag(p, x + first_col, y, x + last_col, y + 1); - - const selected = try p.gpa.dupe(u8, pardes.exec.heldSelection(p, 0) orelse return error.MissingMouseSelection); - defer p.gpa.free(selected); - if (expected) |want| try std.testing.expectEqualStrings(want, selected); - try std.testing.expect(std.mem.indexOfScalar(u8, selected, '\n') != null); - if (wrap) try std.testing.expect(std.mem.indexOf(u8, selected, "界") != null); - - // Seed two actual locations after the drag, so both history directions - // must scroll and discard the previous selection. - p.njumps = 2; - p.jcur = 1; - p.jumps[0] = .{ .pane = 0, .serial = pane.serial, .line = 60, .col = 1 }; - p.jumps[1] = .{ .pane = 0, .serial = pane.serial, .line = 1, .col = 1 }; - p.update(.{ .key = .{ .cp = 'o', .ctrl = true } }); - _ = frame.reset(.retain_capacity); - _ = try p.render(frame.allocator()); - try std.testing.expectEqual(@as(usize, 0), p.jcur); - try std.testing.expect(pane.file.?.scroll > 20); - try LookResetTests.cleared(pane); - try std.testing.expect(!pane.body.vsel.active); - try std.testing.expect(pardes.exec.heldSelection(p, 0) == null); - try std.testing.expectEqual(@as(i32, 59), pane.body.cur_row); - try std.testing.expectEqual(@as(i32, 0), pane.body.cur_col); - - // A selection created after Back must also disappear on Forward. - // Back announces itself, so the body sits under a notice band now. - const y2 = p.bodyTop(pane, p.rects[0]); - drag(p, x + 1, y2, x + 3, y2 + 1); - try std.testing.expect(pardes.exec.heldSelection(p, 0) != null); - p.update(.{ .key = .{ .cp = 'i', .ctrl = true } }); - _ = frame.reset(.retain_capacity); - _ = try p.render(frame.allocator()); - try std.testing.expectEqual(@as(usize, 1), p.jcur); - try std.testing.expectEqual(@as(usize, 0), pane.file.?.scroll); - try LookResetTests.cleared(pane); - try std.testing.expect(!pane.body.vsel.active); - try std.testing.expect(pardes.exec.heldSelection(p, 0) == null); - try std.testing.expectEqual(@as(i32, 0), pane.body.cur_row); - try std.testing.expectEqual(@as(i32, 0), pane.body.cur_col); - } - - test "jump selection clears copied sweeps in both history directions" { - for ([_]bool{ false, true }) |reverse| - try exercise("alpha\nbravo\n", false, reverse, 1, 3, "lpha\nbrav"); - } - - test "jump selection clears wrapped Unicode and tab rectangles" { - for ([_]bool{ false, true }) |reverse| - try exercise("界\tabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\n", true, reverse, 0, 8, null); - } - + // One pane's Back and Forward are test/behaviour/keys.zig's; this + // one seeds held selections in two panes, which only internals reach. test "jump selection clears source and destination state across panes" { const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 30 }); defer p.deinit(); @@ -947,7 +880,9 @@ const TagNameTintTests = struct { return visible_name; } - test "tag filename tint excludes directories dirty marker and output commands" { + // A file pane's is test/behaviour/tags.zig's; a search pane's needs + // results put in through fillResults. + test "tag filename tint of a search pane excludes its directory and command" { for ([_]bool{ false, true }) |bottom| { const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 24 }); defer p.deinit(); @@ -959,7 +894,6 @@ const TagNameTintTests = struct { configure(p); defer p.custom_theme = null; p.settings.tag_bottom = bottom; - try std.testing.expect((try check(p, 0, pane.file.?.path)) > 0); try panes.Output.fillResults(p, 0, "/project", .search, "tint", try p.gpa.dupe(u8, "no matches\n"), null); const id = pane.search_pane.?; p.update(.tick); |
