fix: ColorList.clone not cloning colors_c

pull/9613/head
Jake Nelson 2025-11-17 15:58:50 +11:00
parent bee5875351
commit 243d32c82a
1 changed files with 21 additions and 0 deletions

View File

@ -5203,6 +5203,7 @@ pub const ColorList = struct {
) Allocator.Error!Self {
return .{
.colors = try self.colors.clone(alloc),
.colors_c = try self.colors_c.clone(alloc),
};
}
@ -5281,6 +5282,26 @@ pub const ColorList = struct {
try p.formatEntry(formatterpkg.entryFormatter("a", &buf.writer));
try std.testing.expectEqualSlices(u8, "a = #000000,#ffffff\n", buf.written());
}
test "clone" {
const testing = std.testing;
var arena = ArenaAllocator.init(testing.allocator);
defer arena.deinit();
const alloc = arena.allocator();
var source: Self = .{};
try source.parseCLI(alloc, "#ff0000,#00ff00,#0000ff");
const cloned = try source.clone(alloc);
try testing.expect(source.equal(cloned));
try testing.expectEqual(source.colors_c.items.len, cloned.colors_c.items.len);
for (source.colors_c.items, cloned.colors_c.items) |src_c, clone_c| {
try testing.expectEqual(src_c.r, clone_c.r);
try testing.expectEqual(src_c.g, clone_c.g);
try testing.expectEqual(src_c.b, clone_c.b);
}
}
};
/// Palette is the 256 color palette for 256-color mode. This is still