Move test

This commit is contained in:
2026-01-06 14:41:15 +01:00
parent 6c9a786926
commit 49cf6e4237

View File

@@ -63,16 +63,7 @@ pub const Color = extern struct {
@compileError("Invalid color literal: " ++ literal);
}
pub inline fn asArray(self: Color) Array {
return @bitCast(self);
}
pub fn format(self: Color, w: *std.io.Writer) !void {
try w.print("#{X:0>2}{X:0>2}{X:0>2}{X:0>2}", .{ self.r, self.g, self.b, self.a });
}
};
test "l" {
test l {
const i: Color = .l("#012");
try std.testing.expectEqual(0x00, i.r);
try std.testing.expectEqual(0x11, i.g);
@@ -91,9 +82,18 @@ test "l" {
try std.testing.expectEqual(0x40, k.b);
try std.testing.expectEqual(0xFF, k.a);
const l: Color = .l("#20304050");
try std.testing.expectEqual(0x20, l.r);
try std.testing.expectEqual(0x30, l.g);
try std.testing.expectEqual(0x40, l.b);
try std.testing.expectEqual(0x50, l.a);
const m: Color = .l("#20304050");
try std.testing.expectEqual(0x20, m.r);
try std.testing.expectEqual(0x30, m.g);
try std.testing.expectEqual(0x40, m.b);
try std.testing.expectEqual(0x50, m.a);
}
pub inline fn asArray(self: Color) Array {
return @bitCast(self);
}
pub fn format(self: Color, w: *std.io.Writer) !void {
try w.print("#{X:0>2}{X:0>2}{X:0>2}{X:0>2}", .{ self.r, self.g, self.b, self.a });
}
};