terminal: dirty tests for insertLines

This commit is contained in:
Mitchell Hashimoto
2024-04-16 10:59:38 -07:00
parent f7a57bd2c8
commit 58aa4cc10b

View File

@ -4425,8 +4425,15 @@ test "Terminal: insertLines simple" {
try t.linefeed(); try t.linefeed();
try t.printString("GHI"); try t.printString("GHI");
t.setCursorPos(2, 2); t.setCursorPos(2, 2);
t.clearDirty();
t.insertLines(1); t.insertLines(1);
try testing.expect(!t.isDirty(.{ .active = .{ .x = 0, .y = 0 } }));
try testing.expect(t.isDirty(.{ .active = .{ .x = 0, .y = 1 } }));
try testing.expect(t.isDirty(.{ .active = .{ .x = 0, .y = 2 } }));
try testing.expect(t.isDirty(.{ .active = .{ .x = 0, .y = 3 } }));
{ {
const str = try t.plainString(testing.allocator); const str = try t.plainString(testing.allocator);
defer testing.allocator.free(str); defer testing.allocator.free(str);
@ -4523,8 +4530,14 @@ test "Terminal: insertLines outside of scroll region" {
try t.printString("GHI"); try t.printString("GHI");
t.setTopAndBottomMargin(3, 4); t.setTopAndBottomMargin(3, 4);
t.setCursorPos(2, 2); t.setCursorPos(2, 2);
t.clearDirty();
t.insertLines(1); t.insertLines(1);
try testing.expect(!t.isDirty(.{ .active = .{ .x = 0, .y = 0 } }));
try testing.expect(!t.isDirty(.{ .active = .{ .x = 0, .y = 1 } }));
try testing.expect(!t.isDirty(.{ .active = .{ .x = 0, .y = 2 } }));
{ {
const str = try t.plainString(testing.allocator); const str = try t.plainString(testing.allocator);
defer testing.allocator.free(str); defer testing.allocator.free(str);
@ -4549,8 +4562,15 @@ test "Terminal: insertLines top/bottom scroll region" {
try t.printString("123"); try t.printString("123");
t.setTopAndBottomMargin(1, 3); t.setTopAndBottomMargin(1, 3);
t.setCursorPos(2, 2); t.setCursorPos(2, 2);
t.clearDirty();
t.insertLines(1); t.insertLines(1);
try testing.expect(!t.isDirty(.{ .active = .{ .x = 0, .y = 0 } }));
try testing.expect(t.isDirty(.{ .active = .{ .x = 0, .y = 1 } }));
try testing.expect(t.isDirty(.{ .active = .{ .x = 0, .y = 2 } }));
try testing.expect(!t.isDirty(.{ .active = .{ .x = 0, .y = 3 } }));
{ {
const str = try t.plainString(testing.allocator); const str = try t.plainString(testing.allocator);
defer testing.allocator.free(str); defer testing.allocator.free(str);
@ -4623,8 +4643,14 @@ test "Terminal: insertLines with scroll region" {
t.setTopAndBottomMargin(1, 2); t.setTopAndBottomMargin(1, 2);
t.setCursorPos(1, 1); t.setCursorPos(1, 1);
t.clearDirty();
t.insertLines(1); t.insertLines(1);
try testing.expect(t.isDirty(.{ .active = .{ .x = 0, .y = 0 } }));
try testing.expect(t.isDirty(.{ .active = .{ .x = 0, .y = 1 } }));
try testing.expect(!t.isDirty(.{ .active = .{ .x = 0, .y = 2 } }));
try t.print('X'); try t.print('X');
{ {
@ -4658,8 +4684,13 @@ test "Terminal: insertLines more than remaining" {
t.setCursorPos(2, 1); t.setCursorPos(2, 1);
// Insert a bunch of lines // Insert a bunch of lines
t.clearDirty();
t.insertLines(20); t.insertLines(20);
try testing.expect(!t.isDirty(.{ .active = .{ .x = 0, .y = 0 } }));
try testing.expect(t.isDirty(.{ .active = .{ .x = 0, .y = 1 } }));
try testing.expect(t.isDirty(.{ .active = .{ .x = 0, .y = 2 } }));
{ {
const str = try t.plainString(testing.allocator); const str = try t.plainString(testing.allocator);
defer testing.allocator.free(str); defer testing.allocator.free(str);
@ -4758,8 +4789,15 @@ test "Terminal: insertLines left/right scroll region" {
t.scrolling_region.left = 1; t.scrolling_region.left = 1;
t.scrolling_region.right = 3; t.scrolling_region.right = 3;
t.setCursorPos(2, 2); t.setCursorPos(2, 2);
t.clearDirty();
t.insertLines(1); t.insertLines(1);
try testing.expect(!t.isDirty(.{ .active = .{ .x = 0, .y = 0 } }));
try testing.expect(t.isDirty(.{ .active = .{ .x = 0, .y = 1 } }));
try testing.expect(t.isDirty(.{ .active = .{ .x = 0, .y = 2 } }));
try testing.expect(t.isDirty(.{ .active = .{ .x = 0, .y = 3 } }));
{ {
const str = try t.plainString(testing.allocator); const str = try t.plainString(testing.allocator);
defer testing.allocator.free(str); defer testing.allocator.free(str);