Move test

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

View File

@@ -63,6 +63,32 @@ pub const Color = extern struct {
@compileError("Invalid color literal: " ++ literal);
}
test l {
const i: Color = .l("#012");
try std.testing.expectEqual(0x00, i.r);
try std.testing.expectEqual(0x11, i.g);
try std.testing.expectEqual(0x22, i.b);
try std.testing.expectEqual(0xFF, i.a);
const j: Color = .l("#3456");
try std.testing.expectEqual(0x33, j.r);
try std.testing.expectEqual(0x44, j.g);
try std.testing.expectEqual(0x55, j.b);
try std.testing.expectEqual(0x66, j.a);
const k: Color = .l("#F08040");
try std.testing.expectEqual(0xF0, k.r);
try std.testing.expectEqual(0x80, k.g);
try std.testing.expectEqual(0x40, k.b);
try std.testing.expectEqual(0xFF, k.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);
}
@@ -71,29 +97,3 @@ pub const Color = extern struct {
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" {
const i: Color = .l("#012");
try std.testing.expectEqual(0x00, i.r);
try std.testing.expectEqual(0x11, i.g);
try std.testing.expectEqual(0x22, i.b);
try std.testing.expectEqual(0xFF, i.a);
const j: Color = .l("#3456");
try std.testing.expectEqual(0x33, j.r);
try std.testing.expectEqual(0x44, j.g);
try std.testing.expectEqual(0x55, j.b);
try std.testing.expectEqual(0x66, j.a);
const k: Color = .l("#F08040");
try std.testing.expectEqual(0xF0, k.r);
try std.testing.expectEqual(0x80, k.g);
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);
}