font/shaper: test with bg only cells

This commit is contained in:
Mitchell Hashimoto
2024-03-08 09:48:44 -08:00
parent 34200a3e83
commit efe037bb9f

View File

@ -307,41 +307,62 @@ test "run iterator" {
} }
} }
// test "run iterator: empty cells with background set" { test "run iterator: empty cells with background set" {
// const testing = std.testing; const testing = std.testing;
// const alloc = testing.allocator; const alloc = testing.allocator;
//
// var testdata = try testShaper(alloc); var testdata = try testShaper(alloc);
// defer testdata.deinit(); defer testdata.deinit();
//
// { {
// // Make a screen with some data // Make a screen with some data
// var screen = try terminal.Screen.init(alloc, 3, 5, 0); var screen = try terminal.Screen.init(alloc, 5, 3, 0);
// defer screen.deinit(); defer screen.deinit();
// screen.cursor.pen.bg = .{ .rgb = try terminal.color.Name.cyan.default() }; try screen.setAttribute(.{ .direct_color_bg = .{ .r = 0xFF, .g = 0, .b = 0 } });
// try screen.testWriteString("A"); try screen.testWriteString("A");
//
// // Get our first row // Get our first row
// const row = screen.getRow(.{ .active = 0 }); {
// row.getCellPtr(1).* = screen.cursor.pen; const list_cell = screen.pages.getCell(.{ .active = .{ .x = 1 } }).?;
// row.getCellPtr(2).* = screen.cursor.pen; const cell = list_cell.cell;
// cell.* = .{
// // Get our run iterator .content_tag = .bg_color_rgb,
// var shaper = &testdata.shaper; .content = .{ .color_rgb = .{ .r = 0xFF, .g = 0, .b = 0 } },
// var it = shaper.runIterator(testdata.cache, screen.getRow(.{ .screen = 0 }), null, null); };
// var count: usize = 0; }
// while (try it.next(alloc)) |run| { {
// count += 1; const list_cell = screen.pages.getCell(.{ .active = .{ .x = 2 } }).?;
// const cell = list_cell.cell;
// // The run should have length 3 because of the two background cell.* = .{
// // cells. .content_tag = .bg_color_rgb,
// try testing.expectEqual(@as(u32, 3), shaper.hb_buf.getLength()); .content = .{ .color_rgb = .{ .r = 0xFF, .g = 0, .b = 0 } },
// const cells = try shaper.shape(run); };
// try testing.expectEqual(@as(usize, 3), cells.len); }
// }
// try testing.expectEqual(@as(usize, 1), count); // Get our run iterator
// } var shaper = &testdata.shaper;
// } var it = shaper.runIterator(
testdata.cache,
&screen,
screen.pages.pin(.{ .screen = .{ .y = 0 } }).?,
null,
null,
);
{
const run = (try it.next(alloc)).?;
try testing.expectEqual(@as(u32, 1), shaper.hb_buf.getLength());
const cells = try shaper.shape(run);
try testing.expectEqual(@as(usize, 1), cells.len);
}
{
const run = (try it.next(alloc)).?;
try testing.expectEqual(@as(u32, 2), shaper.hb_buf.getLength());
const cells = try shaper.shape(run);
try testing.expectEqual(@as(usize, 2), cells.len);
}
try testing.expect(try it.next(alloc) == null);
}
}
test "shape" { test "shape" {
const testing = std.testing; const testing = std.testing;