mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +03:00
input: unit tests for pasing tuples
This commit is contained in:
@ -288,6 +288,9 @@ pub const Action = union(enum) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If we have extra parameters it is an error
|
||||||
|
if (it.next() != null) return Error.InvalidFormat;
|
||||||
|
|
||||||
break :blk value;
|
break :blk value;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -829,6 +832,27 @@ test "parse: action with float" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test "parse: action with a tuple" {
|
||||||
|
const testing = std.testing;
|
||||||
|
|
||||||
|
// parameter
|
||||||
|
{
|
||||||
|
const binding = try parse("a=resize_split:up,10");
|
||||||
|
try testing.expect(binding.action == .resize_split);
|
||||||
|
try testing.expectEqual(Action.SplitResizeDirection.up, binding.action.resize_split[0]);
|
||||||
|
try testing.expectEqual(@as(u16, 10), binding.action.resize_split[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// missing parameter
|
||||||
|
try testing.expectError(Error.InvalidFormat, parse("a=resize_split:up"));
|
||||||
|
|
||||||
|
// too many
|
||||||
|
try testing.expectError(Error.InvalidFormat, parse("a=resize_split:up,10,12"));
|
||||||
|
|
||||||
|
// invalid type
|
||||||
|
try testing.expectError(Error.InvalidFormat, parse("a=resize_split:up,four"));
|
||||||
|
}
|
||||||
|
|
||||||
test "set: maintains reverse mapping" {
|
test "set: maintains reverse mapping" {
|
||||||
const testing = std.testing;
|
const testing = std.testing;
|
||||||
const alloc = testing.allocator;
|
const alloc = testing.allocator;
|
||||||
|
Reference in New Issue
Block a user