mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-05-18 11:10:22 +00:00
config: add background-opacity and float parsing for config
This commit is contained in:
@@ -144,6 +144,11 @@ fn parseIntoField(
|
||||
0,
|
||||
),
|
||||
|
||||
f64 => try std.fmt.parseFloat(
|
||||
f64,
|
||||
value orelse return error.ValueRequired,
|
||||
),
|
||||
|
||||
else => unreachable,
|
||||
};
|
||||
|
||||
@@ -298,6 +303,20 @@ test "parseIntoField: unsigned numbers" {
|
||||
try testing.expectEqual(@as(u8, 1), data.u8);
|
||||
}
|
||||
|
||||
test "parseIntoField: floats" {
|
||||
const testing = std.testing;
|
||||
var arena = ArenaAllocator.init(testing.allocator);
|
||||
defer arena.deinit();
|
||||
const alloc = arena.allocator();
|
||||
|
||||
var data: struct {
|
||||
f64: f64,
|
||||
} = undefined;
|
||||
|
||||
try parseIntoField(@TypeOf(data), alloc, &data, "f64", "1");
|
||||
try testing.expectEqual(@as(f64, 1.0), data.f64);
|
||||
}
|
||||
|
||||
test "parseIntoField: optional field" {
|
||||
const testing = std.testing;
|
||||
var arena = ArenaAllocator.init(testing.allocator);
|
||||
|
||||
Reference in New Issue
Block a user