add(test): input testing of Key.isAscii
All checks were successful
Zig Project Action / Lint, Spell-check and test zig project (push) Successful in 1m42s

This commit is contained in:
2025-02-25 16:52:17 +01:00
parent 8519d204f3
commit a588e2ef21

View File

@@ -88,6 +88,24 @@ pub const Key = packed struct {
(this.cp >= 32 and this.cp <= 126 or // ascii printable characters (except for input.Delete) (this.cp >= 32 and this.cp <= 126 or // ascii printable characters (except for input.Delete)
this.cp >= 128 and this.cp <= 255); // extended ascii codes this.cp >= 128 and this.cp <= 255); // extended ascii codes
} }
test "isAscii with ascii character" {
try std.testing.expectEqual(true, isAscii(.{ .cp = 'c' }));
try std.testing.expectEqual(false, isAscii(.{ .cp = 'c', .mod = .{ .ctrl = true } }));
try std.testing.expectEqual(false, isAscii(.{ .cp = 'c', .mod = .{ .alt = true } }));
try std.testing.expectEqual(false, isAscii(.{ .cp = 'c', .mod = .{ .alt = true, .ctrl = true } }));
}
test "isAscii with non-ascii character" {
try std.testing.expectEqual(false, isAscii(.{ .cp = Escape }));
try std.testing.expectEqual(false, isAscii(.{ .cp = Enter }));
try std.testing.expectEqual(false, isAscii(.{ .cp = Enter, .mod = .{ .alt = true } }));
}
test "isAscii with excluded input.Delete" {
try std.testing.expectEqual(false, isAscii(.{ .cp = Delete }));
try std.testing.expectEqual(false, isAscii(.{ .cp = Delete, .mod = .{ .alt = false, .ctrl = false } }));
}
}; };
// codepoints for keys // codepoints for keys