terminal2: more selectLine tests

This commit is contained in:
Mitchell Hashimoto
2024-03-06 14:01:24 -08:00
parent f91624ab61
commit 201ad4d850
2 changed files with 105 additions and 0 deletions

View File

@ -4606,6 +4606,7 @@ test "Screen: selectLine semantic prompt boundary" {
}
}
// X
test "Screen: selectLine across soft-wrap ignores blank lines" {
const testing = std.testing;
const alloc = testing.allocator;
@ -4642,6 +4643,7 @@ test "Screen: selectLine across soft-wrap ignores blank lines" {
}
}
// X
test "Screen: selectLine with scrollback" {
const testing = std.testing;
const alloc = testing.allocator;

View File

@ -3729,6 +3729,66 @@ test "Screen: selectLine across soft-wrap" {
}
}
test "Screen: selectLine across soft-wrap ignores blank lines" {
const testing = std.testing;
const alloc = testing.allocator;
var s = try init(alloc, 5, 10, 0);
defer s.deinit();
try s.testWriteString(" 12 34012 \n 123");
// Going forward
{
var sel = s.selectLine(s.pages.pin(.{ .active = .{
.x = 1,
.y = 0,
} }).?).?;
defer sel.deinit(&s);
try testing.expectEqual(point.Point{ .screen = .{
.x = 1,
.y = 0,
} }, s.pages.pointFromPin(.screen, sel.start().*).?);
try testing.expectEqual(point.Point{ .screen = .{
.x = 3,
.y = 1,
} }, s.pages.pointFromPin(.screen, sel.end().*).?);
}
// Going backward
{
var sel = s.selectLine(s.pages.pin(.{ .active = .{
.x = 1,
.y = 1,
} }).?).?;
defer sel.deinit(&s);
try testing.expectEqual(point.Point{ .screen = .{
.x = 1,
.y = 0,
} }, s.pages.pointFromPin(.screen, sel.start().*).?);
try testing.expectEqual(point.Point{ .screen = .{
.x = 3,
.y = 1,
} }, s.pages.pointFromPin(.screen, sel.end().*).?);
}
// Going forward and backward
{
var sel = s.selectLine(s.pages.pin(.{ .active = .{
.x = 3,
.y = 0,
} }).?).?;
defer sel.deinit(&s);
try testing.expectEqual(point.Point{ .screen = .{
.x = 1,
.y = 0,
} }, s.pages.pointFromPin(.screen, sel.start().*).?);
try testing.expectEqual(point.Point{ .screen = .{
.x = 3,
.y = 1,
} }, s.pages.pointFromPin(.screen, sel.end().*).?);
}
}
test "Screen: selectAll" {
const testing = std.testing;
const alloc = testing.allocator;
@ -3764,3 +3824,46 @@ test "Screen: selectAll" {
} }, s.pages.pointFromPin(.screen, sel.end().*).?);
}
}
test "Screen: selectLine with scrollback" {
const testing = std.testing;
const alloc = testing.allocator;
var s = try init(alloc, 2, 3, 5);
defer s.deinit();
try s.testWriteString("1A\n2B\n3C\n4D\n5E");
// Selecting first line
{
var sel = s.selectLine(s.pages.pin(.{ .active = .{
.x = 0,
.y = 0,
} }).?).?;
defer sel.deinit(&s);
try testing.expectEqual(point.Point{ .active = .{
.x = 0,
.y = 0,
} }, s.pages.pointFromPin(.active, sel.start().*).?);
try testing.expectEqual(point.Point{ .active = .{
.x = 1,
.y = 0,
} }, s.pages.pointFromPin(.active, sel.end().*).?);
}
// Selecting last line
{
var sel = s.selectLine(s.pages.pin(.{ .active = .{
.x = 0,
.y = 2,
} }).?).?;
defer sel.deinit(&s);
try testing.expectEqual(point.Point{ .active = .{
.x = 0,
.y = 2,
} }, s.pages.pointFromPin(.active, sel.start().*).?);
try testing.expectEqual(point.Point{ .active = .{
.x = 1,
.y = 2,
} }, s.pages.pointFromPin(.active, sel.end().*).?);
}
}