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
All checks were successful
Zig Project Action / Lint, Spell-check and test zig project (push) Successful in 1m42s
This commit is contained in:
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user