tests: fix TextInput test
This commit is contained in:
parent
5ad01f6a3a
commit
31b97f73d2
2 changed files with 11 additions and 3 deletions
|
@ -27,5 +27,7 @@ pub fn init(alloc: std.mem.Allocator, opts: Vaxis.Options) !Vaxis {
|
|||
|
||||
test {
|
||||
std.testing.refAllDecls(@This());
|
||||
std.testing.refAllDecls(widgets);
|
||||
_ = @import("Parser.zig");
|
||||
_ = @import("Tty.zig");
|
||||
}
|
||||
|
|
|
@ -316,12 +316,15 @@ fn deleteAtCursor(self: *TextInput) !void {
|
|||
}
|
||||
|
||||
test "assertion" {
|
||||
const alloc = std.testing.allocator_instance.allocator();
|
||||
const unicode = try Unicode.init(alloc);
|
||||
defer unicode.deinit();
|
||||
const astronaut = "👩🚀";
|
||||
const astronaut_emoji: Key = .{
|
||||
.text = astronaut,
|
||||
.codepoint = try std.unicode.utf8Decode(astronaut[0..4]),
|
||||
};
|
||||
var input = TextInput.init(std.testing.allocator);
|
||||
var input = TextInput.init(std.testing.allocator, &unicode);
|
||||
defer input.deinit();
|
||||
for (0..6) |_| {
|
||||
try input.update(.{ .key_press = astronaut_emoji });
|
||||
|
@ -329,8 +332,11 @@ test "assertion" {
|
|||
}
|
||||
|
||||
test "sliceToCursor" {
|
||||
var alloc = std.testing.allocator_instance;
|
||||
var input = init(alloc.allocator());
|
||||
const alloc = std.testing.allocator_instance.allocator();
|
||||
const unicode = try Unicode.init(alloc);
|
||||
defer unicode.deinit();
|
||||
var input = init(alloc, &unicode);
|
||||
defer input.deinit();
|
||||
try input.insertSliceAtCursor("hello, world");
|
||||
input.cursor_idx = 2;
|
||||
var buf: [32]u8 = undefined;
|
||||
|
|
Loading…
Reference in a new issue